├── .gitattributes ├── .gitignore ├── Business ├── Abstract │ ├── ICategoryService.cs │ └── IProductService.cs ├── Business.csproj ├── Concrete │ ├── CategoryManager.cs │ └── ProductManager.cs └── Constants │ └── Messages.cs ├── ConsoleUI ├── ConsoleUI.csproj └── Program.cs ├── Core ├── Core.csproj ├── DataAccess │ ├── EntityFramework │ │ └── EfEntityRepositoryBase.cs │ └── IEntityRepository.cs ├── Entities │ ├── IDto.cs │ └── IEntity.cs └── Utilities │ └── Results │ ├── DataResult.cs │ ├── ErrorDataResult.cs │ ├── ErrorResult.cs │ ├── IDataResult.cs │ ├── IResult.cs │ ├── Result.cs │ ├── SuccessDataResult.cs │ └── SuccessResult.cs ├── DataAccess ├── Abstract │ ├── ICategoryDal.cs │ ├── ICustomerDal.cs │ ├── IOrderDal.cs │ └── IProductDal.cs ├── Concrete │ ├── EntityFramework │ │ ├── EfCategoryDal.cs │ │ ├── EfOrderDal.cs │ │ ├── EfProductDal.cs │ │ └── NorthwindContext.cs │ └── InMemory │ │ └── InMemoryProductDal.cs └── DataAccess.csproj ├── Entities ├── Concrete │ ├── Category.cs │ ├── Customer.cs │ ├── Order.cs │ └── Product.cs ├── DTOs │ └── ProductDetailDto.cs └── Entities.csproj ├── MyFinalProject.sln └── WebAPI ├── Controllers ├── ProductsController.cs └── ValuesController.cs ├── Program.cs ├── Properties └── launchSettings.json ├── Startup.cs ├── WebAPI.csproj ├── appsettings.Development.json └── appsettings.json /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc -------------------------------------------------------------------------------- /Business/Abstract/ICategoryService.cs: -------------------------------------------------------------------------------- 1 | using Entities.Concrete; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Business.Abstract 7 | { 8 | public interface ICategoryService 9 | { 10 | List GetAll(); 11 | Category GetById(int categoryId); 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Business/Abstract/IProductService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results; 2 | using Entities.Concrete; 3 | using Entities.DTOs; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace Business.Abstract 9 | { 10 | public interface IProductService 11 | { 12 | IDataResult> GetAll(); 13 | IDataResult> GetAllByCategoryId(int id); 14 | IDataResult> GetByUnitPrice(decimal min, decimal max); 15 | IDataResult> GetProductDetails(); 16 | IDataResult GetById(int productId); 17 | 18 | IResult Add(Product product); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Business/Business.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Business/Concrete/CategoryManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using DataAccess.Abstract; 3 | using Entities.Concrete; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace Business.Concrete 9 | { 10 | public class CategoryManager : ICategoryService 11 | { 12 | ICategoryDal _categoryDal; 13 | 14 | public CategoryManager(ICategoryDal categoryDal) 15 | { 16 | _categoryDal = categoryDal; 17 | } 18 | 19 | public List GetAll() 20 | { 21 | return _categoryDal.GetAll(); 22 | } 23 | //Select*from Categories where CategoryId= 3 -what you send 24 | public Category GetById(int categoryId) 25 | { 26 | return _categoryDal.Get(c => c.CategoryId == categoryId); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Business/Concrete/ProductManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Constants; 3 | using Core.Utilities.Results; 4 | using DataAccess.Abstract; 5 | using Entities.Concrete; 6 | using Entities.DTOs; 7 | using System; 8 | using System.Collections.Generic; 9 | using System.Text; 10 | 11 | namespace Business.Concrete 12 | { 13 | public class ProductManager : IProductService 14 | { 15 | IProductDal _productDal; 16 | private string messages; 17 | 18 | public ProductManager(IProductDal productDal) 19 | { 20 | _productDal = productDal; 21 | } 22 | 23 | 24 | 25 | public IDataResult> GetAll() 26 | { 27 | 28 | if (DateTime.Now.Hour == 1) 29 | { 30 | return new ErrorDataResult>(Messages.MaintenanceTime); 31 | } 32 | return new SuccessDataResult>(_productDal.GetAll(),Messages.ProductsListed); 33 | 34 | } 35 | 36 | public IDataResult> GetByUnitPrice(decimal min, decimal max) 37 | { 38 | return new SuccessDataResult>(_productDal.GetAll(p => p.UnitPrice >= min && p.UnitPrice <= max)); 39 | } 40 | 41 | public IDataResult> GetAllByCategoryId(int id) 42 | { 43 | return new SuccessDataResult>(_productDal.GetAll(p=>p.CategoryId==id)); 44 | } 45 | 46 | public IDataResult> GetProductDetails() 47 | { 48 | return new SuccessDataResult>(_productDal.GetProductDetails()); 49 | } 50 | 51 | public IResult Add(Product product) 52 | { 53 | //business codes 54 | 55 | 56 | if (product.ProductName.Length<2) 57 | { 58 | return new ErrorResult(Messages.ProductNameInvalid); 59 | } 60 | _productDal.Add(product); 61 | return new SuccessResult(Messages.ProductAdded); 62 | } 63 | 64 | public IDataResult GetById(int productId) 65 | { 66 | return new SuccessDataResult(_productDal.Get(p=>p.ProductId == productId)); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Business/Constants/Messages.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Entities.Concrete; 5 | 6 | namespace Business.Constants 7 | { 8 | public class Messages 9 | { 10 | public static string ProductAdded = " Product added"; 11 | public static string ProductNameInvalid = " Product name is invalid"; 12 | internal static string MaintenanceTime = "System is under maintenance"; 13 | internal static string ProductsListed="ürünler listelendi"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /ConsoleUI/ConsoleUI.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /ConsoleUI/Program.cs: -------------------------------------------------------------------------------- 1 | using Business.Concrete; 2 | using DataAccess.Concrete.EntityFramework; 3 | using DataAccess.Concrete.InMemory; 4 | using System; 5 | 6 | namespace ConsoleUI 7 | { 8 | class Program 9 | { 10 | static void Main(string[] args) 11 | { 12 | ProductTest(); 13 | //IoC 14 | // CategoryTest(); 15 | 16 | Console.ReadLine(); 17 | } 18 | 19 | private static void CategoryTest() 20 | { 21 | CategoryManager categoryManager = new CategoryManager(new EfCategoryDal()); 22 | foreach (var category in categoryManager.GetAll()) 23 | { 24 | Console.WriteLine(category.CategoryName); 25 | } 26 | } 27 | 28 | private static void ProductTest() 29 | { 30 | ProductManager productManager = new ProductManager(new EfProductDal()); 31 | 32 | var result = productManager.GetProductDetails(); 33 | if (result.Success==true) 34 | { 35 | foreach (var product in result.Data) 36 | { 37 | Console.WriteLine(product.ProductName + "/" + product.CategoryName); 38 | } 39 | } 40 | else 41 | { 42 | Console.WriteLine(result.Message); 43 | } 44 | 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Core/Core.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 7.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Core/DataAccess/EntityFramework/EfEntityRepositoryBase.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using Microsoft.EntityFrameworkCore; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Linq.Expressions; 7 | using System.Text; 8 | 9 | 10 | namespace Core.DataAccess.EntityFramework 11 | { 12 | public class EfEntityRepositoryBase:IEntityRepository 13 | where TEntity:class,IEntity,new() 14 | where TContext:DbContext,new() 15 | { 16 | public void Add(TEntity entity) 17 | { 18 | //IDısposable pattern implementation of c# 19 | using (TContext context = new TContext()) 20 | { 21 | var addedEntity = context.Entry(entity); 22 | addedEntity.State = EntityState.Added; 23 | context.SaveChanges(); 24 | 25 | } 26 | } 27 | 28 | public void Delete(TEntity entity) 29 | { 30 | using (TContext context = new TContext()) 31 | { 32 | var deletedEntity = context.Entry(entity); 33 | deletedEntity.State = EntityState.Deleted; 34 | context.SaveChanges(); 35 | 36 | } 37 | } 38 | 39 | public TEntity Get(Expression> filter) 40 | { 41 | using (TContext context = new TContext()) 42 | { 43 | return context.Set().SingleOrDefault(filter); 44 | 45 | } 46 | } 47 | 48 | public List GetAll(Expression> filter = null) 49 | { 50 | using (TContext context = new TContext()) 51 | { 52 | return filter == null ? context.Set().ToList() : context.Set().Where(filter).ToList(); 53 | } 54 | } 55 | 56 | public void Update(TEntity entity) 57 | { 58 | using (TContext context = new TContext()) 59 | { 60 | var updatedEntity = context.Entry(entity); 61 | updatedEntity.State = EntityState.Modified; 62 | context.SaveChanges(); 63 | 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Core/DataAccess/IEntityRepository.cs: -------------------------------------------------------------------------------- 1 |  2 | using Core.Entities; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq.Expressions; 6 | using System.Text; 7 | 8 | namespace Core.DataAccess 9 | { 10 | public interface IEntityRepository where T:class,IEntity,new() 11 | { 12 | 13 | //generic constraint 14 | //Class 15 | List GetAll(Expression> filter = null); 16 | T Get(Expression> filter); 17 | void Add(T entity); 18 | void Update(T entity); 19 | void Delete(T entity); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Core/Entities/IDto.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Entities 2 | { 3 | public interface IDto 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /Core/Entities/IEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Entities 6 | { 7 | 8 | public interface IEntity 9 | { 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Core/Utilities/Results/DataResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results 6 | { 7 | public class DataResult : Result, IDataResult 8 | { 9 | public DataResult(T data,bool success, string message):base(success,message) 10 | { 11 | Data = data; 12 | } 13 | public DataResult(T data,bool success):base(success) 14 | { 15 | Data = data; 16 | } 17 | public T Data { get; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Core/Utilities/Results/ErrorDataResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results 6 | { 7 | public class ErrorDataResult : DataResult 8 | { 9 | public ErrorDataResult(T data, string message) : base(data, false, message) 10 | { 11 | 12 | } 13 | public ErrorDataResult(T data) : base(data, false) 14 | { 15 | 16 | } 17 | public ErrorDataResult(string message) : base(default, false, message) 18 | { 19 | 20 | } 21 | public ErrorDataResult() : base(default, false) 22 | { 23 | 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Core/Utilities/Results/ErrorResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results 6 | { 7 | public class ErrorResult:Result 8 | { 9 | public ErrorResult(string message) : base(false, message) 10 | { 11 | 12 | } 13 | public ErrorResult() : base(false) 14 | { 15 | 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Core/Utilities/Results/IDataResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results 6 | { 7 | public interface IDataResult:IResult 8 | { 9 | T Data { get; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Core/Utilities/Results/IResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results 6 | { 7 | 8 | //for basic 9 | public interface IResult 10 | { 11 | bool Success { get; } 12 | string Message { get; } 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Core/Utilities/Results/Result.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results 6 | { 7 | public class Result : IResult 8 | { 9 | 10 | public Result(bool success, string message):this(success) 11 | { 12 | Message = message; 13 | 14 | } 15 | 16 | public Result (bool success) 17 | { 18 | Success = success; 19 | } 20 | 21 | public string Message { get; } 22 | public bool Success { get; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Core/Utilities/Results/SuccessDataResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results 6 | { 7 | public class SuccessDataResult:DataResult 8 | { 9 | public SuccessDataResult(T data, string message):base(data,true,message) 10 | { 11 | 12 | } 13 | public SuccessDataResult(T data):base(data,true) 14 | { 15 | 16 | } 17 | public SuccessDataResult(string message):base(default,true,message) 18 | { 19 | 20 | } 21 | public SuccessDataResult():base(default,true) 22 | { 23 | 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Utilities/Results/SuccessResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results 6 | { 7 | public class SuccessResult : Result 8 | { 9 | public SuccessResult(string message) : base(true, message) 10 | { 11 | 12 | } 13 | public SuccessResult():base(true) 14 | { 15 | 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /DataAccess/Abstract/ICategoryDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Entities.Concrete; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace DataAccess.Abstract 8 | { 9 | public interface ICategoryDal:IEntityRepository 10 | { 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DataAccess/Abstract/ICustomerDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Entities.Concrete; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace DataAccess.Abstract 8 | { 9 | public interface ICustomerDal:IEntityRepository 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /DataAccess/Abstract/IOrderDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Entities.Concrete; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace DataAccess.Abstract 8 | { 9 | public interface IOrderDal:IEntityRepository 10 | { 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DataAccess/Abstract/IProductDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Entities.Concrete; 3 | using Entities.DTOs; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace DataAccess.Abstract 9 | { 10 | public interface IProductDal:IEntityRepository 11 | { 12 | 13 | List GetProductDetails(); 14 | } 15 | } 16 | 17 | 18 | //Code Refactoring -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfCategoryDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using DataAccess.Abstract; 3 | using Entities.Concrete; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq.Expressions; 7 | using System.Text; 8 | 9 | namespace DataAccess.Concrete.EntityFramework 10 | { 11 | public class EfCategoryDal : EfEntityRepositoryBase,ICategoryDal 12 | { 13 | 14 | 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfOrderDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using DataAccess.Abstract; 3 | using Entities.Concrete; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace DataAccess.Concrete.EntityFramework 9 | { 10 | public class EfOrderDal:EfEntityRepositoryBase,IOrderDal 11 | { 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfProductDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using DataAccess.Abstract; 3 | using Entities.Concrete; 4 | using Entities.DTOs; 5 | using Microsoft.EntityFrameworkCore; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Linq.Expressions; 10 | using System.Text; 11 | 12 | namespace DataAccess.Concrete.EntityFramework 13 | { 14 | public class EfProductDal : EfEntityRepositoryBase, IProductDal 15 | { 16 | public List GetProductDetails() 17 | { 18 | 19 | using (NorthwindContext context = new NorthwindContext()) 20 | { 21 | var result = from p in context.Products 22 | join c in context.Categories 23 | on p.CategoryId equals c.CategoryId 24 | select new ProductDetailDto {ProductId = p.ProductId,ProductName = p.ProductName,CategoryName=c.CategoryName,UnitsInStock=p.UnitsInStock }; 25 | return result.ToList(); 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/NorthwindContext.cs: -------------------------------------------------------------------------------- 1 | using Entities.Concrete; 2 | using Microsoft.EntityFrameworkCore; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace DataAccess.Concrete.EntityFramework 8 | { 9 | //Context : db tabloları ile proje classlarını ilişkilendirmek. 10 | 11 | public class NorthwindContext:DbContext 12 | { 13 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 14 | { 15 | optionsBuilder.UseSqlServer(@"Server=(localdb)\MSSQLLocalDB;Database=Northwind;Trusted_Connection=true"); 16 | } 17 | 18 | public DbSet Products { get; set; } 19 | public DbSet Categories { get; set; } 20 | public DbSet Customers { get; set; } 21 | public DbSet Orders { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /DataAccess/Concrete/InMemory/InMemoryProductDal.cs: -------------------------------------------------------------------------------- 1 | using DataAccess.Abstract; 2 | using Entities.Concrete; 3 | using Entities.DTOs; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Linq.Expressions; 8 | using System.Text; 9 | 10 | namespace DataAccess.Concrete.InMemory 11 | { 12 | public class InMemoryProductDal : IProductDal 13 | { 14 | List _products; 15 | public InMemoryProductDal() 16 | { 17 | //oracle,sql server,postgres,mongodb 18 | _products = new List { 19 | new Product{ProductId=1, CategoryId=1, ProductName="Bardak",UnitPrice =15, UnitsInStock=15}, 20 | new Product{ProductId=2, CategoryId=1, ProductName="Kamera",UnitPrice =500, UnitsInStock=3}, 21 | new Product{ProductId=3, CategoryId=2, ProductName="Telefon",UnitPrice =1500, UnitsInStock=2}, 22 | new Product{ProductId=4, CategoryId=2, ProductName="Klavye",UnitPrice =150, UnitsInStock=65}, 23 | new Product{ProductId=5, CategoryId=2, ProductName="Fare",UnitPrice =85, UnitsInStock=1} 24 | }; 25 | } 26 | public void Add(Product product) 27 | { 28 | _products.Add(product); 29 | } 30 | 31 | public void Delete(Product product) 32 | { 33 | 34 | 35 | Product productToDelete = _products.SingleOrDefault(p=>p.ProductId==product.ProductId); 36 | 37 | 38 | _products.Remove(productToDelete); 39 | } 40 | 41 | public List GetAll() 42 | { 43 | return _products; 44 | } 45 | 46 | public void Update(Product product) 47 | { 48 | Product productToUpdate = _products.SingleOrDefault(p => p.ProductId == product.ProductId); 49 | productToUpdate.ProductName = product.ProductName; 50 | productToUpdate.CategoryId = product.CategoryId; 51 | productToUpdate.UnitPrice = product.UnitPrice; 52 | productToUpdate.UnitsInStock = product.UnitsInStock; 53 | 54 | } 55 | public List GetAllByCategory(int categoryId) 56 | { 57 | return _products.Where(p => p.CategoryId == categoryId).ToList(); 58 | } 59 | 60 | public List GetAll(Expression> filter = null) 61 | { 62 | throw new NotImplementedException(); 63 | } 64 | 65 | public Product Get(Expression> filter) 66 | { 67 | throw new NotImplementedException(); 68 | } 69 | 70 | public List GetProductDetails() 71 | { 72 | throw new NotImplementedException(); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /DataAccess/DataAccess.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Entities/Concrete/Category.cs: -------------------------------------------------------------------------------- 1 |  2 | using Core.Entities; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Entities.Concrete 8 | { 9 | public class Category:IEntity 10 | { 11 | 12 | public int CategoryId { get; set; } 13 | public string CategoryName { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Entities/Concrete/Customer.cs: -------------------------------------------------------------------------------- 1 |  2 | using Core.Entities; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Entities.Concrete 8 | { 9 | public class Customer:IEntity 10 | { 11 | public string CustomerId { get; set; } 12 | public string ContactName { get; set; } 13 | public string CompanyName { get; set; } 14 | public string City { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Entities/Concrete/Order.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class Order:IEntity 9 | { 10 | public int OrderId { get; set; } 11 | public string CustomerId { get; set; } 12 | public int EmployeeId { get; set; } 13 | public DateTime OrderDate { get; set; } 14 | public string ShipCity { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Entities/Concrete/Product.cs: -------------------------------------------------------------------------------- 1 |  2 | using Core.Entities; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Entities.Concrete 8 | { 9 | public class Product:IEntity 10 | { 11 | public int ProductId { get; set; } 12 | public int CategoryId { get; set; } 13 | public string ProductName { get; set; } 14 | public short UnitsInStock { get; set; } 15 | public decimal UnitPrice { get; set; } 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Entities/DTOs/ProductDetailDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.DTOs 7 | { 8 | public class ProductDetailDto:IDto 9 | { 10 | public int ProductId { get; set; } 11 | public string ProductName { get; set; } 12 | public string CategoryName { get; set; } 13 | public short UnitsInStock { get; set; } 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Entities/Entities.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /MyFinalProject.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.852 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataAccess", "DataAccess\DataAccess.csproj", "{D07ED5E7-3494-4DA6-8F08-03116B6BE3C2}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Business", "Business\Business.csproj", "{0C7AFA2A-B471-4A7F-8AC7-E882C21AB969}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Entities", "Entities\Entities.csproj", "{BAE7497E-19A6-4EFE-AF6C-55F7D78BBD72}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleUI", "ConsoleUI\ConsoleUI.csproj", "{33D0F405-A0DD-4B36-B22E-07146F733BA8}" 13 | EndProject 14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core", "Core\Core.csproj", "{C1EB0AE0-FD06-4FA7-A951-C71BCF89ACF4}" 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAPI", "WebAPI\WebAPI.csproj", "{7F0DC54E-5B0F-42C8-B880-33A98B304741}" 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 20 | Debug|Any CPU = Debug|Any CPU 21 | Release|Any CPU = Release|Any CPU 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {D07ED5E7-3494-4DA6-8F08-03116B6BE3C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {D07ED5E7-3494-4DA6-8F08-03116B6BE3C2}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {D07ED5E7-3494-4DA6-8F08-03116B6BE3C2}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {D07ED5E7-3494-4DA6-8F08-03116B6BE3C2}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {0C7AFA2A-B471-4A7F-8AC7-E882C21AB969}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {0C7AFA2A-B471-4A7F-8AC7-E882C21AB969}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {0C7AFA2A-B471-4A7F-8AC7-E882C21AB969}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {0C7AFA2A-B471-4A7F-8AC7-E882C21AB969}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {BAE7497E-19A6-4EFE-AF6C-55F7D78BBD72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {BAE7497E-19A6-4EFE-AF6C-55F7D78BBD72}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {BAE7497E-19A6-4EFE-AF6C-55F7D78BBD72}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {BAE7497E-19A6-4EFE-AF6C-55F7D78BBD72}.Release|Any CPU.Build.0 = Release|Any CPU 36 | {33D0F405-A0DD-4B36-B22E-07146F733BA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 37 | {33D0F405-A0DD-4B36-B22E-07146F733BA8}.Debug|Any CPU.Build.0 = Debug|Any CPU 38 | {33D0F405-A0DD-4B36-B22E-07146F733BA8}.Release|Any CPU.ActiveCfg = Release|Any CPU 39 | {33D0F405-A0DD-4B36-B22E-07146F733BA8}.Release|Any CPU.Build.0 = Release|Any CPU 40 | {C1EB0AE0-FD06-4FA7-A951-C71BCF89ACF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 41 | {C1EB0AE0-FD06-4FA7-A951-C71BCF89ACF4}.Debug|Any CPU.Build.0 = Debug|Any CPU 42 | {C1EB0AE0-FD06-4FA7-A951-C71BCF89ACF4}.Release|Any CPU.ActiveCfg = Release|Any CPU 43 | {C1EB0AE0-FD06-4FA7-A951-C71BCF89ACF4}.Release|Any CPU.Build.0 = Release|Any CPU 44 | {7F0DC54E-5B0F-42C8-B880-33A98B304741}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 45 | {7F0DC54E-5B0F-42C8-B880-33A98B304741}.Debug|Any CPU.Build.0 = Debug|Any CPU 46 | {7F0DC54E-5B0F-42C8-B880-33A98B304741}.Release|Any CPU.ActiveCfg = Release|Any CPU 47 | {7F0DC54E-5B0F-42C8-B880-33A98B304741}.Release|Any CPU.Build.0 = Release|Any CPU 48 | EndGlobalSection 49 | GlobalSection(SolutionProperties) = preSolution 50 | HideSolutionNode = FALSE 51 | EndGlobalSection 52 | GlobalSection(ExtensibilityGlobals) = postSolution 53 | SolutionGuid = {6477E403-5E1E-48B5-B8A2-22F4F3CD2042} 54 | EndGlobalSection 55 | EndGlobal 56 | -------------------------------------------------------------------------------- /WebAPI/Controllers/ProductsController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Business.Abstract; 6 | using Business.Concrete; 7 | using DataAccess.Concrete.EntityFramework; 8 | using Entities.Concrete; 9 | using Microsoft.AspNetCore.Http; 10 | using Microsoft.AspNetCore.Mvc; 11 | 12 | namespace WebAPI.Controllers 13 | { 14 | [Route("api/[controller]")] 15 | [ApiController] 16 | public class ProductsController : ControllerBase 17 | { 18 | //Loosely coupled 19 | //naming convention 20 | //IoC Container - Inversion of Control 21 | IProductService _productService; 22 | 23 | public ProductsController(IProductService productService) 24 | { 25 | _productService = productService; 26 | } 27 | 28 | [HttpGet("getall")] 29 | public IActionResult GetAll() 30 | { 31 | 32 | //Swagger 33 | //Dependency chain -- 34 | 35 | var result = _productService.GetAll(); 36 | if (result.Success) 37 | { 38 | return Ok(result); 39 | } 40 | return BadRequest(result); 41 | } 42 | [HttpGet("getbyid")] 43 | public IActionResult GetById(int id) 44 | { 45 | var result = _productService.GetById(id); 46 | if (result.Success) 47 | { 48 | return Ok(result.Data); 49 | } 50 | return BadRequest(result); 51 | } 52 | 53 | [HttpPost("add")] 54 | public IActionResult Add(Product product) 55 | { 56 | var result = _productService.Add(product); 57 | if (result.Success) 58 | { 59 | return Ok(result); 60 | } 61 | return BadRequest(result); 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /WebAPI/Controllers/ValuesController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | namespace WebAPI.Controllers 8 | { 9 | [Route("api/[controller]")] 10 | [ApiController] 11 | public class ValuesController : ControllerBase 12 | { 13 | // GET api/values 14 | [HttpGet] 15 | public ActionResult> Get() 16 | { 17 | return new string[] { "value1", "value2" }; 18 | } 19 | 20 | // GET api/values/5 21 | [HttpGet("{id}")] 22 | public ActionResult Get(int id) 23 | { 24 | return "value"; 25 | } 26 | 27 | // POST api/values 28 | [HttpPost] 29 | public void Post([FromBody] string value) 30 | { 31 | } 32 | 33 | // PUT api/values/5 34 | [HttpPut("{id}")] 35 | public void Put(int id, [FromBody] string value) 36 | { 37 | } 38 | 39 | // DELETE api/values/5 40 | [HttpDelete("{id}")] 41 | public void Delete(int id) 42 | { 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /WebAPI/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.Extensions.Configuration; 9 | using Microsoft.Extensions.Logging; 10 | 11 | namespace WebAPI 12 | { 13 | public class Program 14 | { 15 | public static void Main(string[] args) 16 | { 17 | CreateWebHostBuilder(args).Build().Run(); 18 | } 19 | 20 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) => 21 | WebHost.CreateDefaultBuilder(args) 22 | .UseStartup(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /WebAPI/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:1040", 8 | "sslPort": 44354 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "api/values", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "WebAPI": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "api/values", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /WebAPI/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Business.Abstract; 6 | using Business.Concrete; 7 | using DataAccess.Abstract; 8 | using DataAccess.Concrete.EntityFramework; 9 | using Microsoft.AspNetCore.Builder; 10 | using Microsoft.AspNetCore.Hosting; 11 | using Microsoft.AspNetCore.HttpsPolicy; 12 | using Microsoft.AspNetCore.Mvc; 13 | using Microsoft.Extensions.Configuration; 14 | using Microsoft.Extensions.DependencyInjection; 15 | using Microsoft.Extensions.Logging; 16 | using Microsoft.Extensions.Options; 17 | 18 | namespace WebAPI 19 | { 20 | public class Startup 21 | { 22 | public Startup(IConfiguration configuration) 23 | { 24 | Configuration = configuration; 25 | } 26 | 27 | public IConfiguration Configuration { get; } 28 | 29 | // This method gets called by the runtime. Use this method to add services to the container. 30 | public void ConfigureServices(IServiceCollection services) 31 | { //Autofac, Ninject, CastleWindsor, StructureMap, LightInject, DryInject --> IoC Container 32 | //AOP 33 | services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); 34 | services.AddSingleton(); 35 | services.AddSingleton(); 36 | } 37 | 38 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 39 | public void Configure(IApplicationBuilder app, IHostingEnvironment env) 40 | { 41 | if (env.IsDevelopment()) 42 | { 43 | app.UseDeveloperExceptionPage(); 44 | } 45 | else 46 | { 47 | app.UseHsts(); 48 | } 49 | 50 | app.UseHttpsRedirection(); 51 | app.UseMvc(); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /WebAPI/WebAPI.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /WebAPI/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /WebAPI/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Warning" 5 | } 6 | }, 7 | "AllowedHosts": "*" 8 | } 9 | --------------------------------------------------------------------------------