├── .gitattributes ├── .gitignore ├── Business ├── Abstract │ ├── IBrandService.cs │ ├── ICarService.cs │ ├── IColorService.cs │ ├── ICustomerService.cs │ ├── IRentalService.cs │ └── IUserService.cs ├── Business.csproj ├── Concrete │ ├── BrandManager.cs │ ├── CarManager.cs │ ├── ColorManager.cs │ ├── CustomerManager.cs │ ├── RentalManager.cs │ └── UserManager.cs ├── Constants │ └── Messages.cs ├── DependencyResolvers │ └── Autofac │ │ └── AutofacBusinessModule.cs └── ValidationRules │ └── FluentValidation │ ├── BrandValidator.cs │ ├── CarValidator.cs │ ├── ColorValidator.cs │ ├── CustomerValidator.cs │ ├── RentalValidator.cs │ └── UserValidator.cs ├── ConsoleUI ├── ConsoleUI.csproj └── Program.cs ├── Core ├── Aspects │ └── Autofac │ │ └── Validation │ │ └── ValidationAspect.cs ├── Core.csproj ├── CrossCuttingConcerns │ └── Validation │ │ └── ValidationTool.cs ├── DataAccess │ ├── EntityFramework │ │ └── EfEntityRepositoryBase.cs │ └── IEntityRepository.cs ├── Entities │ ├── IDto.cs │ └── IEntity.cs └── Utilities │ ├── Interceptors │ ├── AspectInterceptorSelector.cs │ ├── MethodInterception.cs │ └── MethodInterceptionBaseAttribute.cs │ └── Results │ ├── DataResult.cs │ ├── ErrorDataResult.cs │ ├── ErrorResult.cs │ ├── IDataResult.cs │ ├── IResult.cs │ ├── Result.cs │ ├── SuccessDataResult.cs │ └── SuccessResult.cs ├── DataAccess ├── Abstract │ ├── IBrandDal.cs │ ├── ICarDal.cs │ ├── IColorDal.cs │ ├── ICustomerDal.cs │ ├── IRentalDal.cs │ └── IUserDal.cs ├── Concrete │ └── EntityFramework │ │ ├── EfBrandDal.cs │ │ ├── EfCarDal.cs │ │ ├── EfColorDal.cs │ │ ├── EfCustomerDal.cs │ │ ├── EfRentalDal.cs │ │ ├── EfUserDal.cs │ │ └── ReCapDatabaseContext.cs └── DataAccess.csproj ├── Entities ├── Concrete │ ├── Brand.cs │ ├── Car.cs │ ├── Color.cs │ ├── Customer.cs │ ├── Rental.cs │ └── User.cs ├── DTOs │ ├── CarDetailDto.cs │ └── RentalDetailDto.cs └── Entities.csproj ├── ReCapProject.sln └── WebAPI ├── Controllers ├── BrandsController.cs ├── CarsController.cs ├── ColorsController.cs ├── CustomersController.cs ├── RentalsController.cs └── UsersController.cs ├── Program.cs ├── Properties └── launchSettings.json ├── Startup.cs ├── WeatherForecast.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 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | [Aa][Rr][Mm]/ 24 | [Aa][Rr][Mm]64/ 25 | bld/ 26 | [Bb]in/ 27 | [Oo]bj/ 28 | [Ll]og/ 29 | 30 | # Visual Studio 2015/2017 cache/options directory 31 | .vs/ 32 | # Uncomment if you have tasks that create the project's static files in wwwroot 33 | #wwwroot/ 34 | 35 | # Visual Studio 2017 auto generated files 36 | Generated\ Files/ 37 | 38 | # MSTest test Results 39 | [Tt]est[Rr]esult*/ 40 | [Bb]uild[Ll]og.* 41 | 42 | # NUNIT 43 | *.VisualState.xml 44 | TestResult.xml 45 | 46 | # Build Results of an ATL Project 47 | [Dd]ebugPS/ 48 | [Rr]eleasePS/ 49 | dlldata.c 50 | 51 | # Benchmark Results 52 | BenchmarkDotNet.Artifacts/ 53 | 54 | # .NET Core 55 | project.lock.json 56 | project.fragment.lock.json 57 | artifacts/ 58 | 59 | # StyleCop 60 | StyleCopReport.xml 61 | 62 | # Files built by Visual Studio 63 | *_i.c 64 | *_p.c 65 | *_h.h 66 | *.ilk 67 | *.meta 68 | *.obj 69 | *.iobj 70 | *.pch 71 | *.pdb 72 | *.ipdb 73 | *.pgc 74 | *.pgd 75 | *.rsp 76 | *.sbr 77 | *.tlb 78 | *.tli 79 | *.tlh 80 | *.tmp 81 | *.tmp_proj 82 | *_wpftmp.csproj 83 | *.log 84 | *.vspscc 85 | *.vssscc 86 | .builds 87 | *.pidb 88 | *.svclog 89 | *.scc 90 | 91 | # Chutzpah Test files 92 | _Chutzpah* 93 | 94 | # Visual C++ cache files 95 | ipch/ 96 | *.aps 97 | *.ncb 98 | *.opendb 99 | *.opensdf 100 | *.sdf 101 | *.cachefile 102 | *.VC.db 103 | *.VC.VC.opendb 104 | 105 | # Visual Studio profiler 106 | *.psess 107 | *.vsp 108 | *.vspx 109 | *.sap 110 | 111 | # Visual Studio Trace Files 112 | *.e2e 113 | 114 | # TFS 2012 Local Workspace 115 | $tf/ 116 | 117 | # Guidance Automation Toolkit 118 | *.gpState 119 | 120 | # ReSharper is a .NET coding add-in 121 | _ReSharper*/ 122 | *.[Rr]e[Ss]harper 123 | *.DotSettings.user 124 | 125 | # JustCode is a .NET coding add-in 126 | .JustCode 127 | 128 | # TeamCity is a build add-in 129 | _TeamCity* 130 | 131 | # DotCover is a Code Coverage Tool 132 | *.dotCover 133 | 134 | # AxoCover is a Code Coverage Tool 135 | .axoCover/* 136 | !.axoCover/settings.json 137 | 138 | # Visual Studio code coverage results 139 | *.coverage 140 | *.coveragexml 141 | 142 | # NCrunch 143 | _NCrunch_* 144 | .*crunch*.local.xml 145 | nCrunchTemp_* 146 | 147 | # MightyMoose 148 | *.mm.* 149 | AutoTest.Net/ 150 | 151 | # Web workbench (sass) 152 | .sass-cache/ 153 | 154 | # Installshield output folder 155 | [Ee]xpress/ 156 | 157 | # DocProject is a documentation generator add-in 158 | DocProject/buildhelp/ 159 | DocProject/Help/*.HxT 160 | DocProject/Help/*.HxC 161 | DocProject/Help/*.hhc 162 | DocProject/Help/*.hhk 163 | DocProject/Help/*.hhp 164 | DocProject/Help/Html2 165 | DocProject/Help/html 166 | 167 | # Click-Once directory 168 | publish/ 169 | 170 | # Publish Web Output 171 | *.[Pp]ublish.xml 172 | *.azurePubxml 173 | # Note: Comment the next line if you want to checkin your web deploy settings, 174 | # but database connection strings (with potential passwords) will be unencrypted 175 | *.pubxml 176 | *.publishproj 177 | 178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 179 | # checkin your Azure Web App publish settings, but sensitive information contained 180 | # in these scripts will be unencrypted 181 | PublishScripts/ 182 | 183 | # NuGet Packages 184 | *.nupkg 185 | # The packages folder can be ignored because of Package Restore 186 | **/[Pp]ackages/* 187 | # except build/, which is used as an MSBuild target. 188 | !**/[Pp]ackages/build/ 189 | # Uncomment if necessary however generally it will be regenerated when needed 190 | #!**/[Pp]ackages/repositories.config 191 | # NuGet v3's project.json files produces more ignorable files 192 | *.nuget.props 193 | *.nuget.targets 194 | 195 | # Microsoft Azure Build Output 196 | csx/ 197 | *.build.csdef 198 | 199 | # Microsoft Azure Emulator 200 | ecf/ 201 | rcf/ 202 | 203 | # Windows Store app package directories and files 204 | AppPackages/ 205 | BundleArtifacts/ 206 | Package.StoreAssociation.xml 207 | _pkginfo.txt 208 | *.appx 209 | 210 | # Visual Studio cache files 211 | # files ending in .cache can be ignored 212 | *.[Cc]ache 213 | # but keep track of directories ending in .cache 214 | !?*.[Cc]ache/ 215 | 216 | # Others 217 | ClientBin/ 218 | ~$* 219 | *~ 220 | *.dbmdl 221 | *.dbproj.schemaview 222 | *.jfm 223 | *.pfx 224 | *.publishsettings 225 | orleans.codegen.cs 226 | 227 | # Including strong name files can present a security risk 228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 229 | #*.snk 230 | 231 | # Since there are multiple workflows, uncomment next line to ignore bower_components 232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 233 | #bower_components/ 234 | 235 | # RIA/Silverlight projects 236 | Generated_Code/ 237 | 238 | # Backup & report files from converting an old project file 239 | # to a newer Visual Studio version. Backup files are not needed, 240 | # because we have git ;-) 241 | _UpgradeReport_Files/ 242 | Backup*/ 243 | UpgradeLog*.XML 244 | UpgradeLog*.htm 245 | ServiceFabricBackup/ 246 | *.rptproj.bak 247 | 248 | # SQL Server files 249 | *.mdf 250 | *.ldf 251 | *.ndf 252 | 253 | # Business Intelligence projects 254 | *.rdl.data 255 | *.bim.layout 256 | *.bim_*.settings 257 | *.rptproj.rsuser 258 | *- Backup*.rdl 259 | 260 | # Microsoft Fakes 261 | FakesAssemblies/ 262 | 263 | # GhostDoc plugin setting file 264 | *.GhostDoc.xml 265 | 266 | # Node.js Tools for Visual Studio 267 | .ntvs_analysis.dat 268 | node_modules/ 269 | 270 | # Visual Studio 6 build log 271 | *.plg 272 | 273 | # Visual Studio 6 workspace options file 274 | *.opt 275 | 276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 277 | *.vbw 278 | 279 | # Visual Studio LightSwitch build output 280 | **/*.HTMLClient/GeneratedArtifacts 281 | **/*.DesktopClient/GeneratedArtifacts 282 | **/*.DesktopClient/ModelManifest.xml 283 | **/*.Server/GeneratedArtifacts 284 | **/*.Server/ModelManifest.xml 285 | _Pvt_Extensions 286 | 287 | # Paket dependency manager 288 | .paket/paket.exe 289 | paket-files/ 290 | 291 | # FAKE - F# Make 292 | .fake/ 293 | 294 | # JetBrains Rider 295 | .idea/ 296 | *.sln.iml 297 | 298 | # CodeRush personal settings 299 | .cr/personal 300 | 301 | # Python Tools for Visual Studio (PTVS) 302 | __pycache__/ 303 | *.pyc 304 | 305 | # Cake - Uncomment if you are using it 306 | # tools/** 307 | # !tools/packages.config 308 | 309 | # Tabs Studio 310 | *.tss 311 | 312 | # Telerik's JustMock configuration file 313 | *.jmconfig 314 | 315 | # BizTalk build output 316 | *.btp.cs 317 | *.btm.cs 318 | *.odx.cs 319 | *.xsd.cs 320 | 321 | # OpenCover UI analysis results 322 | OpenCover/ 323 | 324 | # Azure Stream Analytics local run output 325 | ASALocalRun/ 326 | 327 | # MSBuild Binary and Structured Log 328 | *.binlog 329 | 330 | # NVidia Nsight GPU debugger configuration file 331 | *.nvuser 332 | 333 | # MFractors (Xamarin productivity tool) working folder 334 | .mfractor/ 335 | 336 | # Local History for Visual Studio 337 | .localhistory/ 338 | 339 | # BeatPulse healthcheck temp database 340 | healthchecksdb -------------------------------------------------------------------------------- /Business/Abstract/IBrandService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results; 2 | using Entities.Concrete; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Business.Abstract 8 | { 9 | public interface IBrandService 10 | { 11 | IResult Add(Brand brand); 12 | IResult Update(Brand brand); 13 | IResult Delete(Brand brand); 14 | IDataResult> GetAll(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Business/Abstract/ICarService.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 ICarService 11 | { 12 | IDataResult> GetAll(); 13 | IResult Add(Car car); 14 | IResult Delete(Car car); 15 | IResult Update(Car car); 16 | IDataResult> GetCarsByBrandId(int brandId); 17 | IDataResult> GetCarsByColorId(int colorId); 18 | IDataResult> GetCarDetails(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Business/Abstract/IColorService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results; 2 | using Entities.Concrete; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Business.Abstract 8 | { 9 | public interface IColorService 10 | { 11 | IResult Add(Color color); 12 | IResult Update(Color color); 13 | IResult Delete(Color color); 14 | IDataResult> GetAll(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Business/Abstract/ICustomerService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results; 2 | using Entities.Concrete; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Business.Abstract 8 | { 9 | public interface ICustomerService 10 | { 11 | IResult Add(Customer customer); 12 | IDataResult> GetAll(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Business/Abstract/IRentalService.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 IRentalService 11 | { 12 | IDataResult> GetAll(); 13 | IDataResult> GetRentalDetails(); 14 | IResult Add(Rental rental); 15 | IResult CheckReturnDate(int carId); 16 | IResult UpdateReturnDate(int carId); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Business/Abstract/IUserService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results; 2 | using Entities.Concrete; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Business.Abstract 8 | { 9 | public interface IUserService 10 | { 11 | IDataResult> GetAll(); 12 | IResult Update(User user); 13 | IResult Delete(User user); 14 | IResult Add(User user); 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Business/Business.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Business/Concrete/BrandManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Constants; 3 | using Business.ValidationRules.FluentValidation; 4 | using Core.Aspects.Autofac.Validation; 5 | using Core.Utilities.Results; 6 | using DataAccess.Abstract; 7 | using Entities.Concrete; 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Text; 11 | 12 | namespace Business.Concrete 13 | { 14 | public class BrandManager : IBrandService 15 | { 16 | IBrandDal _brandDal; 17 | public BrandManager(IBrandDal brandDal) 18 | { 19 | _brandDal = brandDal; 20 | } 21 | [ValidationAspect(typeof(BrandValidator))] 22 | public IResult Add(Brand brand) 23 | { 24 | _brandDal.Add(brand); 25 | 26 | return new SuccessResult(Messages.BrandAdded); 27 | } 28 | 29 | public IResult Delete(Brand brand) 30 | { 31 | _brandDal.Delete(brand); 32 | 33 | return new SuccessResult(Messages.BrandDeleted); 34 | } 35 | 36 | public IDataResult> GetAll() 37 | { 38 | return new SuccessDataResult>(_brandDal.GetAll()); 39 | } 40 | 41 | public IResult Update(Brand brand) 42 | { 43 | _brandDal.Update(brand); 44 | 45 | return new SuccessResult(Messages.BrandUpdated); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Business/Concrete/CarManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Constants; 3 | using Business.ValidationRules.FluentValidation; 4 | using Core.Aspects.Autofac.Validation; 5 | using Core.Utilities.Results; 6 | using DataAccess.Abstract; 7 | using Entities.Concrete; 8 | using Entities.DTOs; 9 | using System; 10 | using System.Collections.Generic; 11 | using System.Text; 12 | 13 | namespace Business.Concrete 14 | { 15 | public class CarManager : ICarService 16 | { 17 | ICarDal _carDal; 18 | public CarManager(ICarDal carDal) 19 | { 20 | _carDal = carDal; 21 | } 22 | 23 | [ValidationAspect(typeof(CarValidator))] 24 | public IResult Add(Car car) 25 | { 26 | _carDal.Add(car); 27 | 28 | return new SuccessResult(Messages.CarAdded); 29 | 30 | } 31 | 32 | public IResult Delete(Car car) 33 | { 34 | _carDal.Delete(car); 35 | 36 | return new SuccessResult(Messages.CarDeleted); 37 | } 38 | 39 | public IDataResult> GetAll() 40 | { 41 | return new SuccessDataResult>(_carDal.GetAll()); 42 | } 43 | 44 | public IDataResult> GetCarDetails() 45 | { 46 | return _carDal.GetCarDetails(); 47 | } 48 | 49 | public IDataResult> GetCarsByBrandId(int brandId) 50 | { 51 | return new SuccessDataResult>(_carDal.GetAll(c => c.BrandId == brandId)); 52 | } 53 | 54 | public IDataResult> GetCarsByColorId(int colorId) 55 | { 56 | return new SuccessDataResult>(_carDal.GetAll(c => c.ColorId == colorId)); 57 | } 58 | 59 | public IResult Update(Car car) 60 | { 61 | _carDal.Update(car); 62 | return new SuccessResult(Messages.CarUpdated); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Business/Concrete/ColorManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Constants; 3 | using Business.ValidationRules.FluentValidation; 4 | using Core.Aspects.Autofac.Validation; 5 | using Core.Utilities.Results; 6 | using DataAccess.Abstract; 7 | using Entities.Concrete; 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Text; 11 | 12 | namespace Business.Concrete 13 | { 14 | public class ColorManager : IColorService 15 | { 16 | IColorDal _colorDal; 17 | public ColorManager(IColorDal colorDal) 18 | { 19 | _colorDal = colorDal; 20 | } 21 | [ValidationAspect(typeof(ColorValidator))] 22 | public IResult Add(Color color) 23 | { 24 | _colorDal.Add(color); 25 | return new SuccessResult(Messages.ColorAdded); 26 | } 27 | 28 | public IResult Delete(Color color) 29 | { 30 | _colorDal.Delete(color); 31 | return new SuccessResult(Messages.ColorDeleted); 32 | } 33 | 34 | public IDataResult> GetAll() 35 | { 36 | return new SuccessDataResult>(_colorDal.GetAll()); 37 | } 38 | 39 | public IDataResult> GetCarsByColorId(int colorId) 40 | { 41 | return new SuccessDataResult>(_colorDal.GetAll(p => p.ColorId == colorId)); 42 | } 43 | 44 | public IResult Update(Color color) 45 | { 46 | _colorDal.Update(color); 47 | return new SuccessResult(Messages.ColorUpdated); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Business/Concrete/CustomerManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Constants; 3 | using Business.ValidationRules; 4 | using Core.Aspects.Autofac.Validation; 5 | using Core.Utilities.Results; 6 | using DataAccess.Abstract; 7 | using Entities.Concrete; 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Text; 11 | 12 | namespace Business.Concrete 13 | { 14 | public class CustomerManager : ICustomerService 15 | { 16 | ICustomerDal _customerDal; 17 | public CustomerManager(ICustomerDal customerDal) 18 | { 19 | _customerDal = customerDal; 20 | } 21 | [ValidationAspect(typeof(CustomerValidator))] 22 | public IResult Add(Customer customer) 23 | { 24 | _customerDal.Add(customer); 25 | return new SuccessResult(Messages.CustomerAdded); 26 | } 27 | 28 | public IDataResult> GetAll() 29 | { 30 | return new SuccessDataResult>(_customerDal.GetAll()); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Business/Concrete/RentalManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Constants; 3 | using Business.ValidationRules.FluentValidation; 4 | using Core.Aspects.Autofac.Validation; 5 | using Core.Utilities.Results; 6 | using DataAccess.Abstract; 7 | using Entities.Concrete; 8 | using Entities.DTOs; 9 | using System; 10 | using System.Collections.Generic; 11 | using System.Text; 12 | 13 | namespace Business.Concrete 14 | { 15 | public class RentalManager : IRentalService 16 | { 17 | IRentalDal _rentalDal; 18 | public RentalManager(IRentalDal rentalDal) 19 | { 20 | _rentalDal = rentalDal; 21 | } 22 | [ValidationAspect(typeof(RentalValidator))] 23 | public IResult Add(Rental rental) 24 | { 25 | _rentalDal.Add(rental); 26 | return new SuccessResult(Messages.RentalAdded); 27 | } 28 | 29 | public IResult CheckReturnDate(int carId) 30 | { 31 | throw new NotImplementedException(); 32 | } 33 | 34 | public IDataResult> GetAll() 35 | { 36 | return new SuccessDataResult>(_rentalDal.GetAll()); 37 | } 38 | 39 | public IDataResult> GetRentalDetails() 40 | { 41 | return _rentalDal.GetRentalDetails(); 42 | } 43 | 44 | public IResult UpdateReturnDate(int carId) 45 | { 46 | throw new NotImplementedException(); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Business/Concrete/UserManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Constants; 3 | using Business.ValidationRules.FluentValidation; 4 | using Core.Aspects.Autofac.Validation; 5 | using Core.Utilities.Results; 6 | using DataAccess.Abstract; 7 | using Entities.Concrete; 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Text; 11 | 12 | namespace Business.Concrete 13 | { 14 | public class UserManager : IUserService 15 | { 16 | IUserDal _userDal; 17 | public UserManager(IUserDal userDal) 18 | { 19 | _userDal = userDal; 20 | } 21 | [ValidationAspect(typeof(UserValidator))] 22 | public IResult Add(User user) 23 | { 24 | _userDal.Add(user); 25 | return new SuccessResult(Messages.UserAdded); 26 | } 27 | 28 | public IResult Delete(User user) 29 | { 30 | _userDal.Delete(user); 31 | 32 | return new SuccessResult(Messages.UserDeleted); 33 | } 34 | 35 | public IDataResult> GetAll() 36 | { 37 | return new SuccessDataResult>(_userDal.GetAll()); 38 | } 39 | 40 | public IResult Update(User user) 41 | { 42 | _userDal.Update(user); 43 | return new SuccessResult(Messages.UserUpdated); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Business/Constants/Messages.cs: -------------------------------------------------------------------------------- 1 | using Entities.Concrete; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Business.Constants 7 | { 8 | public static class Messages 9 | { 10 | public static string ProductAdded = "Ürün eklendi"; 11 | public static string ProductNameInvalid = "Ürün ismi geçersiz"; 12 | public static string MaintenanceTime = "Saat 22 giremezsin"; 13 | public static string ProductsListed = "Ürünler listelendi"; 14 | public static string ProductsListedByUnitPrice = "Ürünler fiyata göre listelendi"; 15 | public static string ProductDeleted = "Ürün silindi"; 16 | public static string BrandUpdated = "Marka güncellendi"; 17 | public static string BrandDeleted = "Marka silindi"; 18 | public static string BrandAdded = "Marka eklendi"; 19 | public static string BrandNameInvalid = "Marka ismi en az 2 karakter olmalıdır"; 20 | public static string CarNameInvalid = "Araba açıklaması en az 2 karakter olmalıdır"; 21 | public static string CarAdded = "Araba eklendi"; 22 | public static string CarDeleted = "Araba silindi"; 23 | public static string CarUpdated = "Araba güncellendi"; 24 | public static string ColorDeleted = "Renk silindi"; 25 | public static string ColorNameInvalid = "Renk ismi en az iki karakter olmalıdır"; 26 | public static string ColorAdded = "Renk eklendi"; 27 | public static string ColorUpdated = "Renk güncellendi"; 28 | public static string UserFirstNameInvalid = "User ismi en az iki karakter olmalıdır"; 29 | public static string UserAdded = "User eklendi"; 30 | public static string UserDeleted = "User silindi"; 31 | public static string UserUpdated = "User güncellendi"; 32 | public static string RentalAdded = "Kiralanma başarılı"; 33 | public static string CompanyNameInvalid = "Şirket ismi en az 2 karakter olmalıdır."; 34 | public static string CustomerAdded = "Müşteri eklendi"; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Business/DependencyResolvers/Autofac/AutofacBusinessModule.cs: -------------------------------------------------------------------------------- 1 | using Autofac; 2 | using Autofac.Extras.DynamicProxy; 3 | using Business.Abstract; 4 | using Business.Concrete; 5 | using Castle.DynamicProxy; 6 | using Core.Utilities.Interceptors; 7 | using DataAccess.Abstract; 8 | using DataAccess.Concrete.EntityFramework; 9 | using System; 10 | using System.Collections.Generic; 11 | using System.Text; 12 | 13 | namespace Business.DependencyResolvers.Autofac 14 | { 15 | public class AutofacBusinessModule:Module 16 | { 17 | protected override void Load(ContainerBuilder builder) 18 | { 19 | builder.RegisterType().As().SingleInstance(); 20 | builder.RegisterType().As().SingleInstance(); 21 | 22 | builder.RegisterType().As().SingleInstance(); 23 | builder.RegisterType().As().SingleInstance(); 24 | 25 | builder.RegisterType().As().SingleInstance(); 26 | builder.RegisterType().As().SingleInstance(); 27 | 28 | builder.RegisterType().As().SingleInstance(); 29 | builder.RegisterType().As().SingleInstance(); 30 | 31 | builder.RegisterType().As().SingleInstance(); 32 | builder.RegisterType().As().SingleInstance(); 33 | 34 | builder.RegisterType().As().SingleInstance(); 35 | builder.RegisterType().As().SingleInstance(); 36 | 37 | var assembly = System.Reflection.Assembly.GetExecutingAssembly(); 38 | builder.RegisterAssemblyTypes(assembly).AsImplementedInterfaces() 39 | .EnableInterfaceInterceptors(new ProxyGenerationOptions() 40 | { 41 | Selector = new AspectInterceptorSelector() 42 | }).SingleInstance(); 43 | 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/BrandValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.Concrete; 2 | using FluentValidation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Business.ValidationRules.FluentValidation 8 | { 9 | public class BrandValidator:AbstractValidator 10 | { 11 | public BrandValidator() 12 | { 13 | RuleFor(brand => brand.BrandName).NotEmpty(); 14 | RuleFor(brand => brand.BrandName).MinimumLength(2); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/CarValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.Concrete; 2 | using FluentValidation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Business.ValidationRules.FluentValidation 8 | { 9 | public class CarValidator : AbstractValidator 10 | { 11 | public CarValidator() 12 | { 13 | RuleFor(car => car.DailyPrice).GreaterThan(0); 14 | RuleFor(car => car.Description).MinimumLength(2); 15 | RuleFor(car => car.ModelYear).GreaterThanOrEqualTo(1900); 16 | RuleFor(car => car.BrandId).NotEmpty(); 17 | RuleFor(car => car.ColorId).NotEmpty(); 18 | RuleFor(car => car.DailyPrice).NotEmpty(); 19 | RuleFor(car => car.ModelYear).NotEmpty(); 20 | 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/ColorValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.Concrete; 2 | using FluentValidation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Business.ValidationRules.FluentValidation 8 | { 9 | public class ColorValidator:AbstractValidator 10 | { 11 | public ColorValidator() 12 | { 13 | RuleFor(color => color.ColorName).NotEmpty(); 14 | RuleFor(color => color.ColorName).MinimumLength(2); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/CustomerValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.Concrete; 2 | using FluentValidation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Business.ValidationRules 8 | { 9 | public class CustomerValidator : AbstractValidator 10 | { 11 | public CustomerValidator() 12 | { 13 | RuleFor(customer => customer.CompanyName).NotEmpty(); 14 | RuleFor(customer => customer.CompanyName).MinimumLength(2); 15 | RuleFor(customer => customer.CompanyName).MaximumLength(50); 16 | RuleFor(customer => customer.UserId).NotEmpty(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/RentalValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.Concrete; 2 | using FluentValidation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Business.ValidationRules.FluentValidation 8 | { 9 | public class RentalValidator:AbstractValidator 10 | { 11 | public RentalValidator() 12 | { 13 | RuleFor(rental => rental.CustomerId).NotEmpty(); 14 | RuleFor(rental => rental.CarId).NotEmpty(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/UserValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.Concrete; 2 | using FluentValidation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Business.ValidationRules.FluentValidation 8 | { 9 | public class UserValidator:AbstractValidator 10 | { 11 | public UserValidator() 12 | { 13 | RuleFor(user => user.Email).EmailAddress(); 14 | RuleFor(user => user.Email).NotEmpty(); 15 | RuleFor(user => user.FirstName).NotEmpty(); 16 | RuleFor(user => user.FirstName).MinimumLength(2); 17 | RuleFor(user => user.LastName).NotEmpty(); 18 | RuleFor(user => user.LastName).MinimumLength(2); 19 | RuleFor(user => user.Password).NotEmpty(); 20 | RuleFor(user => user.Password).MinimumLength(5); 21 | RuleFor(user => user.Password).MaximumLength(25); 22 | RuleFor(user => user.Password).Must(ContainCapitalLetter); 23 | } 24 | 25 | private bool ContainCapitalLetter(string arg) 26 | { 27 | foreach (var letter in arg) 28 | { 29 | if (letter>='A' && letter<='Z') 30 | { 31 | return true; 32 | } 33 | else 34 | { 35 | continue; 36 | } 37 | } 38 | 39 | return false; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /ConsoleUI/ConsoleUI.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /ConsoleUI/Program.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Concrete; 3 | using DataAccess.Concrete.EntityFramework; 4 | using Entities.Concrete; 5 | using System; 6 | 7 | namespace ConsoleUI 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | CarManager carManager = new CarManager(new EfCarDal()); 14 | BrandManager brandManager = new BrandManager(new EfBrandDal()); 15 | ColorManager colorManager = new ColorManager(new EfColorDal()); 16 | UserManager userManager = new UserManager(new EfUserDal()); 17 | RentalManager rentalManager = new RentalManager(new EfRentalDal()); 18 | CustomerManager customerManager = new CustomerManager(new EfCustomerDal()); 19 | 20 | bool loop = true; 21 | while (loop) 22 | { 23 | Console.WriteLine("**************************MENU**************************\n"); 24 | Console.WriteLine("1-Yeni Araç Ekle\n2-Tüm Araçları Listele\n3-Listeden Bir Aracı Sil\n4-Listedeki Bir Aracın Bilgilerini Güncelle\n5-Yeni Bir Marka Ekle\n6-Bir Markayı Sil\n7-Tüm Markaları Listele\n8-Bir Markayı Güncelle\n9-Renk Ekle\n10-Renk Sil\n11-Tüm Renkleri Listele\n12-Kullanıcı Ekle\n13-Kullanıcı Listele\n14-Kullanıcı Sil\n15-Kiralamak istediğiniz arabayı ekleyin\n16-Kiralık arabaları listeleyin\n17-Müşteri ekle\n18-Müşteri Listele\n19-Çıkış\n"); 25 | Console.WriteLine("********************************************************\n"); 26 | int choice = Convert.ToInt32(Console.ReadLine()); 27 | Console.Clear(); 28 | 29 | switch (choice) 30 | { 31 | case 1: 32 | AddCar(carManager); 33 | break; 34 | case 2: 35 | ListCars(carManager); 36 | break; 37 | case 3: 38 | DeleteCar(carManager); 39 | break; 40 | case 4: 41 | UpdateCar(carManager); 42 | break; 43 | case 5: 44 | AddBrand(brandManager); 45 | break; 46 | case 6: 47 | DeleteBrand(brandManager); 48 | break; 49 | case 7: 50 | ListBrands(brandManager); 51 | break; 52 | case 8: 53 | UpdateBrand(brandManager); 54 | break; 55 | case 9: 56 | AddColor(colorManager); 57 | break; 58 | case 10: 59 | DeleteColor(colorManager); 60 | break; 61 | case 11: 62 | ListColors(colorManager); 63 | break; 64 | case 12: 65 | AddUser(userManager); 66 | break; 67 | case 13: 68 | ListUsers(userManager); 69 | break; 70 | case 14: 71 | DeleteUser(userManager); 72 | break; 73 | case 15: 74 | AddRental(rentalManager,carManager,customerManager); 75 | break; 76 | case 16: 77 | ListRentals(rentalManager); 78 | break; 79 | case 17: 80 | AddCustomer(userManager, customerManager); 81 | break; 82 | case 18: 83 | ListCustomers(customerManager); 84 | break; 85 | case 19: 86 | Console.WriteLine("Programdan çıkış yaptınız.\nİyi günler..."); 87 | loop = false; 88 | break; 89 | default: 90 | break; 91 | } 92 | } 93 | } 94 | 95 | private static void ListCustomers(CustomerManager customerManager) 96 | { 97 | Console.WriteLine("ID | MÜŞTERİNİN ŞİRKET İSMİ\n-------------------------"); 98 | foreach (var customer in customerManager.GetAll().Data) 99 | { 100 | Console.WriteLine($"{customer.Id.ToString().PadRight(5, ' ')}| {customer.CompanyName}"); 101 | } 102 | } 103 | 104 | private static void AddCustomer(UserManager userManager, CustomerManager customerManager) 105 | { 106 | ListUsers(userManager); 107 | Console.Write("Müşteri eklemek için listeden bir numara seçiniz:"); 108 | int customerId = Convert.ToInt32(Console.ReadLine()); 109 | Console.Write("Müşterinin şirket ismini giriniz:"); 110 | string companyName = Console.ReadLine(); 111 | customerManager.Add(new Customer { UserId = customerId, CompanyName = companyName }); 112 | } 113 | 114 | private static void DeleteUser(UserManager userManager) 115 | { 116 | ListUsers(userManager); 117 | Console.Write("Silmek istediğiniz kullanıcının numarasını giriniz:"); 118 | int userId = Convert.ToInt32(Console.ReadLine()); 119 | Console.Clear(); 120 | Console.WriteLine(userManager.Delete(new User { Id = userId }).Message); 121 | } 122 | 123 | private static void ListUsers(UserManager userManager) 124 | { 125 | var users = userManager.GetAll(); 126 | Console.WriteLine("ID | KULLANICININ ADI | KULLANICININ EMAİLİ\n---------------------------------------------------"); 127 | foreach (var user in users.Data) 128 | { 129 | Console.WriteLine($"{user.Id.ToString().PadRight(5, ' ')}| {user.FirstName} {user.LastName} |{user.Email}"); 130 | } 131 | } 132 | 133 | private static void AddUser(UserManager userManager) 134 | { 135 | Console.Write("Eklemek istediğiniz müşterinin emailini giriniz:"); 136 | string email = Console.ReadLine(); 137 | Console.Write("Eklemek istediğiniz müşterinin adını giriniz:"); 138 | string firstName = Console.ReadLine(); 139 | Console.Write("Eklemek istediğiniz müşterinin soyadını giriniz:"); 140 | string lastName = Console.ReadLine(); 141 | Console.Write("Eklemek istediğiniz müşterinin şifresini giriniz:"); 142 | string password = Console.ReadLine(); 143 | Console.Clear(); 144 | Console.WriteLine(userManager.Add(new User { Email = email, FirstName = firstName, LastName = lastName, Password = password }).Message); 145 | } 146 | 147 | private static void ListRentals(RentalManager rentalManager) 148 | { 149 | Console.WriteLine("ID | MARKA | MÜŞTERİ ADI | KİRALANMA TARİHİ | KİRADAN GERİ DÖNME TARİHİ \n--------------------------------------------------"); 150 | foreach (var rental in rentalManager.GetRentalDetails().Data) 151 | { 152 | Console.WriteLine($"{rental.Id.ToString().PadRight(5, ' ')}|{rental.BrandName.PadRight(10, ' ')}|{rental.CustomerName.PadRight(16, ' ')}|{rental.RentDate.ToString().PadRight(22, ' ')}|{rental.ReturnDate.ToString().PadRight(20, ' ')}"); 153 | } 154 | } 155 | 156 | private static void AddRental(RentalManager rentalManager,CarManager carManager,CustomerManager customerManager) 157 | { 158 | ListCars(carManager); 159 | Console.WriteLine("---------------------------------------------------------"); 160 | ListCustomers(customerManager); 161 | Console.Write("Araba numarasını giriniz:"); 162 | int carId = Convert.ToInt32(Console.ReadLine()); 163 | Console.Write("Müşteri numarasını giriniz:"); 164 | int customerId = Convert.ToInt32(Console.ReadLine()); 165 | DateTime rentDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); 166 | DateTime returnDate = Convert.ToDateTime(null); 167 | Console.Clear(); 168 | Console.WriteLine(rentalManager.Add(new Rental { CarId = carId, CustomerId = customerId, RentDate = rentDate, ReturnDate = returnDate }).Message); 169 | } 170 | 171 | private static void DeleteColor(ColorManager colorManager) 172 | { 173 | ListColors(colorManager); 174 | Console.Write("Silmek İstediğiniz Rengin Numarasını Seçiniz:"); 175 | int colorId = Convert.ToInt32(Console.ReadLine()); 176 | Console.Clear(); 177 | colorManager.Delete(new Color { ColorId = colorId }); 178 | } 179 | 180 | private static void ListColors(ColorManager colorManager) 181 | { 182 | foreach (var color in colorManager.GetAll().Data) 183 | { 184 | Console.WriteLine($"{color.ColorId}. {color.ColorName}"); 185 | } 186 | } 187 | 188 | private static void AddColor(ColorManager colorManager) 189 | { 190 | Console.Write("Rengin Adını Giriniz:"); 191 | string colorName = Console.ReadLine(); 192 | Console.Clear(); 193 | Console.WriteLine(colorManager.Add(new Color { ColorName = colorName }).Message); 194 | } 195 | 196 | private static void UpdateBrand(BrandManager brandManager) 197 | { 198 | ListBrands(brandManager); 199 | Console.WriteLine("------------------------------------------------------"); 200 | Console.Write("Listeden Güncellemek İstediğiniz Markanın Numarasını Giriniz:"); 201 | int brandId = Convert.ToInt32(Console.ReadLine()); 202 | Console.Clear(); 203 | Console.Write("Aracın Markasını Giriniz: "); 204 | string brandName = Console.ReadLine(); 205 | Console.Clear(); 206 | brandManager.Update(new Brand { BrandId = brandId, BrandName = brandName }); 207 | } 208 | 209 | private static void DeleteBrand(BrandManager brandManager) 210 | { 211 | ListBrands(brandManager); 212 | Console.Write("Silmek İstediğiniz Markanın Numarasını Seçiniz:"); 213 | int brandId = Convert.ToInt32(Console.ReadLine()); 214 | Console.Clear(); 215 | brandManager.Delete(new Brand { BrandId = brandId }); 216 | } 217 | 218 | private static void AddBrand(BrandManager brandManager) 219 | { 220 | Console.Write("Markanın Adını Giriniz:"); 221 | string brandName = Console.ReadLine(); 222 | Console.Clear(); 223 | brandManager.Add(new Brand { BrandName = brandName }); 224 | } 225 | 226 | private static void ListBrands(BrandManager brandManager) 227 | { 228 | foreach (var brand in brandManager.GetAll().Data) 229 | { 230 | Console.WriteLine($"{brand.BrandId}. {brand.BrandName}"); 231 | } 232 | } 233 | 234 | private static void UpdateCar(CarManager carManager) 235 | { 236 | ListCars(carManager); 237 | Console.WriteLine("------------------------------------------------------"); 238 | Console.Write("Listeden Güncellemek İstediğiniz Aracın Numarasını Giriniz:"); 239 | int id = Convert.ToInt32(Console.ReadLine()); 240 | Console.Clear(); 241 | Console.Write("Aracin BrandId'sini belirleyin: "); 242 | int BrandId = Convert.ToInt32(Console.ReadLine()); 243 | Console.Write("Aracin ColorId'sini belirleyin: "); 244 | int ColorId = Convert.ToInt32(Console.ReadLine()); 245 | Console.Write("Aracin ModelYear degerini belirleyin: "); 246 | int ModelYear = Convert.ToInt32(Console.ReadLine()); 247 | Console.Write("Aracin DailyPrice degerini belirleyin: "); 248 | decimal DailyPrice = Convert.ToDecimal(Console.ReadLine()); 249 | Console.Write("Arac Aciklamasini Yaziniz: "); 250 | string Description = Console.ReadLine(); 251 | Console.Clear(); 252 | carManager.Update(new Car { Id = id, BrandId = BrandId, ColorId = ColorId, ModelYear = ModelYear, DailyPrice = DailyPrice, Description = Description }); 253 | } 254 | 255 | private static void DeleteCar(CarManager carManager) 256 | { 257 | ListCars(carManager); 258 | Console.WriteLine("------------------------------------------------------"); 259 | Console.Write("Listeden Silmek İstediğiniz Aracın Numarasını Giriniz:"); 260 | int id = Convert.ToInt32(Console.ReadLine()); 261 | Console.Clear(); 262 | carManager.Delete(new Car { Id = id }); 263 | } 264 | 265 | private static void ListCars(CarManager carManager) 266 | { 267 | Console.WriteLine("ID | MARKA | RENK | AÇIKLAMA \n-------------------------------------------------------"); 268 | foreach (var car in carManager.GetCarDetails().Data) 269 | { 270 | Console.WriteLine($"{car.Id.ToString().PadRight(5,' ')}|{car.BrandName.PadRight(15,' ')}|{car.ColorName.PadRight(10,' ')}|{car.Description.PadRight(20,' ')}"); 271 | } 272 | } 273 | 274 | private static void AddCar(CarManager carManager) 275 | { 276 | Console.Write("Aracın BrandId'sini belirleyin: "); 277 | int BrandId = Convert.ToInt32(Console.ReadLine()); 278 | Console.Write("Aracın ColorId'sini belirleyin: "); 279 | int ColorId = Convert.ToInt32(Console.ReadLine()); 280 | Console.Write("Aracın ModelYear degerini belirleyin: "); 281 | int ModelYear = Convert.ToInt32(Console.ReadLine()); 282 | Console.Write("Aracın DailyPrice degerini belirleyin: "); 283 | decimal DailyPrice = Convert.ToDecimal(Console.ReadLine()); 284 | Console.Write("Arac Aciklamasini Yaziniz: "); 285 | string Description = Console.ReadLine(); 286 | Console.Clear(); 287 | carManager.Add(new Car { BrandId = BrandId, ColorId = ColorId, ModelYear = ModelYear, DailyPrice = DailyPrice, Description = Description }); 288 | } 289 | } 290 | } 291 | -------------------------------------------------------------------------------- /Core/Aspects/Autofac/Validation/ValidationAspect.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using Core.CrossCuttingConcerns.Validation; 3 | using Core.Utilities.Interceptors; 4 | using FluentValidation; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | 10 | namespace Core.Aspects.Autofac.Validation 11 | { 12 | public class ValidationAspect : MethodInterception 13 | { 14 | private Type _validatorType; 15 | public ValidationAspect(Type validatorType) 16 | { 17 | if (!typeof(IValidator).IsAssignableFrom(validatorType)) 18 | { 19 | throw new System.Exception("Bu bir doğrulama mesajı değil."); 20 | } 21 | 22 | _validatorType = validatorType; 23 | } 24 | protected override void OnBefore(IInvocation invocation) 25 | { 26 | var validator = (IValidator)Activator.CreateInstance(_validatorType); 27 | var entityType = _validatorType.BaseType.GetGenericArguments()[0]; 28 | var entities = invocation.Arguments.Where(t => t.GetType() == entityType); 29 | foreach (var entity in entities) 30 | { 31 | ValidationTool.Validate(validator, entity); 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Core/Core.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Core/CrossCuttingConcerns/Validation/ValidationTool.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.CrossCuttingConcerns.Validation 7 | { 8 | public static class ValidationTool 9 | { 10 | public static void Validate(IValidator validator,object entity) 11 | { 12 | var context = new ValidationContext(entity); 13 | var result = validator.Validate(context); 14 | if (!result.IsValid) 15 | { 16 | throw new ValidationException(result.Errors); 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Core/DataAccess/EntityFramework/EfEntityRepositoryBase.cs: -------------------------------------------------------------------------------- 1 | using DataAccess.Abstract; 2 | using Entities.Abstract; 3 | using Microsoft.EntityFrameworkCore; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Linq.Expressions; 8 | using System.Text; 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 | using (TContext context = new TContext()) 19 | { 20 | var addedEntity = context.Entry(entity); 21 | addedEntity.State = EntityState.Added; 22 | context.SaveChanges(); 23 | } 24 | } 25 | 26 | public void Delete(TEntity entity) 27 | { 28 | using (TContext context = new TContext()) 29 | { 30 | var deletedEntity = context.Entry(entity); 31 | deletedEntity.State = EntityState.Deleted; 32 | context.SaveChanges(); 33 | } 34 | } 35 | 36 | public TEntity Get(Expression> filter) 37 | { 38 | using (TContext context = new TContext()) 39 | { 40 | return context.Set().SingleOrDefault(filter); 41 | } 42 | } 43 | 44 | public List GetAll(Expression> filter = null) 45 | { 46 | using (TContext context = new TContext()) 47 | { 48 | return filter == null ? context.Set().ToList() : context.Set().Where(filter).ToList(); 49 | } 50 | } 51 | 52 | public void Update(TEntity entity) 53 | { 54 | using (TContext context = new TContext()) 55 | { 56 | var updatedEntity = context.Entry(entity); 57 | updatedEntity.State = EntityState.Modified; 58 | context.SaveChanges(); 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Core/DataAccess/IEntityRepository.cs: -------------------------------------------------------------------------------- 1 | using Entities.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq.Expressions; 5 | using System.Text; 6 | 7 | namespace DataAccess.Abstract 8 | { 9 | public interface IEntityRepository where T:class,IEntity,new() 10 | { 11 | List GetAll(Expression> filter = null); 12 | T Get(Expression> filter); 13 | void Add(T entity); 14 | void Update(T entity); 15 | void Delete(T entity); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Core/Entities/IDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Entities 6 | { 7 | public interface IDto 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Core/Entities/IEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Entities.Abstract 6 | { 7 | public interface IEntity 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Core/Utilities/Interceptors/AspectInterceptorSelector.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using System; 3 | using System.Linq; 4 | using System.Reflection; 5 | 6 | namespace Core.Utilities.Interceptors 7 | { 8 | public class AspectInterceptorSelector : IInterceptorSelector 9 | { 10 | public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors) 11 | { 12 | var classAttributes = type.GetCustomAttributes(true).ToList(); 13 | var methodAttributes = type.GetMethod(method.Name).GetCustomAttributes(true); 14 | classAttributes.AddRange(methodAttributes); 15 | 16 | return classAttributes.OrderBy(x => x.Priority).ToArray(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Core/Utilities/Interceptors/MethodInterception.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Utilities.Interceptors 7 | { 8 | public abstract class MethodInterception : MethodInterceptionBaseAttribute 9 | { 10 | protected virtual void OnBefore(IInvocation invocation) { } 11 | protected virtual void OnAfter(IInvocation invocation) { } 12 | protected virtual void OnException(IInvocation invocation, System.Exception e) { } 13 | protected virtual void OnSuccess(IInvocation invocation) { } 14 | public override void Intercept(IInvocation invocation) 15 | { 16 | var isSuccess = true; 17 | OnBefore(invocation); 18 | try 19 | { 20 | invocation.Proceed(); 21 | } 22 | catch (Exception e) 23 | { 24 | isSuccess = false; 25 | OnException(invocation, e); 26 | throw; 27 | } 28 | finally 29 | { 30 | if (isSuccess) 31 | { 32 | OnSuccess(invocation); 33 | } 34 | } 35 | OnAfter(invocation); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Core/Utilities/Interceptors/MethodInterceptionBaseAttribute.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Utilities.Interceptors 7 | { 8 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] 9 | public abstract class MethodInterceptionBaseAttribute : Attribute, IInterceptor 10 | { 11 | public int Priority { get; set; } 12 | 13 | public virtual void Intercept(IInvocation invocation) 14 | { 15 | 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /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 | } 27 | -------------------------------------------------------------------------------- /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 | public interface IResult 8 | { 9 | bool Success { get; } 10 | string Message { get; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /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 | public Result(bool success, string message):this(success) 10 | { 11 | Message = message; 12 | } 13 | public Result(bool success) 14 | { 15 | Success = success; 16 | } 17 | 18 | public bool Success { get; } 19 | 20 | public string Message { get; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /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/IBrandDal.cs: -------------------------------------------------------------------------------- 1 | using Entities.Concrete; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace DataAccess.Abstract 7 | { 8 | public interface IBrandDal:IEntityRepository 9 | { 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /DataAccess/Abstract/ICarDal.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 DataAccess.Abstract 9 | { 10 | public interface ICarDal:IEntityRepository 11 | { 12 | IDataResult> GetCarDetails(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /DataAccess/Abstract/IColorDal.cs: -------------------------------------------------------------------------------- 1 | using Entities.Concrete; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace DataAccess.Abstract 7 | { 8 | public interface IColorDal:IEntityRepository 9 | { 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /DataAccess/Abstract/ICustomerDal.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results; 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/IRentalDal.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 DataAccess.Abstract 9 | { 10 | public interface IRentalDal:IEntityRepository 11 | { 12 | IDataResult> GetRentalDetails(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /DataAccess/Abstract/IUserDal.cs: -------------------------------------------------------------------------------- 1 | using Entities.Concrete; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace DataAccess.Abstract 7 | { 8 | public interface IUserDal:IEntityRepository 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfBrandDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using DataAccess.Abstract; 3 | using Entities.Concrete; 4 | using Microsoft.EntityFrameworkCore; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Linq.Expressions; 9 | using System.Text; 10 | 11 | namespace DataAccess.Concrete.EntityFramework 12 | { 13 | public class EfBrandDal : EfEntityRepositoryBase,IBrandDal 14 | { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfCarDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using Core.Utilities.Results; 3 | using DataAccess.Abstract; 4 | using Entities.Concrete; 5 | using Entities.DTOs; 6 | using Microsoft.EntityFrameworkCore; 7 | using System; 8 | using System.Collections.Generic; 9 | using System.Linq; 10 | using System.Linq.Expressions; 11 | using System.Text; 12 | 13 | namespace DataAccess.Concrete.EntityFramework 14 | { 15 | public class EfCarDal : EfEntityRepositoryBase, ICarDal 16 | { 17 | public IDataResult> GetCarDetails() 18 | { 19 | using (ReCapDatabaseContext context=new ReCapDatabaseContext()) 20 | { 21 | var result = from car in context.Cars 22 | join color in context.Colors 23 | on car.ColorId equals color.ColorId 24 | join brand in context.Brands 25 | on car.BrandId equals brand.BrandId 26 | select new CarDetailDto { Id = car.Id, BrandId = brand.BrandId, BrandName = brand.BrandName, ColorId = color.ColorId, ColorName = color.ColorName, DailyPrice = car.DailyPrice, Description = car.Description, ModelYear = car.ModelYear }; 27 | 28 | return new SuccessDataResult>(result.ToList()); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfColorDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using DataAccess.Abstract; 3 | using Entities.Concrete; 4 | using Microsoft.EntityFrameworkCore; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Linq.Expressions; 9 | using System.Text; 10 | 11 | namespace DataAccess.Concrete.EntityFramework 12 | { 13 | public class EfColorDal : EfEntityRepositoryBase,IColorDal 14 | { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfCustomerDal.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 EfCustomerDal:EfEntityRepositoryBase,ICustomerDal 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfRentalDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using Core.Utilities.Results; 3 | using DataAccess.Abstract; 4 | using Entities.Concrete; 5 | using Entities.DTOs; 6 | using Microsoft.EntityFrameworkCore; 7 | using System; 8 | using System.Collections.Generic; 9 | using System.Linq; 10 | using System.Linq.Expressions; 11 | using System.Text; 12 | 13 | namespace DataAccess.Concrete.EntityFramework 14 | { 15 | public class EfRentalDal : EfEntityRepositoryBase, IRentalDal 16 | { 17 | public IDataResult> GetRentalDetails() 18 | { 19 | using (ReCapDatabaseContext context=new ReCapDatabaseContext()) 20 | { 21 | var result = from car in context.Cars 22 | join rental in context.Rentals 23 | on car.Id equals rental.CarId 24 | join brand in context.Brands 25 | on car.BrandId equals brand.BrandId 26 | join customer in context.Customers 27 | on rental.CustomerId equals customer.Id 28 | join user in context.Users 29 | on customer.UserId equals user.Id 30 | select new RentalDetailDto 31 | { 32 | Id = rental.Id, 33 | BrandName = brand.BrandName, 34 | CustomerName = user.FirstName + " " + user.LastName, 35 | RentDate = rental.RentDate, 36 | ReturnDate = rental.ReturnDate 37 | 38 | }; 39 | 40 | return new SuccessDataResult>(result.ToList()); 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfUserDal.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 EfUserDal: EfEntityRepositoryBase, IUserDal 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/ReCapDatabaseContext.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 | public class ReCapDatabaseContext:DbContext 10 | { 11 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 12 | { 13 | optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=ReCapDatabase;Trusted_Connection=true"); 14 | } 15 | 16 | public DbSet Cars { get; set; } 17 | public DbSet Brands { get; set; } 18 | public DbSet Colors { get; set; } 19 | public DbSet Users { get; set; } 20 | public DbSet Customers { get; set; } 21 | public DbSet Rentals { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /DataAccess/DataAccess.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Entities/Concrete/Brand.cs: -------------------------------------------------------------------------------- 1 | using Entities.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class Brand:IEntity 9 | { 10 | public int BrandId { get; set; } 11 | public string BrandName { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Entities/Concrete/Car.cs: -------------------------------------------------------------------------------- 1 | using Entities.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class Car:IEntity 9 | { 10 | public int Id { get; set; } 11 | public int BrandId { get; set; } 12 | public int ColorId { get; set; } 13 | public int ModelYear { get; set; } 14 | public decimal DailyPrice { get; set; } 15 | public string Description { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Entities/Concrete/Color.cs: -------------------------------------------------------------------------------- 1 | using Entities.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class Color:IEntity 9 | { 10 | public int ColorId { get; set; } 11 | public string ColorName { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Entities/Concrete/Customer.cs: -------------------------------------------------------------------------------- 1 | using Entities.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class Customer:IEntity 9 | { 10 | public int Id { get; set; } 11 | public int UserId { get; set; } 12 | public string CompanyName { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Entities/Concrete/Rental.cs: -------------------------------------------------------------------------------- 1 | using Entities.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class Rental:IEntity 9 | { 10 | public int Id { get; set; } 11 | public int CarId { get; set; } 12 | public int CustomerId { get; set; } 13 | public DateTime RentDate { get; set; } 14 | public DateTime ReturnDate { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Entities/Concrete/User.cs: -------------------------------------------------------------------------------- 1 | using Entities.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class User:IEntity 9 | { 10 | public int Id { get; set; } 11 | public string FirstName { get; set; } 12 | public string LastName { get; set; } 13 | public string Email { get; set; } 14 | public string Password { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Entities/DTOs/CarDetailDto.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 CarDetailDto:IDto 9 | { 10 | public int Id { get; set; } 11 | public int ColorId { get; set; } 12 | public int BrandId { get; set; } 13 | public string ColorName { get; set; } 14 | public string BrandName { get; set; } 15 | public int ModelYear { get; set; } 16 | public decimal DailyPrice { get; set; } 17 | public string Description { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Entities/DTOs/RentalDetailDto.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 RentalDetailDto:IDto 9 | { 10 | public int Id { get; set; } 11 | public string BrandName { get; set; } 12 | public string CustomerName { get; set; } 13 | public DateTime RentDate { get; set; } 14 | public DateTime ReturnDate { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Entities/Entities.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /ReCapProject.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30907.101 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Business", "Business\Business.csproj", "{FEA60217-D081-49AB-BB4C-0514B4053AF9}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataAccess", "DataAccess\DataAccess.csproj", "{E319A591-BBE5-4666-AF5B-25A7CA617083}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Entities", "Entities\Entities.csproj", "{37D39246-9E8B-4129-87E6-70A353F8BF5E}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleUI", "ConsoleUI\ConsoleUI.csproj", "{541C4719-BFEA-47BD-AB0A-0500D3ADA1E7}" 13 | EndProject 14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core", "Core\Core.csproj", "{303BE3E0-827D-4978-8108-E10B70570749}" 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAPI", "WebAPI\WebAPI.csproj", "{E2EC0B7A-DEB5-4810-83FB-1B327B3EDF45}" 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 | {FEA60217-D081-49AB-BB4C-0514B4053AF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {FEA60217-D081-49AB-BB4C-0514B4053AF9}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {FEA60217-D081-49AB-BB4C-0514B4053AF9}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {FEA60217-D081-49AB-BB4C-0514B4053AF9}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {E319A591-BBE5-4666-AF5B-25A7CA617083}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {E319A591-BBE5-4666-AF5B-25A7CA617083}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {E319A591-BBE5-4666-AF5B-25A7CA617083}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {E319A591-BBE5-4666-AF5B-25A7CA617083}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {37D39246-9E8B-4129-87E6-70A353F8BF5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {37D39246-9E8B-4129-87E6-70A353F8BF5E}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {37D39246-9E8B-4129-87E6-70A353F8BF5E}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {37D39246-9E8B-4129-87E6-70A353F8BF5E}.Release|Any CPU.Build.0 = Release|Any CPU 36 | {541C4719-BFEA-47BD-AB0A-0500D3ADA1E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 37 | {541C4719-BFEA-47BD-AB0A-0500D3ADA1E7}.Debug|Any CPU.Build.0 = Debug|Any CPU 38 | {541C4719-BFEA-47BD-AB0A-0500D3ADA1E7}.Release|Any CPU.ActiveCfg = Release|Any CPU 39 | {541C4719-BFEA-47BD-AB0A-0500D3ADA1E7}.Release|Any CPU.Build.0 = Release|Any CPU 40 | {303BE3E0-827D-4978-8108-E10B70570749}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 41 | {303BE3E0-827D-4978-8108-E10B70570749}.Debug|Any CPU.Build.0 = Debug|Any CPU 42 | {303BE3E0-827D-4978-8108-E10B70570749}.Release|Any CPU.ActiveCfg = Release|Any CPU 43 | {303BE3E0-827D-4978-8108-E10B70570749}.Release|Any CPU.Build.0 = Release|Any CPU 44 | {E2EC0B7A-DEB5-4810-83FB-1B327B3EDF45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 45 | {E2EC0B7A-DEB5-4810-83FB-1B327B3EDF45}.Debug|Any CPU.Build.0 = Debug|Any CPU 46 | {E2EC0B7A-DEB5-4810-83FB-1B327B3EDF45}.Release|Any CPU.ActiveCfg = Release|Any CPU 47 | {E2EC0B7A-DEB5-4810-83FB-1B327B3EDF45}.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 = {9134A082-9716-435A-A66B-DC9C48941294} 54 | EndGlobalSection 55 | EndGlobal 56 | -------------------------------------------------------------------------------- /WebAPI/Controllers/BrandsController.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Entities.Concrete; 3 | using Microsoft.AspNetCore.Http; 4 | using Microsoft.AspNetCore.Mvc; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace WebAPI.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class BrandsController : ControllerBase 15 | { 16 | IBrandService _brandService; 17 | public BrandsController(IBrandService brandService) 18 | { 19 | _brandService = brandService; 20 | } 21 | [HttpGet("getbrands")] 22 | public IActionResult GetBrands() 23 | { 24 | var result = _brandService.GetAll(); 25 | if (result.Success) 26 | { 27 | return Ok(result.Data); 28 | } 29 | 30 | return BadRequest(result.Message); 31 | } 32 | [HttpPost("addbrand")] 33 | public IActionResult Add(Brand brand) 34 | { 35 | var result = _brandService.Add(brand); 36 | if (result.Success) 37 | { 38 | return Ok(result); 39 | } 40 | 41 | return BadRequest(result.Message); 42 | } 43 | [HttpPost("deletebrand")] 44 | public IActionResult Delete(Brand brand) 45 | { 46 | var result = _brandService.Delete(brand); 47 | if (result.Success) 48 | { 49 | return Ok(result); 50 | } 51 | 52 | return BadRequest(result.Message); 53 | } 54 | [HttpPost("updatebrand")] 55 | public IActionResult Update(Brand brand) 56 | { 57 | var result = _brandService.Update(brand); 58 | if (result.Success) 59 | { 60 | return Ok(result); 61 | } 62 | 63 | return BadRequest(result.Message); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /WebAPI/Controllers/CarsController.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Entities.Concrete; 3 | using Microsoft.AspNetCore.Http; 4 | using Microsoft.AspNetCore.Mvc; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace WebAPI.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class CarsController : ControllerBase 15 | { 16 | ICarService _carService; 17 | public CarsController(ICarService carService) 18 | { 19 | _carService = carService; 20 | } 21 | [HttpGet("getcarsdetails")] 22 | public IActionResult GetCarsDetail() 23 | { 24 | var result = _carService.GetCarDetails(); 25 | if (result.Success) 26 | { 27 | return Ok(result.Data); 28 | } 29 | 30 | return BadRequest(result.Message); 31 | } 32 | [HttpPost("addcar")] 33 | public IActionResult Add(Car car) 34 | { 35 | var result = _carService.Add(car); 36 | if (result.Success) 37 | { 38 | return Ok(result); 39 | } 40 | 41 | return BadRequest(result.Message); 42 | } 43 | [HttpPost("deletecar")] 44 | public IActionResult Delete(Car car) 45 | { 46 | var result = _carService.Delete(car); 47 | if (result.Success) 48 | { 49 | return Ok(result); 50 | } 51 | 52 | return BadRequest(result.Message); 53 | } 54 | [HttpPost("updatecar")] 55 | public IActionResult Update(Car car) 56 | { 57 | var result = _carService.Update(car); 58 | if (result.Success) 59 | { 60 | return Ok(result); 61 | } 62 | 63 | return BadRequest(result.Message); 64 | } 65 | [HttpGet("getcars")] 66 | public IActionResult GetCars() 67 | { 68 | var result = _carService.GetAll(); 69 | if (result.Success) 70 | { 71 | return Ok(result.Data); 72 | } 73 | return BadRequest(result.Message); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /WebAPI/Controllers/ColorsController.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Entities.Concrete; 3 | using Microsoft.AspNetCore.Http; 4 | using Microsoft.AspNetCore.Mvc; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace WebAPI.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class ColorsController : ControllerBase 15 | { 16 | IColorService _colorService; 17 | public ColorsController(IColorService colorService) 18 | { 19 | _colorService = colorService; 20 | } 21 | [HttpGet("getcolors")] 22 | public IActionResult GetColors() 23 | { 24 | var result = _colorService.GetAll(); 25 | if (result.Success) 26 | { 27 | return Ok(result.Data); 28 | } 29 | 30 | return BadRequest(result.Message); 31 | } 32 | [HttpPost("addcolor")] 33 | public IActionResult Add(Color color) 34 | { 35 | var result = _colorService.Add(color); 36 | if (result.Success) 37 | { 38 | return Ok(result); 39 | } 40 | 41 | return BadRequest(result.Message); 42 | } 43 | [HttpPost("deletecolor")] 44 | public IActionResult Delete(Color color) 45 | { 46 | var result = _colorService.Delete(color); 47 | if (result.Success) 48 | { 49 | return Ok(result); 50 | } 51 | 52 | return BadRequest(result.Message); 53 | } 54 | [HttpPost("updatecolor")] 55 | public IActionResult Update(Color color) 56 | { 57 | var result = _colorService.Update(color); 58 | if (result.Success) 59 | { 60 | return Ok(result); 61 | } 62 | 63 | return BadRequest(result.Message); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /WebAPI/Controllers/CustomersController.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Entities.Concrete; 3 | using Microsoft.AspNetCore.Http; 4 | using Microsoft.AspNetCore.Mvc; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace WebAPI.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class CustomersController : ControllerBase 15 | { 16 | ICustomerService _customerService; 17 | 18 | public CustomersController(ICustomerService customerService) 19 | { 20 | _customerService = customerService; 21 | } 22 | [HttpGet("getcustomers")] 23 | public IActionResult GetCustomers() 24 | { 25 | var result = _customerService.GetAll(); 26 | if (result.Success) 27 | { 28 | return Ok(result.Data); 29 | } 30 | 31 | return BadRequest(result.Message); 32 | } 33 | [HttpPost("addcustomer")] 34 | public IActionResult Add(Customer customer) 35 | { 36 | var result = _customerService.Add(customer); 37 | if (result.Success) 38 | { 39 | return Ok(result); 40 | } 41 | return BadRequest(result.Message); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /WebAPI/Controllers/RentalsController.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Entities.Concrete; 3 | using Microsoft.AspNetCore.Http; 4 | using Microsoft.AspNetCore.Mvc; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace WebAPI.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class RentalsController : ControllerBase 15 | { 16 | IRentalService _rentalService; 17 | public RentalsController(IRentalService rentalService) 18 | { 19 | _rentalService = rentalService; 20 | } 21 | [HttpGet("getrentalsdetails")] 22 | public IActionResult GetRentalDetails() 23 | { 24 | var result = _rentalService.GetRentalDetails(); 25 | if (result.Success) 26 | { 27 | return Ok(result.Data); 28 | } 29 | 30 | return BadRequest(result.Message); 31 | } 32 | [HttpGet("getrentals")] 33 | public IActionResult GetRentals() 34 | { 35 | var result = _rentalService.GetAll(); 36 | if (result.Success) 37 | { 38 | return Ok(result.Data); 39 | } 40 | 41 | return BadRequest(result.Message); 42 | } 43 | [HttpPost("addrental")] 44 | public IActionResult Add(Rental rental) 45 | { 46 | var result = _rentalService.Add(rental); 47 | if (result.Success) 48 | { 49 | return Ok(result); 50 | } 51 | 52 | return BadRequest(result.Message); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /WebAPI/Controllers/UsersController.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Entities.Concrete; 3 | using Microsoft.AspNetCore.Http; 4 | using Microsoft.AspNetCore.Mvc; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace WebAPI.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class UsersController : ControllerBase 15 | { 16 | IUserService _userService; 17 | 18 | public UsersController(IUserService userService) 19 | { 20 | _userService = userService; 21 | } 22 | [HttpGet("getusers")] 23 | public IActionResult GetUsers() 24 | { 25 | var result = _userService.GetAll(); 26 | if (result.Success) 27 | { 28 | return Ok(result.Data); 29 | } 30 | 31 | return BadRequest(result.Message); 32 | } 33 | [HttpPost("adduser")] 34 | public IActionResult Add(User user) 35 | { 36 | var result = _userService.Add(user); 37 | if (result.Success) 38 | { 39 | return Ok(result); 40 | } 41 | 42 | return BadRequest(result.Message); 43 | } 44 | [HttpPost("deleteuser")] 45 | public IActionResult Delete(User user) 46 | { 47 | var result = _userService.Delete(user); 48 | if (result.Success) 49 | { 50 | return Ok(result); 51 | } 52 | 53 | return BadRequest(result.Message); 54 | } 55 | [HttpPost("updateuser")] 56 | public IActionResult Update(User user) 57 | { 58 | var result = _userService.Update(user); 59 | if (result.Success) 60 | { 61 | return Ok(result); 62 | } 63 | 64 | return BadRequest(result.Message); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /WebAPI/Program.cs: -------------------------------------------------------------------------------- 1 | using Autofac; 2 | using Autofac.Extensions.DependencyInjection; 3 | using Business.DependencyResolvers.Autofac; 4 | using Microsoft.AspNetCore.Hosting; 5 | using Microsoft.Extensions.Configuration; 6 | using Microsoft.Extensions.Hosting; 7 | using Microsoft.Extensions.Logging; 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Linq; 11 | using System.Threading.Tasks; 12 | 13 | namespace WebAPI 14 | { 15 | public class Program 16 | { 17 | public static void Main(string[] args) 18 | { 19 | CreateHostBuilder(args).Build().Run(); 20 | } 21 | 22 | public static IHostBuilder CreateHostBuilder(string[] args) => 23 | Host.CreateDefaultBuilder(args) 24 | .UseServiceProviderFactory(new AutofacServiceProviderFactory()) 25 | .ConfigureContainer(builder => 26 | { 27 | builder.RegisterModule(new AutofacBusinessModule()); 28 | }) 29 | .ConfigureWebHostDefaults(webBuilder => 30 | { 31 | webBuilder.UseStartup(); 32 | }); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /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:51965", 8 | "sslPort": 44300 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "weatherforecast", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "WebAPI": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "weatherforecast", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /WebAPI/Startup.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Concrete; 3 | using DataAccess.Abstract; 4 | using DataAccess.Concrete.EntityFramework; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Hosting; 7 | using Microsoft.AspNetCore.HttpsPolicy; 8 | using Microsoft.AspNetCore.Mvc; 9 | using Microsoft.Extensions.Configuration; 10 | using Microsoft.Extensions.DependencyInjection; 11 | using Microsoft.Extensions.Hosting; 12 | using Microsoft.Extensions.Logging; 13 | using System; 14 | using System.Collections.Generic; 15 | using System.Linq; 16 | using System.Threading.Tasks; 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 | { 32 | services.AddControllers(); 33 | //services.AddSingleton(); 34 | //services.AddSingleton(); 35 | //services.AddSingleton(); 36 | //services.AddSingleton(); 37 | //services.AddSingleton(); 38 | //services.AddSingleton(); 39 | 40 | 41 | 42 | //services.AddSingleton(); 43 | //services.AddSingleton(); 44 | //services.AddSingleton(); 45 | //services.AddSingleton(); 46 | //services.AddSingleton(); 47 | //services.AddSingleton(); 48 | } 49 | 50 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 51 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 52 | { 53 | if (env.IsDevelopment()) 54 | { 55 | app.UseDeveloperExceptionPage(); 56 | } 57 | 58 | app.UseHttpsRedirection(); 59 | 60 | app.UseRouting(); 61 | 62 | app.UseAuthorization(); 63 | 64 | app.UseEndpoints(endpoints => 65 | { 66 | endpoints.MapControllers(); 67 | }); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /WebAPI/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace WebAPI 4 | { 5 | public class WeatherForecast 6 | { 7 | public DateTime Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | 13 | public string Summary { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /WebAPI/WebAPI.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /WebAPI/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /WebAPI/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | --------------------------------------------------------------------------------