diff --git "a/\350\222\213\345\242\236\350\276\211/.gitignore" "b/\350\222\213\345\242\236\350\276\211/.gitignore" new file mode 100644 index 0000000000000000000000000000000000000000..3e8a1553fcff7845c779d3cb8014e151a9931506 --- /dev/null +++ "b/\350\222\213\345\242\236\350\276\211/.gitignore" @@ -0,0 +1,341 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ +# ASP.NET Core default setup: bower directory is configured as wwwroot/lib/ and bower restore is true +**/wwwroot/lib/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb diff --git "a/\350\222\213\345\242\236\350\276\211/WEBapp001.sln" "b/\350\222\213\345\242\236\350\276\211/WEBapp001.sln" new file mode 100644 index 0000000000000000000000000000000000000000..2f332dad9e9f05d3675c94b91daf1b9605324722 --- /dev/null +++ "b/\350\222\213\345\242\236\350\276\211/WEBapp001.sln" @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.757 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WEBapp001", "WEBapp001\WEBapp001.csproj", "{081944F8-86C2-4AB4-A607-83E3170ED488}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {081944F8-86C2-4AB4-A607-83E3170ED488}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {081944F8-86C2-4AB4-A607-83E3170ED488}.Debug|Any CPU.Build.0 = Debug|Any CPU + {081944F8-86C2-4AB4-A607-83E3170ED488}.Release|Any CPU.ActiveCfg = Release|Any CPU + {081944F8-86C2-4AB4-A607-83E3170ED488}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {EC80615E-A281-4D65-BE41-B970443FAE2D} + EndGlobalSection +EndGlobal diff --git "a/\350\222\213\345\242\236\350\276\211/WEBapp001/Controllers/TestController.cs" "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Controllers/TestController.cs" new file mode 100644 index 0000000000000000000000000000000000000000..3fad0009a2f5f208e974ba1e8dc25eed5074fd5e --- /dev/null +++ "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Controllers/TestController.cs" @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.ViewFeatures; +using Newtonsoft.Json.Serialization; +using WEBapp001.Domain; +using WEBapp001.Helper; +using WEBapp001.Interface; +using JsonHelper = WEBapp001.Helper.JsonHelper; + +namespace WEBapp001.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class TestController : ControllerBase + { + private readonly IRespository Studentrespository; + public TestController(IRespository respository) + { + Studentrespository = respository; + } + + public string Get() + { + var res = Studentrespository.Table.ToList(); + return JsonHelper.SerializeObject(res); + } + + } +} \ No newline at end of file diff --git "a/\350\222\213\345\242\236\350\276\211/WEBapp001/Controllers/ValuesController.cs" "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Controllers/ValuesController.cs" new file mode 100644 index 0000000000000000000000000000000000000000..ec20e763f9e5961ed5ac7a3bb9a93ce4e6f8bff1 --- /dev/null +++ "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Controllers/ValuesController.cs" @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using WEBapp001.Domain; +using Microsoft.Extensions.DependencyInjection; +using Newtonsoft.Json; +using System.CodeDom.Compiler; +using WEBapp001.Helper; + +namespace WEBapp001.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class ValuesController : ControllerBase + { + + private readonly DbSchoolContext _db; + + [ActivatorUtilitiesConstructor] + public ValuesController(DbSchoolContext dbSchoolContext) + { + _db = dbSchoolContext; + } + // GET api/values + [HttpGet] + public string Get() + { + var res= _db.Students.ToList(); + return JsonHelper.SerializeObject(res); + + } + + // GET api/values/5 + + + + // POST api/values + [HttpPost] + public void Post([FromBody] string value) + { + } + + // PUT api/values/5 + [HttpPut("{id}")] + public void Put(int id, [FromBody] string value) + { + } + + // DELETE api/values/5 + [HttpDelete("{id}")] + public void Delete(int id) + { + } + } +} diff --git "a/\350\222\213\345\242\236\350\276\211/WEBapp001/Domain/DbInitializer.cs" "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Domain/DbInitializer.cs" new file mode 100644 index 0000000000000000000000000000000000000000..77f90d5696426738c5690cba82b58806a2009b99 --- /dev/null +++ "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Domain/DbInitializer.cs" @@ -0,0 +1,70 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Internal; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using WEBapp001.Domain.Entity; + +namespace WEBapp001.Domain +{ + public class DbInitializer + { + public static void Seed() + { + using (var db=new DbSchoolContext()) + { + db.Database.EnsureCreated(); + + var IsEsixt = db.Students.Any(); + if (!IsEsixt) + { + + var Collge = new Collge + { + CollgeName="忍术科", + DeanName="猿飞日斩" + + }; + + db.Collges.Add(Collge); + db.SaveChanges(); + + db.Students.AddRange(new Student[] { + new Student + { + StuName="宇智波鼬", + StuAge=26, + StuPri="火之国木叶忍村", + StuSex="男", + Remarske="宇智波鼬,火之国木叶隐村宇智波一族的天才忍者。年幼时他与宇智波止水是挚友,实力强大,擅长使用幻术" + + }, + new Student + { + StuName="宇智佐助", + StuAge=17, + StuPri="火之国木叶忍村", + StuSex="男", + Remarske="佐助是一个具有强大意志的人。在忍者学校,才貌双全的佐助很受女生欢迎,但他丝毫未受影响,为自己的目标不断提高能力。后来他以第一名的成绩在忍者学校毕业,是全村最为期待的头号优等生。“我可是拼了命去做的,不要用‘天才’两个字抹杀掉我的努力!”这是佐助对自己的诠释" + }, + new Student + { + StuName="宇智止水", + StuAge=29, + StuPri="火之国木叶忍村", + StuSex="男", + Remarske="宇智波止水,火之国木叶隐村宇智波一族的天才忍者,年幼时他与宇智波鼬是挚友,有着比鼬更强的瞳术天赋。实力强大,擅长使用幻术和瞬身术,以“瞬身止水”之名威震天下。他身为宇智波镜的后代,不仅是宇智波鼬的导师,同时也是宇智波鼬的挚友,宇智波鼬对其如亲生兄长一般尊敬。" + } + }); + db.SaveChanges(); + + + + + + } + } + } + } +} diff --git "a/\350\222\213\345\242\236\350\276\211/WEBapp001/Domain/DbSchoolContext.cs" "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Domain/DbSchoolContext.cs" new file mode 100644 index 0000000000000000000000000000000000000000..2b4d6838b728addb8e64747de17dd6309d042355 --- /dev/null +++ "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Domain/DbSchoolContext.cs" @@ -0,0 +1,27 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using WEBapp001.Domain.Entity; + +namespace WEBapp001.Domain +{ + public class DbSchoolContext :DbContext + { + public DbSchoolContext() + { + + } + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + optionsBuilder.UseSqlServer("server=.;database=School;uid=sa;pwd=123456"); + } + + public DbSet Students { get; set; } + + public DbSet Schools { get; set; } + + public DbSet Collges { get; set; } + } +} diff --git "a/\350\222\213\345\242\236\350\276\211/WEBapp001/Domain/Entity/BaseEntity.cs" "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Domain/Entity/BaseEntity.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5eee19b2a6274cd268691202eaf8ccb6d74d16a6 --- /dev/null +++ "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Domain/Entity/BaseEntity.cs" @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace WEBapp001.Domain +{ + public abstract class BaseEntity + { + public BaseEntity() + { + IsActived = true; + IsDeleted = false; + CreatedTime = DateTime.Now; + UpDatedTime = DateTime.Now; + + } + + public int Id { set; get; } + + public DateTime CreatedTime { get; set; } + + public DateTime UpDatedTime { get; set; } + + public bool IsActived { get; set; } + + public bool IsDeleted { get; set; } + + public string Remarske { get; set; } + + } +} diff --git "a/\350\222\213\345\242\236\350\276\211/WEBapp001/Domain/Entity/Collge.cs" "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Domain/Entity/Collge.cs" new file mode 100644 index 0000000000000000000000000000000000000000..0809a22bcccecf04f3ba7d4c80501c22ff0201f5 --- /dev/null +++ "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Domain/Entity/Collge.cs" @@ -0,0 +1,16 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace WEBapp001.Domain.Entity +{ + public class Collge:BaseEntity + { + public string CollgeName { get; set; } + public string DeanName { get; set; } + + public DbSet Studentid { set; get; } + } +} diff --git "a/\350\222\213\345\242\236\350\276\211/WEBapp001/Domain/Entity/School.cs" "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Domain/Entity/School.cs" new file mode 100644 index 0000000000000000000000000000000000000000..eea7c24f812fc4ef037a0ae342a8ad2d6503ccf1 --- /dev/null +++ "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Domain/Entity/School.cs" @@ -0,0 +1,21 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using WEBapp001.Domain.Entity; + +namespace WEBapp001.Domain +{ + public class School:BaseEntity + { + public string SchoolName { get; set; } + + public string SchoolPriv { get; set; } + + public string Schoolcolle { get; set; } + + public DbSet Collges { get; set; } + + } +} diff --git "a/\350\222\213\345\242\236\350\276\211/WEBapp001/Domain/Entity/Student.cs" "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Domain/Entity/Student.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7e99aba6554ced0d503be5e59001e8e7c7365af6 --- /dev/null +++ "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Domain/Entity/Student.cs" @@ -0,0 +1,24 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using WEBapp001.Domain.Entity; + +namespace WEBapp001.Domain +{ + public class Student:BaseEntity + { + public string StuName { get; set; } + + public string StuSex { get; set; } + + public string StuPri { get; set; } + + public int StuAge { get; set; } + + + + + } +} diff --git "a/\350\222\213\345\242\236\350\276\211/WEBapp001/Helper/JsonHelper.cs" "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Helper/JsonHelper.cs" new file mode 100644 index 0000000000000000000000000000000000000000..0124408c87c241093104f70c3e8b4625fe593aa5 --- /dev/null +++ "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Helper/JsonHelper.cs" @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Newtonsoft.Json; + +namespace WEBapp001.Helper +{ + public class JsonHelper + { + public static string SerializeObject(object obj) + { + return JsonConvert.SerializeObject(obj, Formatting.Indented, new JsonSerializerSettings + { + ReferenceLoopHandling = ReferenceLoopHandling.Ignore, + DateFormatString = "yyyy-MM-dd hh:mm:ss" + }); ; + } + + } +} diff --git "a/\350\222\213\345\242\236\350\276\211/WEBapp001/Implementation/EfRespository.cs" "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Implementation/EfRespository.cs" new file mode 100644 index 0000000000000000000000000000000000000000..6dcb21dd350c0672714f76c64e13cdc9ac3a754e --- /dev/null +++ "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Implementation/EfRespository.cs" @@ -0,0 +1,87 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography.X509Certificates; +using System.Threading.Tasks; +using WEBapp001.Domain; +using WEBapp001.Interface; + +namespace WEBapp001.Implementation +{ + public class EfRespository : IRespository where T:BaseEntity + { + private readonly DbSchoolContext db; + private DbSet _Entity; + + protected DbSet Entity + { + get + { + if (_Entity == null) + { + _Entity = db.Set(); + } + return _Entity; + } + + } + public IQueryable Table + { + get + { + return Entity; + } + } + public EfRespository(DbSchoolContext schoolContext) + { + db = schoolContext; + } + + public void BulkInsert(IEnumerable list) + { + _Entity.AddRange(list); + + db.SaveChanges(); + } + + public void Delete(T entity) + { + this._Entity.Remove(entity); + db.SaveChanges(); + } + + public void Delete(int id) + { + var row = Table.Where(x=>x.Id==id).FirstOrDefault(); + Delete(row); + db.SaveChanges(); + } + + + public T GitById(int id) + { + //T t = null; + + return _Entity.Where(x => x.Id == id).FirstOrDefault(); + + } + + public void Insert(T entity) + { + _Entity.Add(entity); + db.SaveChanges(); + } + + public void Update(T entity) + { + _Entity.Update(entity); + db.SaveChanges(); + } + + + + + + } +} diff --git "a/\350\222\213\345\242\236\350\276\211/WEBapp001/Interface/IRespository.cs" "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Interface/IRespository.cs" new file mode 100644 index 0000000000000000000000000000000000000000..6280bdaed9693825f89dbfa0d08cb317b99bb2a9 --- /dev/null +++ "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Interface/IRespository.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using WEBapp001.Domain; + +namespace WEBapp001.Interface +{ + public interface IRespository + { + IQueryable Table { get; } + + T GitById(int id); + + + void Insert(T entity); + + void BulkInsert(IEnumerable list); + + void Update(T entity); + + void Delete(T entity); + + void Delete(int id); + } +} diff --git "a/\350\222\213\345\242\236\350\276\211/WEBapp001/Program.cs" "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..a41b196bd891b5b0b7481d2554b222fc358a4843 --- /dev/null +++ "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Program.cs" @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; + +namespace WEBapp001 +{ + public class Program + { + public static void Main(string[] args) + { + CreateWebHostBuilder(args).Build().Run(); + } + + public static IWebHostBuilder CreateWebHostBuilder(string[] args) => + WebHost.CreateDefaultBuilder(args) + .UseStartup(); + } +} diff --git "a/\350\222\213\345\242\236\350\276\211/WEBapp001/Properties/launchSettings.json" "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Properties/launchSettings.json" new file mode 100644 index 0000000000000000000000000000000000000000..1623de7202c5f20355308b7aab01f8e927e84ee4 --- /dev/null +++ "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Properties/launchSettings.json" @@ -0,0 +1,30 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:2328", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "api/values", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "WEBapp001": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "api/values", + "applicationUrl": "http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git "a/\350\222\213\345\242\236\350\276\211/WEBapp001/Startup.cs" "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Startup.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b9bf3afaec0bc4881eb891f5ff04d09979f4a849 --- /dev/null +++ "b/\350\222\213\345\242\236\350\276\211/WEBapp001/Startup.cs" @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using WEBapp001.Domain; +using WEBapp001.Implementation; +using WEBapp001.Interface; + +namespace WEBapp001 +{ + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + services.AddDbContext(); + + services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + + services.AddScoped(typeof(IRespository<>), typeof(EfRespository<>)); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IHostingEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseMvc(); + + DbInitializer.Seed(); + } + } +} diff --git "a/\350\222\213\345\242\236\350\276\211/WEBapp001/WEBapp001.csproj" "b/\350\222\213\345\242\236\350\276\211/WEBapp001/WEBapp001.csproj" new file mode 100644 index 0000000000000000000000000000000000000000..667b7a82b743eec491469466a2f67958c6c56a3c --- /dev/null +++ "b/\350\222\213\345\242\236\350\276\211/WEBapp001/WEBapp001.csproj" @@ -0,0 +1,20 @@ + + + + netcoreapp2.1 + + + + + + + + + + + + + + + + diff --git "a/\350\222\213\345\242\236\350\276\211/WEBapp001/appsettings.Development.json" "b/\350\222\213\345\242\236\350\276\211/WEBapp001/appsettings.Development.json" new file mode 100644 index 0000000000000000000000000000000000000000..e203e9407e74a6b9662aab8fde5d73ae64665f18 --- /dev/null +++ "b/\350\222\213\345\242\236\350\276\211/WEBapp001/appsettings.Development.json" @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Microsoft": "Information" + } + } +} diff --git "a/\350\222\213\345\242\236\350\276\211/WEBapp001/appsettings.json" "b/\350\222\213\345\242\236\350\276\211/WEBapp001/appsettings.json" new file mode 100644 index 0000000000000000000000000000000000000000..def9159a7d9403c04a926f64e71ef3ee7c9e4c57 --- /dev/null +++ "b/\350\222\213\345\242\236\350\276\211/WEBapp001/appsettings.json" @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Warning" + } + }, + "AllowedHosts": "*" +}