├── .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 │ ├── CustomerValidator.cs │ ├── RentalValidator.cs │ └── UserValidator.cs ├── ConsoleApp1 ├── ConsoleUI2.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 │ │ ├── DailyCarRentalContext.cs │ │ ├── EFBrandDal.cs │ │ ├── EFCarDal.cs │ │ ├── EFColorDal.cs │ │ ├── EFCustomerDal.cs │ │ ├── EFRentalDal.cs │ │ └── EFUserDal.cs │ └── InMemory │ │ └── InMemoryCarDal.cs └── DataAccess.csproj ├── Entities ├── Concrete │ ├── Brand.cs │ ├── Car.cs │ ├── Color.cs │ ├── Customer.cs │ ├── Rental.cs │ └── User.cs ├── DTOs │ ├── CarDetailDto.cs │ ├── CustomerDetailDto.cs │ └── RentalDetailDto.cs └── Entities.csproj ├── ReCapProject.sln └── WebAPI ├── Controllers ├── BrandsController.cs ├── CarsController.cs ├── ColorsController.cs ├── CustomersController.cs ├── RentalsController.cs ├── UsersController.cs └── WeatherForecastController.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 | 13 | IResult Delete(Brand brand); 14 | 15 | IDataResult> GetAll(); 16 | IDataResult> GetAllByBrandId(int brandId); 17 | 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /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 | IResult Add(Car car); 13 | IResult Update(Car car); 14 | IResult Delete(Car car); 15 | IDataResult > GetAll(); 16 | IDataResult > GetCarDetails(); 17 | IDataResult< Car> GetById(int carId); 18 | 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Business/Abstract/IColorService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results; 2 | using Entities.Concrete; 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | using System.Text; 7 | 8 | namespace Business.Abstract 9 | { 10 | public interface IColorService 11 | { 12 | IResult Add(Color color); 13 | IResult Delete(Color color); 14 | IDataResult> GetAll(); 15 | IDataResult> GetAllByColorId(int colorId); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Business/Abstract/ICustomerService.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 ICustomerService 11 | { 12 | IResult Add(Customer customer); 13 | IResult Delete(Customer customer); 14 | IResult Update(Customer customer); 15 | IDataResult >GetAll(); 16 | IDataResult > GetCustomerDetails(); 17 | IDataResult< Customer> GetById(int customerId); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /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 | 13 | IResult Add(Rental rental); 14 | IResult Delete(Rental rental); 15 | IResult Update(Rental rental); 16 | IDataResult< List> GetAll(); 17 | IDataResult< List> GetRentalDetails(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /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 | 12 | IResult Add(User user); 13 | IResult Delete(User user); 14 | IResult Update(User user); 15 | IDataResult> GetAll(); 16 | IDataResult GetById(int userId); 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /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.ValidationRules.FluentValidation; 3 | using Core.Aspects.Autofac.Validation; 4 | using Core.CrossCuttingConcerns.Validation; 5 | using Core.Utilities.Results; 6 | using DataAccess.Abstract; 7 | using Entities.Concrete; 8 | using FluentValidation; 9 | using System; 10 | using System.Collections.Generic; 11 | using System.Text; 12 | 13 | namespace Business.Concrete 14 | { 15 | public class BrandManager : IBrandService 16 | { 17 | IBrandDal _brandDal; 18 | 19 | public BrandManager(IBrandDal brandDal) 20 | { 21 | _brandDal = brandDal; 22 | } 23 | 24 | [ValidationAspect(typeof(BrandValidator))] 25 | public IResult Add(Brand brand) 26 | { 27 | 28 | 29 | _brandDal.Add(brand); 30 | return new SuccessResult("Brand Added"); 31 | } 32 | 33 | public IResult Delete(Brand brand) 34 | { 35 | _brandDal.Delete(brand); 36 | return new SuccessResult("Brand Deleted"); 37 | } 38 | 39 | public List GetAll() 40 | { 41 | return _brandDal.GetAll(); 42 | } 43 | 44 | public IDataResult> GetAllByBrandId(int brandId) 45 | { 46 | return new SuccessDataResult>(_brandDal.GetAll(b => b.BrandId == brandId), "Brands listed"); 47 | } 48 | 49 | public Brand GetById(int brandId) 50 | { 51 | return _brandDal.Get(b => b.BrandId == brandId); 52 | } 53 | 54 | IDataResult> IBrandService.GetAll() 55 | { 56 | return new SuccessDataResult>(_brandDal.GetAll()); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /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.CrossCuttingConcerns.Validation; 6 | using Core.Utilities.Results; 7 | using DataAccess.Abstract; 8 | using Entities.Concrete; 9 | using Entities.DTOs; 10 | using System; 11 | using System.Collections.Generic; 12 | using System.Text; 13 | 14 | namespace Business.Concrete 15 | { 16 | public class CarManager : ICarService 17 | { 18 | ICarDal _carDal; 19 | 20 | public CarManager(ICarDal carDal) 21 | { 22 | _carDal = carDal; 23 | } 24 | 25 | [ValidationAspect(typeof(CarValidator))] 26 | public IResult Add(Car car) 27 | { 28 | 29 | _carDal.Add(car); 30 | return new SuccessResult( Messages.CarAdded); 31 | } 32 | 33 | public IResult Delete(Car car) 34 | { 35 | _carDal.Delete(car); 36 | return new SuccessResult(Messages.CarDeleted); 37 | } 38 | 39 | public IDataResult> GetAll() 40 | { 41 | if (DateTime.Now.Hour==22) 42 | { 43 | return new ErrorDataResult>(Messages.MaintenanceTime); 44 | } 45 | return new SuccessDataResult > (_carDal.GetAll(),Messages.CarsListed); 46 | } 47 | 48 | public IDataResult< Car> GetById(int carId) 49 | { 50 | return new SuccessDataResult (_carDal.Get(c => c.Id == carId)); 51 | } 52 | 53 | public IDataResult> GetCarDetails() 54 | { 55 | return new SuccessDataResult>( _carDal.GetCarDetails()); 56 | } 57 | 58 | 59 | 60 | 61 | public IResult Update(Car car) 62 | { 63 | _carDal.Update(car); 64 | return new SuccessResult(Messages.CarUpdated); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Business/Concrete/ColorManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Core.Utilities.Results; 3 | using DataAccess.Abstract; 4 | using Entities.Concrete; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Text; 8 | 9 | namespace Business.Concrete 10 | { 11 | public class ColorManager : IColorService 12 | { 13 | IColorDal _colorDal; 14 | 15 | public ColorManager(IColorDal colorDal) 16 | { 17 | _colorDal = colorDal; 18 | } 19 | 20 | public IResult Add(Color color) 21 | { 22 | 23 | _colorDal.Add(color); 24 | return new SuccessResult("color added"); 25 | } 26 | 27 | public IResult Delete(Color color) 28 | { 29 | _colorDal.Delete(color); 30 | return new SuccessResult("color Deleted"); 31 | } 32 | 33 | 34 | 35 | public IDataResult> GetAllByColorId(int colorId) 36 | { 37 | return new SuccessDataResult>(_colorDal.GetAll(x => x.ColorId == colorId), "Colors listed"); 38 | } 39 | 40 | 41 | IDataResult> IColorService.GetAll() 42 | { 43 | return new SuccessDataResult>(_colorDal.GetAll()); 44 | } 45 | 46 | public IEnumerable GetAll() 47 | { 48 | throw new NotImplementedException(); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Business/Concrete/CustomerManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Constants; 3 | using Business.ValidationRules.FluentValidation; 4 | using Core.Aspects.Autofac.Validation; 5 | using Core.CrossCuttingConcerns.Validation; 6 | using Core.Utilities.Results; 7 | using DataAccess.Abstract; 8 | using Entities.Concrete; 9 | using Entities.DTOs; 10 | using System; 11 | using System.Collections.Generic; 12 | using System.Text; 13 | 14 | namespace Business.Concrete 15 | { 16 | public class CustomerManager : ICustomerService 17 | { 18 | ICustomerDal _customerDal; 19 | public CustomerManager(ICustomerDal customerDal) 20 | { 21 | _customerDal = customerDal; 22 | } 23 | [ValidationAspect(typeof(CustomerValidator))] 24 | public IResult Add(Customer customer) 25 | { 26 | 27 | _customerDal.Add(customer); 28 | return new SuccessResult(Messages.CustomerAdded); 29 | } 30 | 31 | public IResult Delete(Customer customer) 32 | { 33 | _customerDal.Delete(customer); 34 | return new SuccessResult(Messages.CustomerDeleted); 35 | } 36 | 37 | public IDataResult > GetAll() 38 | { 39 | return new SuccessDataResult>(_customerDal.GetAll(), Messages.CustomerrsListed); 40 | } 41 | 42 | public IDataResult GetById(int customerId) 43 | { 44 | return new SuccessDataResult(_customerDal.Get(cs => cs.CustomerId == customerId)); 45 | } 46 | 47 | public IDataResult> GetCustomerDetails() 48 | { 49 | return new SuccessDataResult>(_customerDal.GetCustomerDetails()); 50 | } 51 | 52 | public IResult Update(Customer customer) 53 | { 54 | _customerDal.Update(customer); 55 | return new SuccessResult(Messages.CustomerUpdated); 56 | } 57 | 58 | 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /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.CrossCuttingConcerns.Validation; 6 | using Core.Utilities.Results; 7 | using DataAccess.Abstract; 8 | using Entities.Concrete; 9 | using Entities.DTOs; 10 | using System; 11 | using System.Collections.Generic; 12 | using System.Text; 13 | 14 | namespace Business.Concrete 15 | { 16 | public class RentalManager : IRentalService 17 | { 18 | IRentalDal _rentalDal; 19 | public RentalManager(IRentalDal rentalDal) 20 | { 21 | _rentalDal = rentalDal; 22 | } 23 | 24 | 25 | [ValidationAspect(typeof(RentalValidator))] 26 | public IResult Add(Rental rental) 27 | { 28 | 29 | _rentalDal.Add(rental); 30 | return new SuccessResult(Messages.RentalAdded); 31 | } 32 | 33 | public IResult Delete(Rental rental) 34 | { 35 | _rentalDal.Delete(rental); 36 | return new SuccessResult(Messages.RentalDeleted); 37 | } 38 | 39 | public IDataResult> GetAll() 40 | { 41 | return new SuccessDataResult>(_rentalDal.GetAll(), Messages.RentalsListed); 42 | } 43 | 44 | public IDataResult> GetRentalDetails() 45 | { 46 | return new SuccessDataResult>(_rentalDal.GetRentalDetails()); 47 | } 48 | 49 | public IResult Update(Rental rental) 50 | { 51 | _rentalDal.Update(rental); 52 | return new SuccessResult(Messages.RentalUpdated); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /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.CrossCuttingConcerns.Validation; 6 | using Core.Utilities.Results; 7 | using DataAccess.Abstract; 8 | using Entities.Concrete; 9 | using System; 10 | using System.Collections.Generic; 11 | using System.Text; 12 | 13 | namespace Business.Concrete 14 | { 15 | public class UserManager : IUserService 16 | { 17 | IUserDal _userDal; 18 | public UserManager(IUserDal userDal) 19 | { 20 | _userDal = userDal; 21 | } 22 | 23 | [ValidationAspect(typeof(UserValidator))] 24 | public IResult Add(User user) 25 | { 26 | 27 | _userDal.Add(user); 28 | return new SuccessResult(Messages.UserAdded); 29 | } 30 | 31 | public IResult Delete(User user) 32 | { 33 | _userDal.Delete(user); 34 | return new SuccessResult(Messages.UserDeleted); 35 | } 36 | 37 | public IDataResult GetById(int userId) 38 | { 39 | return new SuccessDataResult(_userDal.Get(u => u.UserId == userId)); 40 | } 41 | 42 | public IResult Update(User user) 43 | { 44 | _userDal.Update(user); 45 | return new SuccessResult(Messages.UserUpdated); 46 | } 47 | public IDataResult> GetAll() 48 | { 49 | return new SuccessDataResult>(_userDal.GetAll(), Messages.UsersListed); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /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 CarAdded="Yeni Araba Başarıyla Eklendi"; 11 | public static string CarDeleted = "Araba başarıyla silindi"; 12 | public static string CarUpdated = "Güncelleme başarılı"; 13 | public static string DescriptionInvalid = "Araba İsmi En Az 2 Karakter Olmalı"; 14 | internal static string MaintenanceTime = "Sistem Bakımda"; 15 | internal static string CarsListed = "Arabalar Listelendi"; 16 | 17 | 18 | public static string CustomerAdded = "Yeni müşteri Başarıyla Eklendi"; 19 | public static string CustomerDeleted = "Müşteri başarıyla silindi"; 20 | public static string CustomerUpdated = "Müşteri bilgileri Güncellendi"; 21 | internal static string CustomerrsListed = "Müşteriler Listelendi"; 22 | 23 | public static string UserAdded = "Kullanıcı Başarıyla Eklendi"; 24 | public static string UserDeleted = "Kullanıcı başarıyla silindi"; 25 | public static string UserUpdated = "Kullanıcı bilgileri Güncellendi"; 26 | internal static string UsersListed = "Kullanıcılar Listelendi"; 27 | 28 | public static string RentalAdded = "Kiralama Bilgisi Eklendi"; 29 | public static string RentalDeleted = "Kiralama Bilgisi silindi"; 30 | public static string RentalUpdated = "Kiralama Bilgisi Güncellendi"; 31 | internal static string RentalsListed = "Kiralama Bilgileri Listelendi"; 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /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 | 39 | builder.RegisterAssemblyTypes(assembly).AsImplementedInterfaces() 40 | .EnableInterfaceInterceptors(new ProxyGenerationOptions() 41 | { 42 | Selector = new AspectInterceptorSelector() 43 | }).SingleInstance(); 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(b => b.BrandName).NotEmpty(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /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(c => c.Description).MinimumLength(2); 14 | RuleFor(c => c.Description).NotEmpty(); 15 | RuleFor(c => c.DailyPrice).GreaterThanOrEqualTo(100); 16 | RuleFor(c => c.DailyPrice).NotEmpty(); 17 | 18 | 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /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.FluentValidation 8 | { 9 | public class CustomerValidator:AbstractValidator 10 | { 11 | public CustomerValidator() 12 | { 13 | RuleFor(cs => cs.CompanyName).MinimumLength(2); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /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(r => r.CarId).NotEmpty(); 14 | RuleFor(r => r.CustomerId).NotEmpty(); 15 | 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /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(u => u.FirstName).NotEmpty(); 14 | RuleFor(u => u.LastName).NotEmpty(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ConsoleApp1/ConsoleUI2.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /ConsoleApp1/Program.cs: -------------------------------------------------------------------------------- 1 | using Business.Concrete; 2 | using DataAccess.Abstract; 3 | using DataAccess.Concrete.EntityFramework; 4 | using DataAccess.Concrete.InMemory; 5 | using System; 6 | 7 | namespace ConsoleApp1 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | 14 | 15 | //CarManager carManager = new CarManager(new EFCarDal()); 16 | //var result = carManager.GetCarDetails(); 17 | //if (result.Success == true) 18 | //{ 19 | // foreach (var car in result.Data) 20 | // { 21 | // Console.WriteLine(car.BrandName + "/" + car.DailyPrice); 22 | // } 23 | 24 | // Console.WriteLine(result.Message); 25 | //} 26 | 27 | //private static void BrandColor() 28 | //{ 29 | // BrandManager brandManager = new BrandManager(new EFBrandDal()); 30 | // foreach (var brand in brandManager.GetAll()) 31 | // { 32 | // Console.WriteLine(brand.BrandName); 33 | // } 34 | 35 | // ColorManager colorManager = new ColorManager(new EFColorDal()); 36 | // foreach (var color in colorManager.GetAll()) 37 | // { 38 | // Console.WriteLine(color.ColorName); 39 | // } 40 | //} 41 | 42 | 43 | //CarManager carManager = new CarManager(new EFCarDal()); 44 | //carManager.Add(new Entities.Concrete.Car { Id = 11, BrandId = 1, ColorId = 3, ModelYear = 2020, DailyPrice = 1000, Description = "Mercedes A200 otomatik" }); 45 | 46 | 47 | //private static void Get() 48 | //{ 49 | // CarManager carManager = new CarManager(new EFCarDal()); 50 | // foreach (var car in carManager.GetAll()) 51 | // { 52 | // Console.WriteLine(car.ModelYear); 53 | // } 54 | 55 | 56 | // CarManager carManager = new CarManager(new EFCarDal()); 57 | // foreach (var car in carManager.GetCarsByBrandId(3)) 58 | // { 59 | // Console.WriteLine(car.DailyPrice); 60 | // } 61 | 62 | // CarManager carManager = new CarManager(new EFCarDal()); 63 | // foreach (var car in carManager.GetCarsByColorId(5)) 64 | // { 65 | // Console.WriteLine(car.DailyPrice); 66 | // } 67 | //} 68 | 69 | 70 | //UserManager userManager = new UserManager(new EFUserDal()); 71 | //foreach (var user in userManager.GetAll().Data) 72 | //{ 73 | // Console.WriteLine(user.FirstName + user.LastName + user.Email); 74 | //} 75 | //CustomerManager customerManager = new CustomerManager(new EFCustomerDal()); 76 | //foreach (var customer in customerManager.GetAll().Data) 77 | //{ 78 | // Console.WriteLine(customer.CompanyName); 79 | //} 80 | 81 | 82 | 83 | RentalManager rentalManager = new RentalManager(new EFRentalDal()); 84 | foreach (var rental in rentalManager.GetRentalDetails().Data) 85 | { 86 | Console.WriteLine(rental.FullName + ' ' + rental.CompanyName + ' ' + rental.Description + ' ' + rental.Description + ' ' + rental.RentDate + ' ' + rental.ReturnDate); 87 | } 88 | 89 | } 90 | 91 | 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /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 sınıfı 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 | 16 | -------------------------------------------------------------------------------- /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 | 14 | var result = validator.Validate(context); 15 | if (!result.IsValid) 16 | { 17 | throw new ValidationException(result.Errors); 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Core/DataAccess/EntityFramework/EFEntityRepositoryBase.cs: -------------------------------------------------------------------------------- 1 |  2 | using Core.Entities; 3 | using Microsoft.EntityFrameworkCore; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | using Core.DataAccess; 8 | using System.Linq.Expressions; 9 | using System.Linq; 10 | 11 | namespace Core.DataAccess.EntityFramework 12 | { 13 | public class EFEntityRepositoryBase:IEntityRepository 14 | where TEntity: class, IEntity,new() 15 | where TContext: DbContext, new() 16 | 17 | 18 | { 19 | public void Add(TEntity entity) 20 | { 21 | using (TContext context = new TContext()) 22 | { 23 | var addedEntity = context.Entry(entity); 24 | addedEntity.State = EntityState.Added; 25 | context.SaveChanges(); 26 | 27 | } 28 | } 29 | public void Delete(TEntity entity) 30 | { 31 | using (TContext context = new TContext()) 32 | { 33 | var deletedEntity = context.Entry(entity); 34 | deletedEntity.State = EntityState.Deleted; 35 | context.SaveChanges(); 36 | 37 | } 38 | } 39 | 40 | public TEntity Get(Expression> filter) 41 | { 42 | using (TContext context = new TContext()) 43 | { 44 | return context.Set().SingleOrDefault(filter); 45 | } 46 | } 47 | 48 | public List GetAll(Expression> filter = null) 49 | { 50 | 51 | 52 | using (TContext context = new TContext()) 53 | { 54 | return filter == null ? context.Set().ToList() : context.Set().Where(filter).ToList(); 55 | } 56 | } 57 | 58 | public void Update(TEntity entity) 59 | { 60 | using (TContext context = new TContext()) 61 | { 62 | var updatedEntity = context.Entry(entity); 63 | updatedEntity.State = EntityState.Modified; 64 | context.SaveChanges(); 65 | 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Core/DataAccess/IEntityRepository.cs: -------------------------------------------------------------------------------- 1 |  2 | using Core.Entities; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq.Expressions; 6 | using System.Text; 7 | 8 | namespace Core.DataAccess 9 | { 10 | public interface IEntityRepository where T : class, IEntity, new() 11 | { 12 | List GetAll(Expression> filter = null); 13 | T Get(Expression> filter); 14 | void Add(T entity); 15 | void Update(T entity); 16 | void Delete(T entity); 17 | 18 | 19 | } 20 | } 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Core/Entities/IDto.cs: -------------------------------------------------------------------------------- 1 | namespace Core 2 | { 3 | public interface IDto 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /Core/Entities/IEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Entities 6 | { 7 | public interface IEntity 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Core/Utilities/Interceptors/AspectInterceptorSelector.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Reflection; 6 | using System.Text; 7 | 8 | namespace Core.Utilities.Interceptors 9 | { 10 | 11 | public class AspectInterceptorSelector : IInterceptorSelector 12 | { 13 | public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors) 14 | { 15 | var classAttributes = type.GetCustomAttributes 16 | (true).ToList(); 17 | var methodAttributes = type.GetMethod(method.Name) 18 | .GetCustomAttributes(true); 19 | classAttributes.AddRange(methodAttributes); 20 | 21 | 22 | return classAttributes.OrderBy(x => x.Priority).ToArray(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Core/Utilities/Interceptors/MethodInterception.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using System; 3 | 4 | namespace Core.Utilities.Interceptors 5 | { 6 | public abstract class MethodInterception : MethodInterceptionBaseAttribute 7 | { 8 | protected virtual void OnBefore(IInvocation invocation) { } 9 | protected virtual void OnAfter(IInvocation invocation) { } 10 | protected virtual void OnException(IInvocation invocation, System.Exception e) { } 11 | protected virtual void OnSuccess(IInvocation invocation) { } 12 | public override void Intercept(IInvocation invocation) 13 | { 14 | var isSuccess = true; 15 | OnBefore(invocation); 16 | try 17 | { 18 | invocation.Proceed(); 19 | } 20 | catch (Exception e) 21 | { 22 | isSuccess = false; 23 | OnException(invocation, e); 24 | throw; 25 | } 26 | finally 27 | { 28 | if (isSuccess) 29 | { 30 | OnSuccess(invocation); 31 | } 32 | } 33 | OnAfter(invocation); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Core/Utilities/Interceptors/MethodInterceptionBaseAttribute.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using System; 3 | 4 | namespace Core.Utilities.Interceptors 5 | { 6 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] 7 | public abstract class MethodInterceptionBaseAttribute : Attribute, IInterceptor 8 | { 9 | public int Priority { get; set; } 10 | 11 | public virtual void Intercept(IInvocation invocation) 12 | { 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /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 | 10 | public Result(bool success, string message):this(success) 11 | { 12 | Message = message; 13 | 14 | } 15 | public Result(bool success) 16 | { 17 | Success = success; 18 | } 19 | 20 | public bool Success { get; } 21 | 22 | public string Message { get; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Core/Utilities/Results/SuccessDataResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results 6 | { 7 | public class SuccessDataResult:DataResult 8 | { 9 | public SuccessDataResult(T data, string message):base(data,true,message) 10 | { 11 | 12 | } 13 | public SuccessDataResult(T data):base(data,true) 14 | { 15 | 16 | } 17 | public SuccessDataResult(string message):base(default,true,message) 18 | { 19 | 20 | } 21 | public SuccessDataResult():base(default,true) 22 | { 23 | 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Utilities/Results/SuccessResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results 6 | { 7 | public class SuccessResult : Result 8 | { 9 | public SuccessResult(string message) : base(true, message) 10 | { 11 | } 12 | public SuccessResult() : base(true) 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /DataAccess/Abstract/IBrandDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Entities.Concrete; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace DataAccess.Abstract 8 | { 9 | public interface IBrandDal: IEntityRepository 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /DataAccess/Abstract/ICarDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Entities.Concrete; 3 | using Entities.DTOs; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace DataAccess.Abstract 9 | { 10 | public interface ICarDal : IEntityRepository 11 | { 12 | List GetCarDetails(); 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /DataAccess/Abstract/IColorDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Entities.Concrete; 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | using System.Text; 7 | 8 | namespace DataAccess.Abstract 9 | { 10 | public interface IColorDal : IEntityRepository 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DataAccess/Abstract/ICustomerDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Entities.Concrete; 3 | using Entities.DTOs; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace DataAccess.Abstract 9 | { 10 | public interface ICustomerDal:IEntityRepository 11 | { 12 | List GetCustomerDetails(); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /DataAccess/Abstract/IRentalDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Entities.Concrete; 3 | using Entities.DTOs; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace DataAccess.Abstract 9 | { 10 | public interface IRentalDal:IEntityRepository 11 | { 12 | List GetRentalDetails(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /DataAccess/Abstract/IUserDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Entities.Concrete; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace DataAccess.Abstract 8 | { 9 | public interface IUserDal:IEntityRepository 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/DailyCarRentalContext.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 DailyCarRentalContext:DbContext 10 | { 11 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 12 | { 13 | optionsBuilder.UseSqlServer(@"Server=(localdb)\MSSQLLocalDB;Initial Catalog=DailyCarRantal;Integrated Security=True"); 14 | } 15 | 16 | public DbSet Cars { get; set; } 17 | public DbSet Brands { get; set; } 18 | public DbSet Colors { get; set; } 19 | public DbSet Customers { get; set; } 20 | public DbSet Users{ get; set; } 21 | public DbSet Rentals { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EFBrandDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using DataAccess.Abstract; 3 | using Entities.Concrete; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq.Expressions; 7 | using System.Text; 8 | 9 | namespace DataAccess.Concrete.EntityFramework 10 | { 11 | public class EFBrandDal : EFEntityRepositoryBase,IBrandDal 12 | { 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EFCarDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using DataAccess.Abstract; 3 | using Entities.Concrete; 4 | using Entities.DTOs; 5 | using Microsoft.EntityFrameworkCore; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Linq.Expressions; 10 | using System.Text; 11 | 12 | namespace DataAccess.Concrete.EntityFramework 13 | { 14 | public class EFCarDal : EFEntityRepositoryBase, ICarDal 15 | { 16 | public List GetCarDetails() 17 | { 18 | using (DailyCarRentalContext context= new DailyCarRentalContext()) 19 | { 20 | var result = from c in context.Cars 21 | join b in context.Brands 22 | on c.BrandId equals b.BrandId 23 | join x in context.Colors 24 | on c.ColorId equals x.ColorId 25 | select new CarDetailDto 26 | { 27 | Id = c.Id, 28 | BrandName = b.BrandName, 29 | ColorName = x.ColorName, 30 | DailyPrice = c.DailyPrice, 31 | 32 | 33 | 34 | }; 35 | return result.ToList(); 36 | } 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EFColorDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using DataAccess.Abstract; 3 | using Entities.Concrete; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq.Expressions; 7 | using System.Text; 8 | 9 | namespace DataAccess.Concrete.EntityFramework 10 | { 11 | public class EFColorDal : EFEntityRepositoryBase,IColorDal 12 | { 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EFCustomerDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using DataAccess.Abstract; 3 | using Entities.Concrete; 4 | using Entities.DTOs; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq.Expressions; 8 | using System.Text; 9 | 10 | namespace DataAccess.Concrete.EntityFramework 11 | { 12 | public class EFCustomerDal : EFEntityRepositoryBase, ICustomerDal 13 | { 14 | public List GetCustomerDetails() 15 | { 16 | throw new NotImplementedException(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EFRentalDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using DataAccess.Abstract; 3 | using Entities.Concrete; 4 | using Entities.DTOs; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | 8 | namespace DataAccess.Concrete.EntityFramework 9 | { 10 | public class EFRentalDal : EFEntityRepositoryBase, IRentalDal 11 | { 12 | public List GetRentalDetails() 13 | { 14 | using (DailyCarRentalContext context=new DailyCarRentalContext()) 15 | { 16 | var result = from r in context.Rentals 17 | join c in context.Cars 18 | on r.CarId equals c.Id 19 | 20 | join cs in context.Customers 21 | on r.CustomerId equals cs.CustomerId 22 | 23 | join u in context.Users 24 | on cs.UserId equals u.UserId 25 | 26 | select new RentalDetailDto 27 | { 28 | RentalId = r.RentalId, 29 | CarId = c.Id, 30 | Description = c.Description, 31 | DailyPrice = c.DailyPrice, 32 | FullName= u.FirstName+' '+u.LastName, 33 | CompanyName = cs.CompanyName, 34 | RentDate=r.RentDate, 35 | ReturnDate=r.ReturnDate 36 | 37 | }; 38 | return result.ToList(); 39 | 40 | 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/InMemory/InMemoryCarDal.cs: -------------------------------------------------------------------------------- 1 | using DataAccess.Abstract; 2 | using Entities.Concrete; 3 | using Entities.DTOs; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Linq.Expressions; 8 | using System.Text; 9 | 10 | namespace DataAccess.Concrete.InMemory 11 | { 12 | public class InMemoryCarDal : ICarDal 13 | { 14 | List _cars; 15 | public InMemoryCarDal() 16 | { 17 | _cars = new List { 18 | new Car{Id=1,BrandId=1,ColorId=1,ModelYear=2020,DailyPrice=550,Description="Otomatik"}, 19 | new Car{Id=2,BrandId=1,ColorId=1,ModelYear=2015,DailyPrice=250,Description="Otomatik"}, 20 | new Car{Id=3,BrandId=2,ColorId=2,ModelYear=2017,DailyPrice=350,Description="Y.Otomatik"}, 21 | new Car{Id=4,BrandId=3,ColorId=2,ModelYear=2012,DailyPrice=150,Description="Y.Otomatik"}, 22 | new Car{Id=5,BrandId=3,ColorId=3,ModelYear=2018,DailyPrice=350,Description="Manuel"}, 23 | new Car{Id=6,BrandId=4,ColorId=3,ModelYear=2020,DailyPrice=450,Description="Manuel"}, 24 | new Car{Id=7,BrandId=4,ColorId=3,ModelYear=2019,DailyPrice=400,Description="Otomatik"}, 25 | new Car{Id=8,BrandId=4,ColorId=4,ModelYear=2017,DailyPrice=300,Description="Manuel"}, 26 | 27 | }; 28 | } 29 | public void Add(Car car) 30 | { 31 | _cars.Add(car); 32 | } 33 | 34 | public void Delete(Car car) 35 | { 36 | Car carToDelete = _cars.SingleOrDefault(c=> c.Id==car.Id); 37 | _cars.Remove(carToDelete); 38 | } 39 | 40 | public Car Get(Expression> filter = null) 41 | { 42 | throw new NotImplementedException(); 43 | } 44 | 45 | public List GetAll() 46 | { 47 | return _cars; 48 | } 49 | 50 | public List GetAllById(int brandId) 51 | { 52 | return _cars.Where(c => c.BrandId == brandId).ToList(); 53 | } 54 | 55 | public List GetAll(Expression> filter = null) 56 | { 57 | throw new NotImplementedException(); 58 | } 59 | 60 | public void Update(Car car) 61 | { 62 | Car carToUpdate = _cars.SingleOrDefault(c=>c.Id==car.Id); 63 | carToUpdate.BrandId = car.BrandId; 64 | carToUpdate.ColorId = car.ColorId; 65 | carToUpdate.ModelYear = car.ModelYear; 66 | carToUpdate.DailyPrice = car.DailyPrice; 67 | carToUpdate.Description = car.Description; 68 | } 69 | 70 | public List GetCarDetails() 71 | { 72 | throw new NotImplementedException(); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /DataAccess/DataAccess.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Entities/Concrete/Brand.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class Brand: IEntity 9 | { 10 | public int BrandId { get; set; } 11 | public string BrandName { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Entities/Concrete/Car.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class 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 | } 19 | -------------------------------------------------------------------------------- /Entities/Concrete/Color.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class Color: IEntity 9 | { 10 | public int ColorId { get; set; } 11 | public string ColorName { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Entities/Concrete/Customer.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class Customer : IEntity 9 | { 10 | public int CustomerId { get; set; } 11 | public int UserId { get; set; } 12 | public string CompanyName { get; set; } 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Entities/Concrete/Rental.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class Rental:IEntity 9 | { 10 | public int RentalId { get; set; } 11 | 12 | public int CarId { get; set; } 13 | public int CustomerId { get; set; } 14 | 15 | public DateTime RentDate { get; set; } 16 | public DateTime? ReturnDate { get; set; } 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Entities/Concrete/User.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class User:IEntity 9 | { 10 | public int UserId { 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 | } 18 | -------------------------------------------------------------------------------- /Entities/DTOs/CarDetailDto.cs: -------------------------------------------------------------------------------- 1 | using Core; 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 string BrandName { get; set; } 12 | public string ColorName { get; set; } 13 | public decimal DailyPrice { get; set; } 14 | 15 | 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Entities/DTOs/CustomerDetailDto.cs: -------------------------------------------------------------------------------- 1 |  2 | using Core; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Entities.DTOs 8 | { 9 | public class CustomerDetailDto:IDto 10 | { 11 | 12 | 13 | 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Entities/DTOs/RentalDetailDto.cs: -------------------------------------------------------------------------------- 1 | using Core; 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 RentalId { get; set; } 11 | public int CarId { get; set; } 12 | public string Description { get; set; } 13 | public decimal DailyPrice { get; set; } 14 | public string FullName { get; set; } 15 | 16 | public string CompanyName { get; set; } 17 | 18 | public DateTime RentDate { get; set; } 19 | public DateTime? ReturnDate { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /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}") = "DataAccess", "DataAccess\DataAccess.csproj", "{9B75B4DE-C1FD-47D9-9C61-AD9B0A475787}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Business", "Business\Business.csproj", "{7C8C5AC1-F613-4284-BFAD-DB00731DA35B}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Entities", "Entities\Entities.csproj", "{1FB7B81D-51EC-4C76-901B-3BF93B8147C9}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleUI2", "ConsoleApp1\ConsoleUI2.csproj", "{6E2A8EE0-688C-42B2-A85D-7EBF6AA6CF2E}" 13 | EndProject 14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core", "Core\Core.csproj", "{1A2AE36D-5E37-44C6-AE2F-673A2EB12F5F}" 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAPI", "WebAPI\WebAPI.csproj", "{8DDE1A8B-BBF7-4F27-A427-35144E6D9993}" 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 | {9B75B4DE-C1FD-47D9-9C61-AD9B0A475787}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {9B75B4DE-C1FD-47D9-9C61-AD9B0A475787}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {9B75B4DE-C1FD-47D9-9C61-AD9B0A475787}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {9B75B4DE-C1FD-47D9-9C61-AD9B0A475787}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {7C8C5AC1-F613-4284-BFAD-DB00731DA35B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {7C8C5AC1-F613-4284-BFAD-DB00731DA35B}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {7C8C5AC1-F613-4284-BFAD-DB00731DA35B}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {7C8C5AC1-F613-4284-BFAD-DB00731DA35B}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {1FB7B81D-51EC-4C76-901B-3BF93B8147C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {1FB7B81D-51EC-4C76-901B-3BF93B8147C9}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {1FB7B81D-51EC-4C76-901B-3BF93B8147C9}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {1FB7B81D-51EC-4C76-901B-3BF93B8147C9}.Release|Any CPU.Build.0 = Release|Any CPU 36 | {6E2A8EE0-688C-42B2-A85D-7EBF6AA6CF2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 37 | {6E2A8EE0-688C-42B2-A85D-7EBF6AA6CF2E}.Debug|Any CPU.Build.0 = Debug|Any CPU 38 | {6E2A8EE0-688C-42B2-A85D-7EBF6AA6CF2E}.Release|Any CPU.ActiveCfg = Release|Any CPU 39 | {6E2A8EE0-688C-42B2-A85D-7EBF6AA6CF2E}.Release|Any CPU.Build.0 = Release|Any CPU 40 | {1A2AE36D-5E37-44C6-AE2F-673A2EB12F5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 41 | {1A2AE36D-5E37-44C6-AE2F-673A2EB12F5F}.Debug|Any CPU.Build.0 = Debug|Any CPU 42 | {1A2AE36D-5E37-44C6-AE2F-673A2EB12F5F}.Release|Any CPU.ActiveCfg = Release|Any CPU 43 | {1A2AE36D-5E37-44C6-AE2F-673A2EB12F5F}.Release|Any CPU.Build.0 = Release|Any CPU 44 | {8DDE1A8B-BBF7-4F27-A427-35144E6D9993}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 45 | {8DDE1A8B-BBF7-4F27-A427-35144E6D9993}.Debug|Any CPU.Build.0 = Debug|Any CPU 46 | {8DDE1A8B-BBF7-4F27-A427-35144E6D9993}.Release|Any CPU.ActiveCfg = Release|Any CPU 47 | {8DDE1A8B-BBF7-4F27-A427-35144E6D9993}.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 = {B5B5958A-B8B8-4D25-B419-738DEBC2C7AD} 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 | 18 | public BrandsController(IBrandService brandService) 19 | { 20 | _brandService = brandService; 21 | } 22 | [HttpPost("add")] 23 | 24 | public IActionResult Add(Brand brand) 25 | { 26 | var result = _brandService.Add(brand); 27 | if (result.Success) 28 | { 29 | return Ok(result); 30 | } 31 | return BadRequest(result); 32 | } 33 | 34 | [HttpPost("delete")] 35 | public IActionResult Delete(Brand brand) 36 | { 37 | var result = _brandService.Delete(brand); 38 | if (result.Success) 39 | { 40 | return Ok(result); 41 | } 42 | return BadRequest(result); 43 | } 44 | 45 | [HttpGet("getall")] 46 | public IActionResult GetAll() 47 | { 48 | var result = _brandService.GetAll(); 49 | if (result.Success) 50 | { 51 | return Ok(result); 52 | 53 | } 54 | return BadRequest(result); 55 | 56 | } 57 | 58 | 59 | 60 | 61 | } 62 | 63 | } 64 | 65 | -------------------------------------------------------------------------------- /WebAPI/Controllers/CarsController.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Concrete; 3 | using DataAccess.Concrete.EntityFramework; 4 | using Entities.Concrete; 5 | using Microsoft.AspNetCore.Http; 6 | using Microsoft.AspNetCore.Mvc; 7 | using System; 8 | using System.Collections.Generic; 9 | using System.Linq; 10 | using System.Threading.Tasks; 11 | 12 | namespace WebAPI.Controllers 13 | { 14 | [Route("api/[controller]")] 15 | [ApiController] 16 | public class CarsController : ControllerBase 17 | { 18 | ICarService _carService; 19 | 20 | public CarsController(ICarService carService) 21 | { 22 | _carService = carService; 23 | } 24 | 25 | [HttpGet("getall")] 26 | public IActionResult GetAll() 27 | { 28 | var result = _carService.GetAll(); 29 | if (result.Success) 30 | { 31 | return Ok(result); 32 | 33 | } 34 | return BadRequest(result); 35 | 36 | } 37 | [HttpGet("getbyid")] 38 | public IActionResult GetById(int id) 39 | { 40 | var result = _carService.GetById(id); 41 | if (result.Success) 42 | { 43 | return Ok(result); 44 | 45 | } 46 | return BadRequest(result); 47 | } 48 | 49 | 50 | 51 | [HttpPost("add")] 52 | public IActionResult Add(Car car) 53 | { 54 | var result = _carService.Add(car); 55 | if (result.Success) 56 | { 57 | return Ok(result); 58 | } 59 | return BadRequest(result.Message); 60 | } 61 | 62 | [HttpPost("delete")] 63 | public IActionResult Delete(Car car) 64 | { 65 | var result = _carService.Delete(car); 66 | if (result.Success) 67 | { 68 | return Ok(result); 69 | } 70 | return BadRequest(result.Message); 71 | } 72 | 73 | [HttpPost("update")] 74 | public IActionResult UpDate(Car car) 75 | { 76 | var result = _carService.Update(car); 77 | if (result.Success) 78 | { 79 | return Ok(result); 80 | 81 | } 82 | return BadRequest(result.Message); 83 | } 84 | 85 | 86 | 87 | 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /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 | 18 | public ColorsController(IColorService colorService) 19 | { 20 | _colorService = colorService; 21 | } 22 | [HttpGet("getall")] 23 | public IActionResult GetAll() 24 | { 25 | var result = _colorService.GetAll(); 26 | if (result.Success) 27 | { 28 | return Ok(result); 29 | 30 | } 31 | return BadRequest(result); 32 | 33 | } 34 | 35 | [HttpPost("add")] 36 | public IActionResult Add(Color color) 37 | { 38 | var result = _colorService.Add(color); 39 | if (result.Success) 40 | { 41 | return Ok(result); 42 | } 43 | return BadRequest(result.Message); 44 | } 45 | 46 | [HttpPost("delete")] 47 | public IActionResult Delete(Color color) 48 | { 49 | var result = _colorService.Delete(color); 50 | if (result.Success) 51 | { 52 | return Ok(result); 53 | } 54 | return BadRequest(result.Message); 55 | } 56 | 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /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("getall")] 23 | public IActionResult GetAll() 24 | { 25 | var result = _customerService.GetAll(); 26 | if (result.Success) 27 | { 28 | return Ok(result); 29 | } 30 | return BadRequest(result.Message); 31 | } 32 | 33 | [HttpGet("getbyid")] 34 | public IActionResult GetById(int customerId ) 35 | { 36 | var result = _customerService.GetById(customerId); 37 | if (result.Success) 38 | { 39 | return Ok(result); 40 | } 41 | return BadRequest(result.Message); 42 | } 43 | 44 | [HttpPost("add")] 45 | public IActionResult Add(Customer customer) 46 | { 47 | var result = _customerService.Add(customer); 48 | if (result.Success) 49 | { 50 | return Ok(result); 51 | } 52 | return BadRequest(result.Message); 53 | } 54 | 55 | [HttpPost("delete")] 56 | public IActionResult Delete(Customer customer) 57 | { 58 | var result = _customerService.Delete(customer); 59 | if (result.Success) 60 | { 61 | return Ok(result); 62 | } 63 | return BadRequest(result.Message); 64 | } 65 | 66 | [HttpPost("update")] 67 | public IActionResult Update(Customer customer) 68 | { 69 | var result = _customerService.Update(customer); 70 | if (result.Success) 71 | { 72 | return Ok(result); 73 | } 74 | return BadRequest(result.Message); 75 | } 76 | 77 | 78 | 79 | 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /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 | 18 | public RentalsController(IRentalService rentalService) 19 | { 20 | _rentalService = rentalService; 21 | } 22 | 23 | [HttpGet("getall")] 24 | public IActionResult GetAll() 25 | { 26 | var result = _rentalService.GetAll(); 27 | if (result.Success) 28 | { 29 | return Ok(result); 30 | } 31 | return BadRequest(result.Message); 32 | } 33 | 34 | 35 | 36 | [HttpPost("add")] 37 | public IActionResult Add(Rental rental) 38 | { 39 | var result = _rentalService.Add(rental); 40 | if (result.Success) 41 | { 42 | return Ok(result); 43 | } 44 | return BadRequest(result.Message); 45 | } 46 | 47 | [HttpPost("delete")] 48 | public IActionResult Delete(Rental rental) 49 | { 50 | var result = _rentalService.Delete(rental); 51 | if (result.Success) 52 | { 53 | return Ok(result); 54 | } 55 | return BadRequest(result.Message); 56 | } 57 | 58 | [HttpPost("update")] 59 | public IActionResult Update(Rental rental) 60 | { 61 | var result = _rentalService.Update(rental); 62 | if (result.Success) 63 | { 64 | return Ok(result); 65 | } 66 | return BadRequest(result.Message); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /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 | 23 | 24 | [HttpGet("getall")] 25 | public IActionResult GetAll() 26 | { 27 | var result = _userService.GetAll(); 28 | if (result.Success) 29 | { 30 | return Ok(result); 31 | } 32 | return BadRequest(result.Message); 33 | } 34 | 35 | [HttpGet("getbyid")] 36 | public IActionResult GetById(int userId) 37 | { 38 | var result = _userService.GetById(userId); 39 | if (result.Success) 40 | { 41 | return Ok(result); 42 | } 43 | return BadRequest(result.Message); 44 | } 45 | 46 | [HttpPost("add")] 47 | public IActionResult Add(User user) 48 | { 49 | var result = _userService.Add(user); 50 | if (result.Success) 51 | { 52 | return Ok(result); 53 | } 54 | return BadRequest(result.Message); 55 | } 56 | 57 | [HttpPost("delete")] 58 | public IActionResult Delete(User user) 59 | { 60 | var result = _userService.Delete(user); 61 | if (result.Success) 62 | { 63 | return Ok(result); 64 | } 65 | return BadRequest(result.Message); 66 | } 67 | 68 | [HttpPost("update")] 69 | public IActionResult Update(User user) 70 | { 71 | var result = _userService.Update(user); 72 | if (result.Success) 73 | { 74 | return Ok(result); 75 | } 76 | return BadRequest(result.Message); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /WebAPI/Controllers/WeatherForecastController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.Extensions.Logging; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | namespace WebAPI.Controllers 8 | { 9 | [ApiController] 10 | [Route("[controller]")] 11 | public class WeatherForecastController : ControllerBase 12 | { 13 | private static readonly string[] Summaries = new[] 14 | { 15 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" 16 | }; 17 | 18 | private readonly ILogger _logger; 19 | 20 | public WeatherForecastController(ILogger logger) 21 | { 22 | _logger = logger; 23 | } 24 | 25 | [HttpGet] 26 | public IEnumerable Get() 27 | { 28 | var rng = new Random(); 29 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast 30 | { 31 | Date = DateTime.Now.AddDays(index), 32 | TemperatureC = rng.Next(-20, 55), 33 | Summary = Summaries[rng.Next(Summaries.Length)] 34 | }) 35 | .ToArray(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /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 | 30 | 31 | .ConfigureWebHostDefaults(webBuilder => 32 | { 33 | 34 | webBuilder.UseStartup(); 35 | }); 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /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:50423", 8 | "sslPort": 44385 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 | //services.AddSingleton(); 40 | //services.AddSingleton(); 41 | //services.AddSingleton(); 42 | //services.AddSingleton(); 43 | //services.AddSingleton(); 44 | //services.AddSingleton(); 45 | 46 | } 47 | 48 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 49 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 50 | { 51 | if (env.IsDevelopment()) 52 | { 53 | app.UseDeveloperExceptionPage(); 54 | } 55 | 56 | app.UseHttpsRedirection(); 57 | 58 | app.UseRouting(); 59 | 60 | app.UseAuthorization(); 61 | 62 | app.UseEndpoints(endpoints => 63 | { 64 | endpoints.MapControllers(); 65 | }); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------