├── .gitattributes ├── .gitignore ├── Business ├── Abstract │ ├── IAuthService.cs │ ├── IBrandService.cs │ ├── ICarImageService.cs │ ├── ICarService.cs │ ├── IColorService.cs │ ├── ICustomerService.cs │ ├── IPaymentService.cs │ ├── IRentalService.cs │ └── IUserService.cs ├── Business.csproj ├── BusinessAspects │ └── Autofac │ │ └── SecuredOperation.cs ├── Concrete │ ├── AuthManager.cs │ ├── BrandManager.cs │ ├── CarImageManager.cs │ ├── CarManager.cs │ ├── ColorManager.cs │ ├── CustomerManager.cs │ ├── PaymentManager.cs │ ├── RentalManager.cs │ └── UserManager.cs ├── Constants │ └── Messages.cs ├── DependencyResolvers │ └── Autofac │ │ └── AutofacBusinessModule.cs └── ValidationRules │ └── FluentValidation │ ├── BrandValidator.cs │ ├── CarImageValidator.cs │ ├── CarValidator.cs │ ├── ColorValidator.cs │ ├── CustomerValidator.cs │ ├── PaymentValidator.cs │ ├── RentalValidator.cs │ └── UserValidator.cs ├── ConsoleUI ├── ConsoleUI.csproj └── Program.cs ├── Core ├── Aspects │ └── Autofac │ │ ├── Caching │ │ ├── CacheAspect.cs │ │ └── CacheRemoveAspect.cs │ │ ├── Performance │ │ └── PerformanceAspect.cs │ │ ├── Transaction │ │ └── TransactionScopeAspect.cs │ │ └── Validation │ │ └── ValidationAspect.cs ├── Core.csproj ├── CrossCuttingConcerns │ ├── Caching │ │ ├── ICacheManager.cs │ │ └── Microsoft │ │ │ └── MemoryCacheManager.cs │ └── Validation │ │ └── ValidationTool.cs ├── DataAccess │ ├── EntityFramework │ │ └── EfEntityRepositoryBase.cs │ └── IEntityRepository.cs ├── DependencyResolvers │ └── CoreModule.cs ├── Entities │ ├── Abstract │ │ ├── IDto.cs │ │ └── IEntity.cs │ └── Concrete │ │ ├── OperationClaim.cs │ │ ├── User.cs │ │ └── UserOperationClaim.cs ├── Extensions │ ├── ClaimExtensions.cs │ ├── ClaimsPrincipalExtensions.cs │ ├── ErrorDetails.cs │ ├── ExceptionMiddleware.cs │ ├── ExceptionMiddlewareExtensions.cs │ └── ServiceCollectionExtensions.cs └── Utilities │ ├── Business │ └── BusinessRules.cs │ ├── Helpers │ └── FileHelper.cs │ ├── Interceptors │ ├── AspectInterceptorSelector.cs │ ├── MethodInterception.cs │ └── MethodInterceptionBaseAttribute.cs │ ├── IoC │ ├── ICoreModule.cs │ └── ServiceTool.cs │ ├── Results │ ├── Abstract │ │ ├── IDataResult.cs │ │ └── IResult.cs │ └── Concrete │ │ ├── DataResult.cs │ │ ├── ErrorDataResult.cs │ │ ├── ErrorResult.cs │ │ ├── Result.cs │ │ ├── SuccessDataResult.cs │ │ └── SuccessResult.cs │ └── Security │ ├── Encryption │ ├── SecurityKeyHelper.cs │ └── SigningCredentialsHelper.cs │ ├── Hashing │ └── HashingHelper.cs │ └── JWT │ ├── AccessToken.cs │ ├── ITokenHelper.cs │ ├── JwtHelper.cs │ └── TokenOptions.cs ├── DataAccess ├── Abstract │ ├── IBrandDal.cs │ ├── ICarDal.cs │ ├── ICarImageDal.cs │ ├── IColorDal.cs │ ├── ICustomerDal.cs │ ├── IPaymentDal.cs │ ├── IRentalDal.cs │ └── IUserDal.cs ├── Concrete │ ├── EntityFramework │ │ ├── EfBrandDal.cs │ │ ├── EfCarDal.cs │ │ ├── EfCarImageDal.cs │ │ ├── EfColorDal.cs │ │ ├── EfCustomerDal.cs │ │ ├── EfPaymentDal.cs │ │ ├── EfRentalDal.cs │ │ ├── EfUserDal.cs │ │ └── ReCapDbContext.cs │ └── InMemory │ │ └── InMemoryCarDal.cs └── DataAccess.csproj ├── Entities ├── Concrete │ ├── Brand.cs │ ├── Car.cs │ ├── CarImage.cs │ ├── Color.cs │ ├── Customer.cs │ ├── Payment.cs │ └── Rental.cs ├── DTOs │ ├── CarDetailDto.cs │ ├── CustomerDetailDto.cs │ ├── RentalDetailDto.cs │ ├── UserForLoginDto.cs │ ├── UserForRegisterDto.cs │ └── UserForUpdateDto .cs └── Entities.csproj ├── LICENSE ├── README.md ├── ReCapProject.sln ├── SQLQuery1.sql ├── SQLQuery2.sql ├── SQLQuery3.sql ├── SQLQuery5.sql ├── SQLQuery7.sql └── WebAPI ├── Controllers ├── AuthController.cs ├── BrandsController.cs ├── CarImagesController.cs ├── CarsController.cs ├── ColorsController.cs ├── CustomersController.cs ├── PaymentsController.cs ├── RentalsController.cs └── UsersController.cs ├── Program.cs ├── Properties └── launchSettings.json ├── Startup.cs ├── WeatherForecast.cs ├── WebAPI.csproj ├── appsettings.Development.json ├── appsettings.json └── wwwroot └── images ├── 29e59136-9487-4fd7-aead-6ec45257a523_3_1_2021.jpg ├── 41951129-4e62-4787-ab21-f4adb43b95f2_3_21_2021.jpg ├── c4b00bb4-8ac0-4b55-b69a-39f5584908fe_3_1_2021.jpg ├── c59673e9-3e85-4777-b4e9-3860a36940da_2_28_2021.jpg ├── cd7b1686-33a1-4c87-baae-44a8f96e61eb_3_21_2021.jpg ├── d5764523-dade-4589-9354-448ce38bba5d_3_21_2021.jpg └── null.jpg /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc -------------------------------------------------------------------------------- /Business/Abstract/IAuthService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results.Abstract; 2 | using Core.Utilities.Security.JWT; 3 | using Entities.Concrete; 4 | using Entities.DTOs; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Text; 8 | 9 | namespace Business.Abstract 10 | { 11 | public interface IAuthService 12 | { 13 | IDataResult Register(UserForRegisterDto userForRegisterDto, string password); 14 | IDataResult Login(UserForLoginDto userForLoginDto); 15 | IResult UserExists(string email); 16 | IDataResult CreateAccessToken(User user); 17 | IDataResult Update(UserForUpdateDto userForUpdate); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Business/Abstract/IBrandService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results; 2 | using Core.Utilities.Results.Abstract; 3 | using Entities.Concrete; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace Business.Abstract 9 | { 10 | public interface IBrandService 11 | { 12 | IDataResult> GetAll(); 13 | IDataResult> GetById(int id); 14 | IResult Add(Brand brand); 15 | IResult Update(Brand brand); 16 | IResult Delete(Brand brand); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Business/Abstract/ICarImageService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results.Abstract; 2 | using Entities.Concrete; 3 | using Microsoft.AspNetCore.Http; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace Business.Abstract 9 | { 10 | public interface ICarImageService 11 | { 12 | IDataResult> GetAll(); 13 | IDataResult Get(int id); 14 | IResult Add(IFormFile file, CarImage carImage); 15 | IResult Update(IFormFile file, CarImage carImage); 16 | IResult Delete(CarImage carImage); 17 | IDataResult> GetImagesByCarId(int id); 18 | IResult GetList(List list); 19 | IDataResult FindByID(int Id); 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Business/Abstract/ICarService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results; 2 | using Core.Utilities.Results.Abstract; 3 | using Entities.Concrete; 4 | using Entities.DTOs; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Text; 8 | 9 | namespace Business.Abstract 10 | { 11 | public interface ICarService 12 | { 13 | IDataResult> GetAll(); 14 | IDataResult GetById(int id); 15 | IDataResult> GetCarDetailByCarId(int carId); 16 | IDataResult> GetCarByBrandId(int brandId); 17 | IDataResult> GetCarByColorId(int colorId); 18 | IDataResult> GetCarByDailyPrice(decimal min, decimal max); 19 | IResult Add(Car car); 20 | IResult Update(Car car); 21 | IResult Delete(Car car); 22 | 23 | IDataResult> GetCarDetails(); 24 | 25 | IDataResult> CarListBrandIdColorId(int brandId, int colorId); 26 | 27 | IResult AddTransactionalTest(Car car); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Business/Abstract/IColorService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results; 2 | using Core.Utilities.Results.Abstract; 3 | using Entities.Concrete; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace Business.Abstract 9 | { 10 | public interface IColorService 11 | { 12 | IDataResult> GetAll(); 13 | IDataResult> GetById(int id); 14 | IResult Add(Color color); 15 | IResult Update(Color color); 16 | IResult Delete(Color color); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Business/Abstract/ICustomerService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results; 2 | using Core.Utilities.Results.Abstract; 3 | using Entities.Concrete; 4 | using Entities.DTOs; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Text; 8 | 9 | namespace Business.Abstract 10 | { 11 | public interface ICustomerService 12 | { 13 | IResult Add(Customer customer); 14 | IResult Delete(Customer customer); 15 | IResult Update(Customer customer); 16 | IDataResult GetById(int id); 17 | IDataResult> GetAll(); 18 | IDataResult> GetCustomerDetails(); 19 | IDataResult> GetCustomerDetailById(int customerId); 20 | IDataResult GetByEmail(string email); 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Business/Abstract/IPaymentService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results.Abstract; 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 IPaymentService 10 | { 11 | IDataResult> GetByCardNumber(string cardNumber); 12 | IResult VerifyCard(Payment creditCard); 13 | IDataResult> GetAll(); 14 | IDataResult GetById(int cardId); 15 | IDataResult> GetByCustomerId(int id); 16 | //IResult IsCardExist(Payment payment); 17 | IResult Add(Payment payment); 18 | IResult Delete(Payment payment); 19 | IResult Update(Payment payment); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Business/Abstract/IRentalService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results; 2 | using Core.Utilities.Results.Abstract; 3 | using Entities.Concrete; 4 | using Entities.DTOs; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Text; 8 | 9 | namespace Business.Abstract 10 | { 11 | public interface IRentalService 12 | { 13 | IDataResult> GetAll(); 14 | IResult Add(Rental rental); 15 | IResult Update(Rental rental); 16 | IResult Delete(Rental rental); 17 | IDataResult GetById(int rentalId); 18 | IDataResult> GetRentalDetailsDto(); 19 | IDataResult> GetRentalDetailsByCarId(int carId); 20 | IDataResult> GetByCarId(int carId); 21 | IDataResult> GetByCustomerId(int customerId); 22 | IDataResult CheckReturnDate(int carId); 23 | IResult CheckRule(Rental rental); 24 | IResult CheckRent(int carId); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Business/Abstract/IUserService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results; 2 | using Core.Utilities.Results.Abstract; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | using Entities.Concrete; 7 | 8 | namespace Business.Abstract 9 | { 10 | public interface IUserService 11 | { 12 | List GetClaims(User user); 13 | void ADD(User user); 14 | User GetByMail(string email); 15 | IDataResult GetLastUser(); 16 | IDataResult> GetAll(); 17 | IDataResult GetById(int id); 18 | IResult Add(User user); 19 | IResult Update(User user); 20 | IResult Delete(User user); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Business/Business.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Business/BusinessAspects/Autofac/SecuredOperation.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using Core.Utilities.Interceptors; 3 | using Core.Utilities.IoC; 4 | using Microsoft.AspNetCore.Http; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Text; 8 | using Microsoft.Extensions.DependencyInjection; 9 | using Core.Extensions; 10 | using Business.Constants; 11 | 12 | namespace Business.BusinessAspects.Autofac 13 | { 14 | public class SecuredOperation : MethodInterception 15 | { 16 | private string[] _roles; 17 | private IHttpContextAccessor _httpContextAccessor; 18 | 19 | public SecuredOperation(string roles) 20 | { 21 | _roles = roles.Split(','); 22 | _httpContextAccessor = ServiceTool.ServiceProvider.GetService(); 23 | 24 | } 25 | 26 | protected override void OnBefore(IInvocation invocation) 27 | { 28 | var roleClaims = _httpContextAccessor.HttpContext.User.ClaimRoles(); 29 | foreach (var role in _roles) 30 | { 31 | if (roleClaims.Contains(role)) 32 | { 33 | return; 34 | } 35 | } 36 | 37 | throw new Exception(Messages.AuthorizationDenied); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Business/Concrete/AuthManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Constants; 3 | using Core.Utilities.Results.Abstract; 4 | using Core.Utilities.Results.Concrete; 5 | using Core.Utilities.Security.Hashing; 6 | using Core.Utilities.Security.JWT; 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 AuthManager : IAuthService 16 | { 17 | private IUserService _userService; 18 | private ITokenHelper _tokenHelper; 19 | private ICustomerService _customerService; 20 | 21 | public AuthManager(IUserService userService, ITokenHelper tokenHelper, ICustomerService customerService) 22 | { 23 | _userService = userService; 24 | _tokenHelper = tokenHelper; 25 | _customerService = customerService; 26 | } 27 | 28 | public IDataResult Register(UserForRegisterDto userForRegisterDto, string password) 29 | { 30 | byte[] passwordHash, passwordSalt; 31 | HashingHelper.CreatePasswordHash(password, out passwordHash, out passwordSalt); 32 | var user = new User 33 | { 34 | Email = userForRegisterDto.Email, 35 | FirstName = userForRegisterDto.FirstName, 36 | LastName = userForRegisterDto.LastName, 37 | PasswordHash = passwordHash, 38 | PasswordSalt = passwordSalt, 39 | Status = true 40 | }; 41 | _userService.Add(user); 42 | var lastUser = _userService.GetLastUser(); 43 | 44 | var customer = new Customer 45 | { 46 | UserId = lastUser.Data.Id, 47 | CompanyName = userForRegisterDto.CompanyName, 48 | FindexPoint = userForRegisterDto.FindexPoint 49 | }; 50 | 51 | _customerService.Add(customer); 52 | return new SuccessDataResult(user, Messages.UserRegistered); 53 | } 54 | 55 | public IDataResult Login(UserForLoginDto userForLoginDto) 56 | { 57 | var userToCheck = _userService.GetByMail(userForLoginDto.Email); 58 | if (userToCheck == null) 59 | { 60 | return new ErrorDataResult(Messages.UserNotFound); 61 | } 62 | 63 | if (!HashingHelper.VerifyPasswordHash(userForLoginDto.Password, userToCheck.PasswordHash, userToCheck.PasswordSalt)) 64 | { 65 | return new ErrorDataResult(Messages.PasswordError); 66 | } 67 | 68 | return new SuccessDataResult(userToCheck, Messages.SuccessfulLogin); 69 | } 70 | 71 | public IResult UserExists(string email) 72 | { 73 | if (_userService.GetByMail(email) != null) 74 | { 75 | return new ErrorResult(Messages.UserAlreadyExists); 76 | } 77 | return new SuccessResult(); 78 | } 79 | 80 | public IDataResult CreateAccessToken(User user) 81 | { 82 | var claims = _userService.GetClaims(user); 83 | var accessToken = _tokenHelper.CreateToken(user, claims); 84 | return new SuccessDataResult(accessToken, Messages.AccessTokenCreated); 85 | } 86 | 87 | public IDataResult Update(UserForUpdateDto userForUpdate) 88 | { 89 | var currentUser = _userService.GetById(userForUpdate.UserId); 90 | 91 | var user = new User 92 | { 93 | Id = userForUpdate.UserId, 94 | Email = userForUpdate.Email, 95 | FirstName = userForUpdate.FirstName, 96 | LastName = userForUpdate.LastName, 97 | PasswordHash = currentUser.Data.PasswordHash, 98 | PasswordSalt = currentUser.Data.PasswordSalt 99 | }; 100 | 101 | byte[] passwordHash, passwordSalt; 102 | 103 | if (userForUpdate.Password != "") 104 | { 105 | HashingHelper.CreatePasswordHash(userForUpdate.Password, out passwordHash, out passwordSalt); 106 | 107 | user.PasswordHash = passwordHash; 108 | user.PasswordSalt = passwordSalt; 109 | } 110 | 111 | _userService.Update(user); 112 | 113 | var customer = new Customer 114 | { 115 | Id = userForUpdate.CustomerId, 116 | UserId = userForUpdate.UserId, 117 | CompanyName = userForUpdate.CompanyName, 118 | FindexPoint = userForUpdate.FindexPoint 119 | }; 120 | 121 | _customerService.Update(customer); 122 | 123 | return new SuccessDataResult(userForUpdate, Messages.CustomerUpdated); 124 | } 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /Business/Concrete/BrandManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.BusinessAspects.Autofac; 3 | using Business.Constants; 4 | using Business.ValidationRules.FluentValidation; 5 | using Core.Aspects.Autofac.Caching; 6 | using Core.Aspects.Autofac.Performance; 7 | using Core.Aspects.Autofac.Validation; 8 | using Core.CrossCuttingConcerns.Validation; 9 | using Core.Utilities.Results; 10 | using Core.Utilities.Results.Abstract; 11 | using Core.Utilities.Results.Concrete; 12 | using DataAccess.Abstract; 13 | using Entities.Concrete; 14 | using System; 15 | using System.Collections.Generic; 16 | using System.Text; 17 | using System.Linq; 18 | 19 | namespace Business.Concrete 20 | { 21 | public class BrandManager:IBrandService 22 | { 23 | IBrandDal _brandDal; 24 | 25 | public BrandManager(IBrandDal brandDal) 26 | { 27 | _brandDal = brandDal; 28 | } 29 | 30 | [SecuredOperation("admin")] 31 | [ValidationAspect(typeof(BrandValidator))] 32 | [CacheRemoveAspect("IBrandService.Get")] 33 | public IResult Add(Brand brand) 34 | { 35 | //bu kısmı fluent validator tarafına devrettim 36 | //if (brand.BrandName.Length <= 2) 37 | //{ 38 | // return new ErrorResult(Messages.BrandNameInvalid); 39 | //} 40 | //ValidationTool.Validate(new BrandValidator(), brand); 41 | _brandDal.Add(brand); 42 | return new SuccessResult(Messages.BrandAdded); 43 | } 44 | 45 | [SecuredOperation("admin")] 46 | [CacheRemoveAspect("IBrandService.Get")] 47 | public IResult Delete(Brand brand) 48 | { 49 | _brandDal.Delete(brand); 50 | return new SuccessResult(Messages.BrandDeleted); 51 | } 52 | 53 | [SecuredOperation("admin")] 54 | [ValidationAspect(typeof(BrandValidator))] 55 | [CacheRemoveAspect("IBrandService.Get")] 56 | public IResult Update(Brand brand) 57 | { 58 | _brandDal.Update(brand); 59 | return new SuccessResult(Messages.BrandUpdated); 60 | } 61 | 62 | [CacheAspect] 63 | [PerformanceAspect(10)] 64 | public IDataResult> GetAll() 65 | { 66 | return new SuccessDataResult>(_brandDal.GetAll(),Messages.BrandList); 67 | } 68 | 69 | [CacheAspect] 70 | [PerformanceAspect(5)] 71 | public IDataResult> GetById(int id) 72 | { 73 | return new SuccessDataResult>(_brandDal.GetAll(b => b.BrandId == id)); 74 | } 75 | 76 | 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Business/Concrete/CarImageManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.BusinessAspects.Autofac; 3 | using Business.Constants; 4 | using Business.ValidationRules.FluentValidation; 5 | using Core.Aspects.Autofac.Caching; 6 | using Core.Aspects.Autofac.Performance; 7 | using Core.Aspects.Autofac.Validation; 8 | using Core.Utilities.Business; 9 | using Core.Utilities.Helpers; 10 | using Core.Utilities.Results.Abstract; 11 | using Core.Utilities.Results.Concrete; 12 | using DataAccess.Abstract; 13 | using Entities.Concrete; 14 | using Microsoft.AspNetCore.Http; 15 | using System; 16 | using System.Collections.Generic; 17 | using System.IO; 18 | using System.Linq; 19 | using System.Text; 20 | 21 | namespace Business.Concrete 22 | { 23 | public class CarImageManager : ICarImageService 24 | { 25 | ICarImageDal _carImageDal; 26 | 27 | public CarImageManager(ICarImageDal carImageDal) 28 | { 29 | _carImageDal = carImageDal; 30 | } 31 | 32 | [SecuredOperation("carImages.add,admin")] 33 | [ValidationAspect(typeof(CarImageValidator))] 34 | [CacheRemoveAspect("ICarImageService.Get")] 35 | public IResult Add(IFormFile file, CarImage carImage) 36 | { 37 | IResult result = BusinessRules.Run(CheckIfImageLimit(carImage.CarId)); 38 | if (result!=null) 39 | { 40 | return result; 41 | } 42 | carImage.ImagePath = FileHelper.Add(file); 43 | carImage.Date = DateTime.Now; 44 | _carImageDal.Add(carImage); 45 | return new SuccessResult(Messages.CarImageAdded); 46 | } 47 | 48 | //[SecuredOperation("carImages.delete,admin")] 49 | [ValidationAspect(typeof(CarImageValidator))] 50 | [CacheRemoveAspect("ICarImageService.Get")] 51 | public IResult Delete(CarImage carImage) 52 | { 53 | IResult result = BusinessRules.Run(CarImageDelete(carImage)); 54 | if (result != null) 55 | { 56 | return result; 57 | } 58 | //FileHelper.Delete(carImage.ImagePath); 59 | _carImageDal.Delete(carImage); 60 | return new SuccessResult(Messages.CarImageDeleted); 61 | } 62 | 63 | [CacheAspect] 64 | [PerformanceAspect(5)] 65 | public IDataResult Get(int id) 66 | { 67 | return new SuccessDataResult(_carImageDal.Get(p => p.Id == id)); 68 | } 69 | 70 | [CacheAspect] 71 | [PerformanceAspect(10)] 72 | public IDataResult> GetAll() 73 | { 74 | return new SuccessDataResult>(_carImageDal.GetAll()); 75 | } 76 | 77 | [PerformanceAspect(5)] 78 | public IDataResult> GetImagesByCarId(int carId) 79 | { 80 | IResult result = BusinessRules.Run(CheckIfCarImageNull(carId)); 81 | if (result != null) 82 | { 83 | return new ErrorDataResult>(result.Message); 84 | } 85 | return new SuccessDataResult>(CheckIfCarImageNull(carId).Data); 86 | } 87 | 88 | [SecuredOperation("carImages.update,admin")] 89 | [ValidationAspect(typeof(CarImageValidator))] 90 | [CacheRemoveAspect("ICarImageService.Get")] 91 | public IResult Update(IFormFile file, CarImage carImage) 92 | { 93 | carImage.ImagePath = FileHelper.Update(_carImageDal.Get(p => p.Id == carImage.Id).ImagePath, file); 94 | carImage.Date = DateTime.Now; 95 | _carImageDal.Update(carImage); 96 | return new SuccessResult(Messages.CarImageUpdated); 97 | } 98 | 99 | 100 | //************************************************************************************* 101 | 102 | private IResult CheckIfImageLimit(int carid) 103 | { 104 | var carImagecount = _carImageDal.GetAll(p => p.CarId == carid).Count; 105 | if (carImagecount >= 5) 106 | { 107 | return new ErrorResult(Messages.FailAddedImageLimit); 108 | } 109 | 110 | return new SuccessResult(); 111 | } 112 | 113 | private IDataResult> CheckIfCarImageNull(int carId) 114 | { 115 | string path = "/images/null.jpg"; 116 | var result = _carImageDal.GetAll(c => c.CarId == carId).ToList(); 117 | if (result.Count == 0) 118 | { 119 | //return new List { new CarImage { CarId = carId, ImagePath = path, Date = DateTime.Now } }; 120 | List carImage = new List(); 121 | carImage.Add(new CarImage 122 | { 123 | CarId = carId, 124 | Date = DateTime.Now, 125 | ImagePath = path, 126 | }); 127 | return new SuccessDataResult>(carImage); 128 | } 129 | return new SuccessDataResult>(result); 130 | //_carImageDal.Update(carImage); 131 | //return _carImageDal.GetAll(p => p.CarId == carId); 132 | } 133 | 134 | public IResult GetList(List list) 135 | { 136 | Console.WriteLine("\n------- Car Image List -------"); 137 | 138 | foreach (var img in list) 139 | { 140 | Console.WriteLine("{0}- Car ID: {1}\n Image Path: {2}\n CratedAt: {3}\n", img.Id, img.CarId, img.ImagePath, img.Date); 141 | } 142 | return new SuccessResult(); 143 | } 144 | 145 | public IDataResult FindByID(int Id) 146 | { 147 | CarImage img = new CarImage(); 148 | if (_carImageDal.GetAll().Any(x => x.CarId == Id)) 149 | { 150 | img = _carImageDal.GetAll().FirstOrDefault(x => x.CarId == Id); 151 | } 152 | else Console.WriteLine("No such car image was found."); 153 | return new SuccessDataResult(img); 154 | } 155 | 156 | private IResult CarImageDelete(CarImage carImage) 157 | { 158 | try 159 | { 160 | FileHelper.Delete(carImage.ImagePath); 161 | } 162 | catch (Exception exception) 163 | { 164 | 165 | return new ErrorResult(exception.Message); 166 | } 167 | 168 | return new SuccessResult(); 169 | } 170 | } 171 | } 172 | -------------------------------------------------------------------------------- /Business/Concrete/CarManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.BusinessAspects.Autofac; 3 | using Business.Constants; 4 | using Business.ValidationRules.FluentValidation; 5 | using Core.Aspects.Autofac.Caching; 6 | using Core.Aspects.Autofac.Performance; 7 | using Core.Aspects.Autofac.Transaction; 8 | using Core.Aspects.Autofac.Validation; 9 | using Core.CrossCuttingConcerns.Validation; 10 | using Core.Utilities.Results.Abstract; 11 | using Core.Utilities.Results.Concrete; 12 | using DataAccess.Abstract; 13 | using DataAccess.Concrete.EntityFramework; 14 | using Entities.Concrete; 15 | using Entities.DTOs; 16 | using FluentValidation; 17 | using System; 18 | using System.Collections.Generic; 19 | using System.Linq; 20 | using System.Text; 21 | using System.Transactions; 22 | 23 | namespace Business.Concrete 24 | { 25 | public class CarManager : ICarService 26 | { 27 | ICarDal _carDal; 28 | 29 | public CarManager(ICarDal carDal) 30 | { 31 | _carDal = carDal; 32 | } 33 | 34 | [SecuredOperation("admin")] 35 | [ValidationAspect(typeof(CarValidator))] 36 | [CacheRemoveAspect("ICarService.Get")] 37 | public IResult Add(Car car) 38 | { 39 | //bu kısmı fluent validator tarafına devrettim 40 | //if (car.DailyPrice <= 0) 41 | //{ 42 | // return new ErrorResult(Messages.CarDailyPriceInvalid); 43 | //} 44 | //ValidationTool.Validate(new CarValidator(), car); 45 | 46 | _carDal.Add(car); 47 | return new SuccessResult(Messages.CarAdded); 48 | } 49 | 50 | [SecuredOperation("admin")] 51 | [CacheRemoveAspect("ICarService.Get")] 52 | public IResult Delete(Car car) 53 | { 54 | _carDal.Delete(car); 55 | return new SuccessResult(Messages.CarDeleted); 56 | } 57 | 58 | [SecuredOperation("admin")] 59 | [CacheRemoveAspect("ICarService.Get")] 60 | public IResult Update(Car car) 61 | { 62 | if (car.DailyPrice <= 0) 63 | { 64 | return new ErrorResult(Messages.CarDailyPriceInvalid); 65 | } 66 | _carDal.Update(car); 67 | return new SuccessResult(Messages.CarUpdated); 68 | } 69 | 70 | [CacheAspect] 71 | [CacheRemoveAspect("ICarService.Get")] 72 | [PerformanceAspect(10)] 73 | public IDataResult> GetAll() 74 | { 75 | if (DateTime.Now.Hour==06) 76 | { 77 | return new ErrorDataResult>(Messages.MaintenanceTime); 78 | } 79 | return new SuccessDataResult>(_carDal.GetAll(), Messages.CarList); 80 | } 81 | 82 | [PerformanceAspect(10)] 83 | public IDataResult> GetCarByDailyPrice(decimal min, decimal max) 84 | { 85 | return new SuccessDataResult>(_carDal.GetAll(c => c.DailyPrice >= min && c.DailyPrice <= max)); 86 | } 87 | 88 | [PerformanceAspect(5)] 89 | public IDataResult> GetCarByBrandId(int brandId) 90 | { 91 | var result=_carDal.GetCarDetails(c => c.BrandId == brandId); 92 | if (result.Count==0) 93 | { 94 | return new ErrorDataResult>(new List(), Messages.CarNotFound); 95 | } 96 | return new SuccessDataResult>(result); 97 | } 98 | 99 | [PerformanceAspect(5)] 100 | public IDataResult> GetCarByColorId(int colorId) 101 | { 102 | var result = _carDal.GetCarDetails(c => c.ColorId == colorId); 103 | if (result.Count == 0) 104 | { 105 | return new ErrorDataResult>(new List(), Messages.CarNotFound); 106 | } 107 | return new SuccessDataResult>(result); 108 | } 109 | 110 | [CacheAspect] 111 | [PerformanceAspect(5)] 112 | public IDataResult GetById(int id) 113 | { 114 | return new SuccessDataResult(_carDal.Get(c => c.Id == id)); 115 | } 116 | 117 | [CacheAspect] 118 | [PerformanceAspect(10)] 119 | public IDataResult> GetCarDetails() 120 | { 121 | return new SuccessDataResult>(_carDal.GetCarDetails()); 122 | } 123 | 124 | 125 | public IDataResult> CarListBrandIdColorId(int brandId,int colorId) 126 | { 127 | var results=_carDal.GetCarDetails(c=>c.ColorId==colorId && c.BrandId==brandId); 128 | if (results.Count == 0) 129 | { 130 | return new ErrorDataResult>(new List()); 131 | } 132 | return new SuccessDataResult>(results); 133 | } 134 | 135 | 136 | public IDataResult> GetCarDetailByCarId(int carId) 137 | { 138 | var result = _carDal.GetCarDetails(c => c.Id == carId); 139 | if (result.Count == 0) 140 | { 141 | return new ErrorDataResult>(new List(), Messages.CarNotFound); 142 | } 143 | return new SuccessDataResult>(result); 144 | } 145 | 146 | 147 | [TransactionScopeAspect] 148 | public IResult AddTransactionalTest(Car car) 149 | { 150 | using (TransactionScope scope = new TransactionScope()) 151 | { 152 | Add(car); 153 | 154 | if (car.DailyPrice < 0) 155 | { 156 | throw new Exception(Messages.CarDailyPriceInvalid); 157 | } 158 | 159 | Add(car); 160 | 161 | return null; 162 | } 163 | } 164 | 165 | 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /Business/Concrete/ColorManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.BusinessAspects.Autofac; 3 | using Business.Constants; 4 | using Business.ValidationRules.FluentValidation; 5 | using Core.Aspects.Autofac.Caching; 6 | using Core.Aspects.Autofac.Performance; 7 | using Core.Aspects.Autofac.Validation; 8 | using Core.Utilities.Results.Abstract; 9 | using Core.Utilities.Results.Concrete; 10 | using DataAccess.Abstract; 11 | using Entities.Concrete; 12 | using System; 13 | using System.Collections.Generic; 14 | using System.Text; 15 | 16 | namespace Business.Concrete 17 | { 18 | public class ColorManager : IColorService 19 | { 20 | IColorDal _colorDal; 21 | 22 | public ColorManager(IColorDal colorDal) 23 | { 24 | _colorDal = colorDal; 25 | } 26 | 27 | [SecuredOperation("color.add,admin")] 28 | [ValidationAspect(typeof(ColorValidator))] 29 | [CacheRemoveAspect("IColorService.Get")] 30 | public IResult Add(Color color) 31 | { 32 | _colorDal.Add(color); 33 | return new SuccessResult(Messages.ColorAdded); 34 | } 35 | 36 | [SecuredOperation("admin")] 37 | [CacheRemoveAspect("IColorService.Get")] 38 | public IResult Delete(Color color) 39 | { 40 | _colorDal.Delete(color); 41 | return new SuccessResult(Messages.ColorDeleted); 42 | } 43 | 44 | [SecuredOperation("admin")] 45 | [ValidationAspect(typeof(ColorValidator))] 46 | [CacheRemoveAspect("IColorService.Get")] 47 | public IResult Update(Color color) 48 | { 49 | _colorDal.Update(color); 50 | return new SuccessResult(Messages.ColorUpdated); 51 | } 52 | 53 | [CacheAspect] 54 | [PerformanceAspect(10)] 55 | public IDataResult> GetAll() 56 | { 57 | return new SuccessDataResult>(_colorDal.GetAll(),Messages.ColorList); 58 | } 59 | 60 | [CacheAspect] 61 | [PerformanceAspect(5)] 62 | public IDataResult> GetById(int id) 63 | { 64 | return new SuccessDataResult>(_colorDal.GetAll(c => c.ColorId == id)); 65 | } 66 | 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Business/Concrete/CustomerManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.ValidationRules.FluentValidation; 3 | using Core.Aspects.Autofac.Caching; 4 | using Core.Aspects.Autofac.Performance; 5 | using Core.Aspects.Autofac.Validation; 6 | using Core.Utilities.Results; 7 | using Core.Utilities.Results.Abstract; 8 | using Core.Utilities.Results.Concrete; 9 | using DataAccess.Abstract; 10 | using Entities.Concrete; 11 | using Entities.DTOs; 12 | using System; 13 | using System.Collections.Generic; 14 | using System.Text; 15 | 16 | namespace Business.Concrete 17 | { 18 | public class CustomerManager : ICustomerService 19 | { 20 | ICustomerDal _customerDal; 21 | 22 | public CustomerManager(ICustomerDal customerDal) 23 | { 24 | _customerDal = customerDal; 25 | } 26 | 27 | [CacheRemoveAspect("ICustomerService.Get")] 28 | public IResult Add(Customer customer) 29 | { 30 | _customerDal.Add(customer); 31 | return new SuccessResult(); 32 | } 33 | 34 | [CacheRemoveAspect("ICustomerService.Get")] 35 | public IResult Delete(Customer customer) 36 | { 37 | _customerDal.Delete(customer); 38 | return new SuccessResult(); 39 | } 40 | 41 | [ValidationAspect(typeof(CustomerValidator))] 42 | [CacheAspect] 43 | [PerformanceAspect(10)] 44 | public IDataResult> GetAll() 45 | { 46 | return new SuccessDataResult>(_customerDal.GetAll()); 47 | } 48 | 49 | public IDataResult GetByEmail(string email) 50 | { 51 | var getByEmail = _customerDal.GetByEmail(user => user.Email == email); 52 | return new SuccessDataResult(getByEmail); 53 | } 54 | 55 | [CacheAspect] 56 | [PerformanceAspect(5)] 57 | public IDataResult GetById(int id) 58 | { 59 | return new SuccessDataResult(_customerDal.Get(c => c.Id == id)); 60 | } 61 | 62 | public IDataResult> GetCustomerDetailById(int customerId) 63 | { 64 | return new SuccessDataResult> 65 | (_customerDal.GetCustomerDetails(c => c.Id == customerId)); 66 | } 67 | 68 | public IDataResult> GetCustomerDetails() 69 | { 70 | return new SuccessDataResult>(_customerDal.GetCustomerDetails()); 71 | } 72 | 73 | 74 | 75 | [CacheRemoveAspect("ICustomerService.Get")] 76 | public IResult Update(Customer customer) 77 | { 78 | _customerDal.Update(customer); 79 | return new SuccessResult(); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Business/Concrete/PaymentManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Constants; 3 | using Core.Aspects.Autofac.Caching; 4 | using Core.Utilities.Results.Abstract; 5 | using Core.Utilities.Results.Concrete; 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 PaymentManager : IPaymentService 15 | { 16 | IPaymentDal _paymentDal; 17 | 18 | public PaymentManager(IPaymentDal paymentDal) 19 | { 20 | _paymentDal = paymentDal; 21 | } 22 | 23 | [CacheRemoveAspect("IPaymentService.Get")] 24 | public IResult Add(Payment payment) 25 | { 26 | var result = CheckCard(payment); 27 | 28 | if (result) 29 | { 30 | return new SuccessResult(); 31 | } 32 | _paymentDal.Add(payment); 33 | return new SuccessResult(Messages.CardAdded); 34 | } 35 | 36 | [CacheRemoveAspect("IPaymentService.Get")] 37 | public IResult Delete(Payment payment) 38 | { 39 | _paymentDal.Delete(payment); 40 | return new SuccessResult(); 41 | } 42 | 43 | [CacheRemoveAspect("IPaymentService.Get")] 44 | public IResult Update(Payment payment) 45 | { 46 | _paymentDal.Update(payment); 47 | return new SuccessResult(); 48 | } 49 | 50 | public IDataResult> GetAll() 51 | { 52 | return new SuccessDataResult>(_paymentDal.GetAll()); 53 | } 54 | 55 | public IDataResult GetById(int cardId) 56 | { 57 | return new SuccessDataResult(_paymentDal.Get(p => p.PaymentId == cardId)); 58 | } 59 | 60 | public IDataResult> GetByCustomerId(int customerId) 61 | { 62 | var getByCustomerId = _paymentDal.GetAll(payment => payment.CustomerId == customerId); 63 | return new SuccessDataResult>(getByCustomerId); 64 | } 65 | 66 | public IDataResult> GetByCardNumber(string cardNumber) 67 | { 68 | return new SuccessDataResult>(_paymentDal.GetAll(c => c.CardNumber == cardNumber)); 69 | } 70 | 71 | public IResult VerifyCard(Payment card) 72 | { 73 | var result = _paymentDal.Get(c => c.CardNameSurname == card.CardNameSurname && c.CardNumber == card.CardNumber && c.CardCvv == card.CardCvv); 74 | if (result == null) 75 | { 76 | return new ErrorResult(); 77 | } 78 | return new SuccessResult(); 79 | } 80 | 81 | private bool CheckCard(Payment card) 82 | { 83 | var beforeExist = _paymentDal.GetAll(c => c.CustomerId == card.CustomerId); 84 | 85 | if (beforeExist.Count > 0) 86 | { 87 | var currentCard = _paymentDal.Get(c => c.CardNumber == card.CardNumber); 88 | 89 | if (currentCard != null) 90 | { 91 | return true; 92 | } 93 | } 94 | 95 | return false; 96 | } 97 | 98 | //public IResult IsCardExist(Payment payment) 99 | //{ 100 | // var result = _paymentDal.Get(p => p.CardNameSurname == payment.CardNameSurname && p.CardNumber == payment.CardNumber 101 | // && p.CardCvv == payment.CardCvv && p.CardExpiryDate == payment.CardExpiryDate); 102 | // if (result == null) 103 | // { 104 | // return new ErrorResult(); 105 | // } 106 | // return new SuccessResult(); 107 | //} 108 | 109 | //public bool CheckCardNumber(string cardNumber) 110 | //{ 111 | // var getByCardNumber = _paymentDal.Get(c => c.CardNumber == cardNumber); 112 | 113 | // if (getByCardNumber != null) 114 | // return true; 115 | 116 | // return false; 117 | //} 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /Business/Concrete/RentalManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Constants; 3 | using Business.ValidationRules.FluentValidation; 4 | using Core.Aspects.Autofac.Caching; 5 | using Core.Aspects.Autofac.Performance; 6 | using Core.Aspects.Autofac.Validation; 7 | using Core.Utilities.Business; 8 | using Core.Utilities.Results.Abstract; 9 | using Core.Utilities.Results.Concrete; 10 | using DataAccess.Abstract; 11 | using Entities.Concrete; 12 | using Entities.DTOs; 13 | using System; 14 | using System.Collections.Generic; 15 | using System.Linq; 16 | using System.Text; 17 | 18 | namespace Business.Concrete 19 | { 20 | public class RentalManager : IRentalService 21 | { 22 | IRentalDal _rentalDal; 23 | 24 | public RentalManager(IRentalDal rentalDal) 25 | { 26 | _rentalDal = rentalDal; 27 | } 28 | 29 | [ValidationAspect(typeof(RentalValidator))] 30 | [CacheRemoveAspect("IRentalService.Get")] 31 | public IResult Add(Rental rental) 32 | { 33 | var result=_rentalDal.GetAll(r => r.CarId == rental.CarId && r.ReturnDate == null ).Any(); 34 | if (result) 35 | { 36 | return new ErrorResult(Messages.RentedCarAlreadyExists); 37 | } 38 | _rentalDal.Add(rental); 39 | return new SuccessResult(Messages.RentalAdded); 40 | } 41 | 42 | public IDataResult CheckReturnDate(int carId) 43 | { 44 | List resultRental = _rentalDal.GetAll(r => r.CarId == carId && r.ReturnDate == null); 45 | if (resultRental.Count > 0) 46 | { 47 | return new ErrorDataResult(Messages.RentalUndeliveredCar); 48 | } 49 | return new SuccessDataResult(_rentalDal.Get(r => r.CarId == carId)); 50 | } 51 | 52 | public IResult CheckRule(Rental rental) 53 | { 54 | IResult result = BusinessRules.Run(RentalRule(rental)); 55 | 56 | if (result != null) 57 | { 58 | return result; 59 | } 60 | return new SuccessResult(); 61 | } 62 | 63 | [CacheRemoveAspect("IRentalService.Get")] 64 | public IResult Delete(Rental rental) 65 | { 66 | _rentalDal.Delete(rental); 67 | return new SuccessResult(Messages.RentalDeleted); 68 | } 69 | 70 | [CacheAspect] 71 | [PerformanceAspect(10)] 72 | public IDataResult> GetAll() 73 | { 74 | return new SuccessDataResult>(_rentalDal.GetAll(), Messages.RentalList); 75 | } 76 | 77 | public IDataResult> GetByCarId(int carId) 78 | { 79 | return new SuccessDataResult>(_rentalDal.GetAll(r => r.CarId == carId)); 80 | } 81 | 82 | public IDataResult> GetByCustomerId(int customerId) 83 | { 84 | return new SuccessDataResult>(_rentalDal.GetAll(r => r.CustomerId == customerId)); 85 | } 86 | 87 | public IDataResult GetById(int rentalId) 88 | { 89 | return new SuccessDataResult(_rentalDal.Get(r => r.Id == rentalId)); 90 | } 91 | 92 | public IDataResult> GetRentalDetailsByCarId(int carId) 93 | { 94 | return new SuccessDataResult> 95 | (_rentalDal.GetRentalDetails(r => r.CarId == carId), Messages.RentalListed); 96 | } 97 | 98 | [CacheAspect] 99 | [PerformanceAspect(10)] 100 | public IDataResult> GetRentalDetailsDto() 101 | { 102 | return new SuccessDataResult>(_rentalDal.GetRentalDetails()); 103 | } 104 | 105 | [CacheRemoveAspect("IRentalService.Get")] 106 | public IResult Update(Rental rental) 107 | { 108 | _rentalDal.Update(rental); 109 | return new SuccessResult(Messages.RentalUpdated); 110 | } 111 | 112 | 113 | 114 | private IResult RentalRule(Rental rental) 115 | { 116 | var result = _rentalDal.GetAll(r => r.CarId == rental.CarId && 117 | ((rental.RentDate > r.RentDate || rental.ReturnDate >= r.RentDate) && rental.RentDate <= r.ReturnDate)); 118 | 119 | if (rental.RentDate < DateTime.Now || result.Count > 0) 120 | { 121 | return new ErrorResult(); 122 | } 123 | return new SuccessResult(); 124 | } 125 | 126 | public IResult CheckRent(int carId) 127 | { 128 | var result = _rentalDal.GetAll().Where(r => r.CarId == carId).LastOrDefault(); 129 | if (result!=null && (result.ReturnDate!=null && result.ReturnDate<= DateTime.Now)) 130 | { 131 | return new SuccessResult(); 132 | } 133 | return new ErrorResult(); 134 | } 135 | 136 | 137 | 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /Business/Concrete/UserManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Constants; 3 | using Business.ValidationRules.FluentValidation; 4 | using Core.Aspects.Autofac.Caching; 5 | using Core.Aspects.Autofac.Validation; 6 | using Core.Utilities.Results; 7 | using Core.Utilities.Results.Abstract; 8 | using Core.Utilities.Results.Concrete; 9 | using DataAccess.Abstract; 10 | using Entities.Concrete; 11 | using System; 12 | using System.Collections.Generic; 13 | using System.Linq; 14 | using System.Text; 15 | 16 | namespace Business.Concrete 17 | { 18 | public class UserManager : IUserService 19 | { 20 | IUserDal _userDal; 21 | 22 | public UserManager(IUserDal userDal) 23 | { 24 | _userDal = userDal; 25 | } 26 | 27 | [CacheAspect] 28 | public List GetClaims(User user) 29 | { 30 | return _userDal.GetClaims(user); 31 | } 32 | 33 | public void ADD(User user) 34 | { 35 | _userDal.Add(user); 36 | } 37 | 38 | public User GetByMail(string email) 39 | { 40 | return _userDal.Get(u => u.Email == email); 41 | } 42 | 43 | public IDataResult GetById(int id) 44 | { 45 | return new SuccessDataResult(_userDal.Get(user => user.Id == id)); 46 | } 47 | 48 | public IResult Add(User user) 49 | { 50 | _userDal.Add(user); 51 | return new SuccessResult(Messages.UserAdded); 52 | } 53 | 54 | public IResult Update(User user) 55 | { 56 | _userDal.Update(user); 57 | return new SuccessResult(Messages.UserUpdated); 58 | } 59 | 60 | public IResult Delete(User user) 61 | { 62 | _userDal.Delete(user); 63 | return new SuccessResult(Messages.UserDeleted); 64 | } 65 | 66 | public IDataResult GetLastUser() 67 | { 68 | var lastUser = _userDal.GetAll().LastOrDefault(); 69 | return new SuccessDataResult(lastUser); 70 | } 71 | 72 | public IDataResult> GetAll() 73 | { 74 | var getAll = _userDal.GetAll(); 75 | return new SuccessDataResult>(getAll); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Business/Constants/Messages.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.Serialization; 4 | using System.Text; 5 | using Entities.Concrete; 6 | 7 | namespace Business.Constants 8 | { 9 | public static class Messages 10 | { 11 | public static string CarAdded = "Araba eklendi"; 12 | public static string CarNotFound = "Araba bulunamadı"; 13 | public static string CarDailyPriceInvalid = "Arabanın günlük fiyatı 0'dan büyük olmalıdır"; 14 | public static string CarDeleted= "Araba silindi"; 15 | public static string CarUpdated = "Araba güncellendi"; 16 | public static string CarList = "Arabalar listesi"; 17 | 18 | public static string ColorAdded = "Renk eklendi"; 19 | public static string ColorDeleted = "Renk silindi"; 20 | public static string ColorUpdated = "Renk güncellendi"; 21 | public static string ColorList = "Renkler listesi"; 22 | 23 | public static string BrandAdded = "Marka eklendi"; 24 | public static string BrandNameInvalid = "Marka ismi en az 2 harfden oluşmalıdır"; 25 | public static string BrandDeleted = "Marka silindi"; 26 | public static string BrandUpdated = "Marka güncellendi"; 27 | public static string BrandList = "Markalar listesi"; 28 | 29 | public static string UserAdded = "Kullanıcı eklendi"; 30 | public static string UserDeleted = "Kullanıcı silindi"; 31 | public static string UserUpdated = "Kullanıcı güncellendi"; 32 | public static string UserList = "Kullanıcılar listesi"; 33 | 34 | public static string RentalAdded = "Kira eklendi"; 35 | public static string RentalDeleted = "Kira silindi"; 36 | public static string RentalUpdated = "Kira güncellendi"; 37 | public static string RentalList = "Kira listesi"; 38 | 39 | public static string MaintenanceTime="Sistem bakımda"; 40 | 41 | public static string FailAddedImageLimit = "Resim limiti aşıldı"; 42 | public static string AuthorizationDenied = "Yetkiniz yok"; 43 | 44 | public static string UserRegistered = "Kayıt oldu"; 45 | public static string UserNotFound = "Kullanıcı bulunamadı"; 46 | public static string PasswordError = "Parola hatası"; 47 | public static string SuccessfulLogin = "Başarılı giriş"; 48 | public static string UserAlreadyExists = "Kullanıcı mevcut"; 49 | 50 | public static string AccessTokenCreated = "Token oluşturuldu"; 51 | 52 | public static string CarImageAdded = "Resim başarıyla eklendi"; 53 | public static string CarImageDeleted = "Resim başarıyla silindi"; 54 | public static string CarImageUpdated = "Resim başarıyla güncellendi"; 55 | 56 | public static string PaymentGetAll = "Ödemeler listelendi"; 57 | public static string RentalUndeliveredCar = "Araç henüz teslim edilmedi"; 58 | public static string RentalListed = "Kiralamalar Lİstelendi"; 59 | public static string RentedCarAlreadyExists = "Bu kiralık araba zaten var"; 60 | 61 | public static string CardAdded = "Kart eklendi"; 62 | 63 | public static string CustomerUpdated = "Müşteri güncellendi"; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Business/DependencyResolvers/Autofac/AutofacBusinessModule.cs: -------------------------------------------------------------------------------- 1 |  2 | using Autofac; 3 | using Autofac.Extras.DynamicProxy; 4 | using Business.Abstract; 5 | using Business.Concrete; 6 | using Castle.DynamicProxy; 7 | using Core.Utilities.Interceptors; 8 | using Core.Utilities.Security.JWT; 9 | using DataAccess.Abstract; 10 | using DataAccess.Concrete.EntityFramework; 11 | using Microsoft.AspNetCore.Http; 12 | using System; 13 | using System.Collections.Generic; 14 | using System.Text; 15 | 16 | namespace Business.DependencyResolvers.Autofac 17 | { 18 | public class AutofacBusinessModule:Module 19 | { 20 | protected override void Load(ContainerBuilder builder) 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 | builder.RegisterType().As().SingleInstance(); 38 | builder.RegisterType().As().SingleInstance(); 39 | 40 | builder.RegisterType().As().SingleInstance(); 41 | builder.RegisterType().As().SingleInstance(); 42 | 43 | builder.RegisterType().As().SingleInstance(); 44 | builder.RegisterType().As().SingleInstance(); 45 | 46 | builder.RegisterType().As(); 47 | builder.RegisterType().As(); 48 | 49 | //builder.RegisterType().As(); 50 | 51 | 52 | 53 | var assembly = System.Reflection.Assembly.GetExecutingAssembly(); 54 | 55 | builder.RegisterAssemblyTypes(assembly).AsImplementedInterfaces() 56 | .EnableInterfaceInterceptors(new ProxyGenerationOptions() 57 | { 58 | Selector = new AspectInterceptorSelector() 59 | }).SingleInstance(); 60 | 61 | 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /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 | RuleFor(b => b.BrandName).MinimumLength(2); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/CarImageValidator.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 CarImageValidator : AbstractValidator 10 | { 11 | public CarImageValidator() 12 | { 13 | RuleFor(c => c.CarId).NotNull(); 14 | RuleFor(c => c.Id).NotNull(); 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(c => c.DailyPrice).GreaterThan(2); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /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(c => c.ColorName).NotEmpty(); 14 | RuleFor(c => c.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.FluentValidation 8 | { 9 | public class CustomerValidator:AbstractValidator 10 | { 11 | public CustomerValidator() 12 | { 13 | RuleFor(c => c.UserId).NotEmpty(); 14 | } 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/PaymentValidator.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 PaymentValidator:AbstractValidator 10 | { 11 | public PaymentValidator() 12 | { 13 | RuleFor(p => p.CardCvv).NotEmpty(); 14 | RuleFor(p => p.CardExpiryDate).NotEmpty(); 15 | RuleFor(p => p.CardNumber).NotEmpty(); 16 | } 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(p => p.CarId).NotEmpty(); 14 | RuleFor(p => p.CustomerId).NotEmpty(); 15 | RuleFor(p => p.ReturnDate).NotEmpty(); 16 | RuleFor(r => r.ReturnDate).GreaterThanOrEqualTo(r => r.RentDate).When(r => r.ReturnDate.HasValue); 17 | } 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/UserValidator.cs: -------------------------------------------------------------------------------- 1 |  2 | using Entities.Concrete; 3 | using FluentValidation; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace Business.ValidationRules.FluentValidation 9 | { 10 | public class UserValidator : AbstractValidator 11 | { 12 | public UserValidator() 13 | { 14 | RuleFor(u => u.FirstName).NotNull().MaximumLength(20); 15 | RuleFor(u => u.LastName).NotNull().MaximumLength(20); 16 | RuleFor(u => u.Email).NotNull().EmailAddress(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ConsoleUI/ConsoleUI.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /ConsoleUI/Program.cs: -------------------------------------------------------------------------------- 1 | using Business.Concrete; 2 | using DataAccess.Concrete.EntityFramework; 3 | using DataAccess.Concrete.InMemory; 4 | using Entities.Concrete; 5 | using System; 6 | 7 | namespace ConsoleUI 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | BrandManager brandManager = new BrandManager(new EfBrandDal()); 14 | //foreach (var brand in brandManager.GetAll()) 15 | //{ 16 | // Console.WriteLine(brand.BrandName); 17 | //} 18 | 19 | ColorManager colorManager = new ColorManager(new EfColorDal()); 20 | //foreach (var color in colorManager.GetAll()) 21 | //{ 22 | // Console.WriteLine(color.ColorName); 23 | //} 24 | 25 | CarManager carManager = new CarManager(new EfCarDal()); 26 | 27 | 28 | foreach (var car in carManager.GetCarDetails().Data) 29 | { 30 | Console.WriteLine("{0} - {1} - {2} - {3} - {4} - {5}", 31 | car.Id,car.ColorName,car.BrandName,car.ModelYear,car.Description,car.DailyPrice); 32 | } 33 | 34 | //Brand brand1 = new Brand {BrandName="Tofash"}; 35 | //Brand brand2 = new Brand(); 36 | 37 | //brandManager.Add(brand1); 38 | 39 | //Console.WriteLine("Brand Id'si 1 olan arabalar:"); 40 | //Console.WriteLine(String.Format("{0,-12} | {1,-12} | {2,-13} | {3,-13} | {4,-13} | {5,-20} ", 41 | // "CarID", "Color", "Brand", "Model Year", "Daily Price", "Description\n")); 42 | //foreach (var car in carManager.GetCarByBrandId(3)) 43 | //{ 44 | // Console.WriteLine(String.Format("{0,-12} | {1,-12} | {2,-13} | {3,-13} | {4,-13} | {5,-20} ", car.Id, colorManager.GetById(car.ColorId).ColorName, 45 | // brandManager.GetById(car.BrandId).BrandName, car.ModelYear, car.DailyPrice, car.Description)); 46 | 47 | //} 48 | 49 | //Console.WriteLine("\n\nGünlük fiyat aralığı 200 ile 500 olan arabalar:"); 50 | //foreach (var car in carManager.GetCarByDailyPrice(200,500)) 51 | //{ 52 | // Console.WriteLine(String.Format("{0,-12} | {1,-12} | {2,-13} | {3,-13} | {4,-13} | {5,-20} ", car.Id, colorManager.GetById(car.ColorId).ColorName, 53 | // brandManager.GetById(car.BrandId).BrandName, car.ModelYear, car.DailyPrice, car.Description)); 54 | //} 55 | 56 | //Car car1 = carManager.GetById(5); 57 | //Console.WriteLine(String.Format("{0,-12} | {1,-12} | {2,-13} | {3,-13} | {4,-13} | {5,-20} ", car1.Id, colorManager.GetById(car1.ColorId).ColorName, 58 | // brandManager.GetById(car1.BrandId).BrandName, car1.ModelYear, car1.DailyPrice, car1.Description)); 59 | 60 | //carManager.Add(new Car { BrandId = 7, ColorId = 2, DailyPrice = 700, ModelYear = 2012, Description = "Güzel Araba" }); 61 | //foreach (var car in carManager.GetAll()) 62 | // { 63 | // Console.WriteLine(String.Format("{0,-12} | {1,-12} | {2,-13} | {3,-13} | {4,-13} | {5,-20} ", car.Id, colorManager.GetById(car.ColorId).ColorName, 64 | // brandManager.GetById(car.BrandId).BrandName, car.ModelYear, car.DailyPrice, car.Description)); 65 | 66 | //} 67 | //brandManager.Add(new Brand { BrandName = "a" }); 68 | //carManager.Add(new Car { DailyPrice=-200 }); 69 | //Car car3 = new Car {Id=2012 }; 70 | //carManager.Delete(car3); 71 | //carManager.Update(new Car { Id=1, BrandId = 1, ColorId = 5, DailyPrice = 470, ModelYear = 2020, Description = "AUDI Q8 - Red" }); 72 | //carManager.Update(new Car { Id = 7,BrandId=7,ModelYear=2021,ColorId=1,DailyPrice=730, Description = "PORSCHE P911 Turbo S - Black" }); 73 | 74 | 75 | 76 | Console.ReadLine(); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Core/Aspects/Autofac/Caching/CacheAspect.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using Core.CrossCuttingConcerns.Caching; 3 | using Core.Utilities.Interceptors; 4 | using Core.Utilities.IoC; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using Microsoft.Extensions.DependencyInjection; 10 | 11 | namespace Core.Aspects.Autofac.Caching 12 | { 13 | public class CacheAspect : MethodInterception 14 | { 15 | private int _duration; 16 | private ICacheManager _cacheManager; 17 | 18 | public CacheAspect(int duration = 60) 19 | { 20 | _duration = duration; 21 | _cacheManager = ServiceTool.ServiceProvider.GetService(); 22 | } 23 | 24 | public override void Intercept(IInvocation invocation) 25 | { 26 | var methodName = string.Format($"{invocation.Method.ReflectedType.FullName}.{invocation.Method.Name}"); 27 | var arguments = invocation.Arguments.ToList(); 28 | var key = $"{methodName}({string.Join(",", arguments.Select(x => x?.ToString() ?? ""))})"; 29 | if (_cacheManager.IsAdd(key)) 30 | { 31 | invocation.ReturnValue = _cacheManager.Get(key); 32 | return; 33 | } 34 | invocation.Proceed(); 35 | _cacheManager.Add(key, invocation.ReturnValue, _duration); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Core/Aspects/Autofac/Caching/CacheRemoveAspect.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using Core.CrossCuttingConcerns.Caching; 3 | using Core.Utilities.Interceptors; 4 | using Core.Utilities.IoC; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Text; 8 | using Microsoft.Extensions.DependencyInjection; 9 | 10 | namespace Core.Aspects.Autofac.Caching 11 | { 12 | public class CacheRemoveAspect : MethodInterception 13 | { 14 | private string _pattern; 15 | private ICacheManager _cacheManager; 16 | 17 | public CacheRemoveAspect(string pattern) 18 | { 19 | _pattern = pattern; 20 | _cacheManager = ServiceTool.ServiceProvider.GetService(); 21 | } 22 | 23 | protected override void OnSuccess(IInvocation invocation) 24 | { 25 | _cacheManager.RemoveByPattern(_pattern); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Core/Aspects/Autofac/Performance/PerformanceAspect.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using Core.Utilities.Interceptors; 3 | using Core.Utilities.IoC; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Diagnostics; 7 | using System.Text; 8 | using Microsoft.Extensions.DependencyInjection; 9 | 10 | namespace Core.Aspects.Autofac.Performance 11 | { 12 | public class PerformanceAspect : MethodInterception 13 | { 14 | private int _interval; 15 | private Stopwatch _stopwatch; 16 | 17 | public PerformanceAspect(int interval) 18 | { 19 | _interval = interval; 20 | _stopwatch = ServiceTool.ServiceProvider.GetService(); 21 | } 22 | 23 | 24 | protected override void OnBefore(IInvocation invocation) 25 | { 26 | _stopwatch.Start(); 27 | } 28 | 29 | protected override void OnAfter(IInvocation invocation) 30 | { 31 | if (_stopwatch.Elapsed.TotalSeconds > _interval) 32 | { 33 | Debug.WriteLine($"Performance : {invocation.Method.DeclaringType.FullName}.{invocation.Method.Name}-->{_stopwatch.Elapsed.TotalSeconds}"); 34 | } 35 | _stopwatch.Reset(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Core/Aspects/Autofac/Transaction/TransactionScopeAspect.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using Core.Utilities.Interceptors; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | using System.Transactions; 7 | 8 | namespace Core.Aspects.Autofac.Transaction 9 | { 10 | public class TransactionScopeAspect : MethodInterception 11 | { 12 | public override void Intercept(IInvocation invocation) 13 | { 14 | using (TransactionScope transactionScope = new TransactionScope()) 15 | { 16 | try 17 | { 18 | invocation.Proceed(); 19 | transactionScope.Complete();//bitir demek 20 | } 21 | catch (Exception) 22 | { 23 | transactionScope.Dispose();//çalıştır demek 24 | throw; 25 | } 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /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("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 | 7.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Core/CrossCuttingConcerns/Caching/ICacheManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.CrossCuttingConcerns.Caching 6 | { 7 | public interface ICacheManager 8 | { 9 | T Get(string key); 10 | object Get(string key); 11 | void Add(string key, object value, int duration); 12 | bool IsAdd(string key); 13 | void Remove(string key); 14 | void RemoveByPattern(string pattern); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Core/CrossCuttingConcerns/Caching/Microsoft/MemoryCacheManager.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.IoC; 2 | using Microsoft.Extensions.Caching.Memory; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | using Microsoft.Extensions.DependencyInjection; 7 | using System.Text.RegularExpressions; 8 | using System.Linq; 9 | 10 | namespace Core.CrossCuttingConcerns.Caching.Microsoft 11 | { 12 | public class MemoryCacheManager : ICacheManager 13 | { 14 | IMemoryCache _memoryCache; 15 | public MemoryCacheManager() 16 | { 17 | _memoryCache = ServiceTool.ServiceProvider.GetService(); 18 | } 19 | public void Add(string key, object value, int duration) 20 | { 21 | _memoryCache.Set(key, value, TimeSpan.FromMinutes(duration)); 22 | } 23 | 24 | public T Get(string key) 25 | { 26 | return _memoryCache.Get(key); 27 | } 28 | 29 | public object Get(string key) 30 | { 31 | return _memoryCache.Get(key); 32 | } 33 | 34 | public bool IsAdd(string key) 35 | { 36 | return _memoryCache.TryGetValue(key, out _); 37 | } 38 | 39 | public void Remove(string key) 40 | { 41 | _memoryCache.Remove(key); 42 | } 43 | 44 | public void RemoveByPattern(string pattern) 45 | { 46 | var cacheEntriesCollectionDefinition = typeof(MemoryCache).GetProperty("EntriesCollection", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); 47 | var cacheEntriesCollection = cacheEntriesCollectionDefinition.GetValue(_memoryCache) as dynamic; 48 | List cacheCollectionValues = new List(); 49 | 50 | foreach (var cacheItem in cacheEntriesCollection) 51 | { 52 | ICacheEntry cacheItemValue = cacheItem.GetType().GetProperty("Value").GetValue(cacheItem, null); 53 | cacheCollectionValues.Add(cacheItemValue); 54 | } 55 | 56 | var regex = new Regex(pattern, RegexOptions.Singleline | RegexOptions.Compiled | RegexOptions.IgnoreCase); 57 | var keysToRemove = cacheCollectionValues.Where(d => regex.IsMatch(d.Key.ToString())).Select(d => d.Key).ToList(); 58 | 59 | foreach (var key in keysToRemove) 60 | { 61 | _memoryCache.Remove(key); 62 | } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /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 Core.Entities.Abstract; 2 | using Microsoft.EntityFrameworkCore; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Linq.Expressions; 7 | using System.Text; 8 | 9 | namespace Core.DataAccess.EntityFramework 10 | { 11 | public class EfEntityRepositoryBase : IEntityRepository 12 | where TEntity : class, IEntity, new() 13 | where TContext : DbContext, new() 14 | { 15 | public void Add(TEntity entity) 16 | { 17 | using (TContext context = new TContext()) 18 | { 19 | var addedEntity = context.Entry(entity); 20 | addedEntity.State = EntityState.Added; 21 | context.SaveChanges(); 22 | } 23 | } 24 | 25 | public void Delete(TEntity entity) 26 | { 27 | using (TContext context = new TContext()) 28 | { 29 | var deletedEntity = context.Entry(entity); 30 | deletedEntity.State = EntityState.Deleted; 31 | context.SaveChanges(); 32 | } 33 | } 34 | 35 | public TEntity Get(Expression> filter) 36 | { 37 | using (TContext context = new TContext()) 38 | { 39 | return context.Set().SingleOrDefault(filter); 40 | } 41 | } 42 | 43 | public List GetAll(Expression> filter = null) 44 | { 45 | using (TContext context = new TContext()) 46 | { 47 | return filter == null ? context.Set().ToList() : context.Set().Where(filter).ToList(); 48 | } 49 | } 50 | 51 | public void Update(TEntity entity) 52 | { 53 | using (TContext context = new TContext()) 54 | { 55 | var updatedEntity = context.Entry(entity); 56 | updatedEntity.State = EntityState.Modified; 57 | context.SaveChanges(); 58 | 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Core/DataAccess/IEntityRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq.Expressions; 5 | using System.Text; 6 | 7 | namespace Core.DataAccess 8 | { 9 | public interface IEntityRepository where T:class,IEntity,new() 10 | { 11 | List GetAll(Expression> filter=null); 12 | T Get(Expression>filter); //tek data getirmek için 13 | void Add(T entity); 14 | void Update(T entity); 15 | void Delete(T entity); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Core/DependencyResolvers/CoreModule.cs: -------------------------------------------------------------------------------- 1 | using Core.CrossCuttingConcerns.Caching; 2 | using Core.CrossCuttingConcerns.Caching.Microsoft; 3 | using Core.Utilities.IoC; 4 | using Microsoft.AspNetCore.Http; 5 | using Microsoft.Extensions.DependencyInjection; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Diagnostics; 9 | using System.Text; 10 | 11 | namespace Core.DependencyResolvers 12 | { 13 | public class CoreModule : ICoreModule 14 | { 15 | public void Load(IServiceCollection serviceCollection) 16 | { 17 | serviceCollection.AddMemoryCache(); 18 | serviceCollection.AddSingleton(); 19 | serviceCollection.AddSingleton(); 20 | serviceCollection.AddSingleton(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Core/Entities/Abstract/IDto.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Entities.Abstract 2 | { 3 | public interface IDto 4 | { 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /Core/Entities/Abstract/IEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Entities.Abstract 6 | { 7 | public interface IEntity 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Core/Entities/Concrete/OperationClaim.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Abstract; 2 | 3 | namespace Entities.Concrete 4 | { 5 | public class OperationClaim:IEntity 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Core/Entities/Concrete/User.cs: -------------------------------------------------------------------------------- 1 | using Core.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 byte[] PasswordHash { get; set; } 15 | public byte[] PasswordSalt { get; set; } 16 | public bool Status { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Core/Entities/Concrete/UserOperationClaim.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Abstract; 2 | 3 | namespace Entities.Concrete 4 | { 5 | public class UserOperationClaim:IEntity 6 | { 7 | public int Id { get; set; } 8 | public int UserId { get; set; } 9 | public int OperationClaimId { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Core/Extensions/ClaimExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IdentityModel.Tokens.Jwt; 4 | using System.Linq; 5 | using System.Security.Claims; 6 | using System.Text; 7 | 8 | namespace Core.Extensions 9 | { 10 | public static class ClaimExtensions 11 | { 12 | public static void AddEmail(this ICollection claims, string email) 13 | { 14 | claims.Add(new Claim(JwtRegisteredClaimNames.Email, email)); 15 | } 16 | 17 | public static void AddName(this ICollection claims, string name) 18 | { 19 | claims.Add(new Claim(ClaimTypes.Name, name)); 20 | } 21 | 22 | public static void AddNameIdentifier(this ICollection claims, string nameIdentifier) 23 | { 24 | claims.Add(new Claim(ClaimTypes.NameIdentifier, nameIdentifier)); 25 | } 26 | 27 | public static void AddRoles(this ICollection claims, string[] roles) 28 | { 29 | roles.ToList().ForEach(role => claims.Add(new Claim(ClaimTypes.Role, role))); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Core/Extensions/ClaimsPrincipalExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Security.Claims; 5 | using System.Text; 6 | 7 | namespace Core.Extensions 8 | { 9 | public static class ClaimsPrincipalExtensions 10 | { 11 | public static List Claims(this ClaimsPrincipal claimsPrincipal, string claimType) 12 | { 13 | var result = claimsPrincipal?.FindAll(claimType)?.Select(x => x.Value).ToList(); 14 | return result; 15 | } 16 | 17 | public static List ClaimRoles(this ClaimsPrincipal claimsPrincipal) 18 | { 19 | return claimsPrincipal?.Claims(ClaimTypes.Role); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Core/Extensions/ErrorDetails.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation.Results; 2 | using Newtonsoft.Json; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Core.Extensions 8 | { 9 | public class ErrorDetails 10 | { 11 | public string Message { get; set; } 12 | public int StatusCode { get; set; } 13 | 14 | public override string ToString() 15 | { 16 | return JsonConvert.SerializeObject(this); 17 | } 18 | } 19 | 20 | public class ValidationErrorDetails : ErrorDetails 21 | { 22 | public IEnumerable Errors { get; set; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Core/Extensions/ExceptionMiddleware.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | using FluentValidation.Results; 3 | using Microsoft.AspNetCore.Http; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Net; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace Core.Extensions 11 | { 12 | public class ExceptionMiddleware 13 | { 14 | private RequestDelegate _next; 15 | 16 | public ExceptionMiddleware(RequestDelegate next) 17 | { 18 | _next = next; 19 | } 20 | 21 | public async Task InvokeAsync(HttpContext httpContext) 22 | { 23 | try 24 | { 25 | await _next(httpContext); 26 | } 27 | catch (Exception e) 28 | { 29 | await HandleExceptionAsync(httpContext, e); 30 | } 31 | } 32 | 33 | private Task HandleExceptionAsync(HttpContext httpContext, Exception e) 34 | { 35 | httpContext.Response.ContentType = "application/json"; 36 | httpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError; 37 | 38 | string message = "Internal Server Error"; 39 | IEnumerable errors; 40 | if (e.GetType() == typeof(ValidationException)) 41 | { 42 | message = e.Message; 43 | errors = ((ValidationException)e).Errors; 44 | httpContext.Response.StatusCode = 400; 45 | 46 | return httpContext.Response.WriteAsync(new ValidationErrorDetails 47 | { 48 | StatusCode = 400, 49 | Message = message, 50 | Errors = errors 51 | }.ToString()); 52 | } 53 | 54 | return httpContext.Response.WriteAsync(new ErrorDetails 55 | { 56 | StatusCode = httpContext.Response.StatusCode, 57 | Message = message 58 | }.ToString()); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Core/Extensions/ExceptionMiddlewareExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Extensions 7 | { 8 | public static class ExceptionMiddlewareExtensions 9 | { 10 | public static void ConfigureCustomExceptionMiddleware(this IApplicationBuilder app) 11 | { 12 | app.UseMiddleware(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Core/Extensions/ServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.IoC; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Core.Extensions 8 | { 9 | public static class ServiceCollectionExtensions 10 | { 11 | public static IServiceCollection AddDependencyResolvers(this IServiceCollection serviceCollection, ICoreModule[] modules) 12 | { 13 | foreach (var module in modules) 14 | { 15 | module.Load(serviceCollection); 16 | } 17 | 18 | return ServiceTool.Create(serviceCollection); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Core/Utilities/Business/BusinessRules.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Utilities.Business 7 | { 8 | public class BusinessRules 9 | { 10 | public static IResult Run(params IResult[] logics) 11 | { 12 | foreach (var logic in logics) 13 | { 14 | if (!logic.Success) 15 | { 16 | return logic; 17 | } 18 | 19 | } 20 | return null; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Core/Utilities/Helpers/FileHelper.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results.Abstract; 2 | using Core.Utilities.Results.Concrete; 3 | using Microsoft.AspNetCore.Http; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.IO; 7 | using System.Text; 8 | 9 | namespace Core.Utilities.Helpers 10 | { 11 | public class FileHelper 12 | { 13 | public static string Add(IFormFile file) 14 | { 15 | string path = Environment.CurrentDirectory + @"\wwwroot\images\"; 16 | var sourcepath = Path.GetTempFileName(); 17 | if (file.Length>0) 18 | { 19 | using (var stream=new FileStream(sourcepath,FileMode.Create)) 20 | { 21 | file.CopyTo(stream); 22 | } 23 | } 24 | var path1 = newPath(file); 25 | var result = path + path1; 26 | File.Move(sourcepath, result); 27 | return "/images/" + path1; 28 | } 29 | 30 | 31 | public static void Delete(string path) 32 | { 33 | string path2 = Environment.CurrentDirectory + @"\wwwroot"; 34 | File.Delete(path2+path); 35 | } 36 | 37 | public static string Update(string sourcePath,IFormFile file) 38 | { 39 | var result= Add(file); 40 | if (sourcePath.Length > 0) 41 | { 42 | Delete(sourcePath); 43 | } 44 | 45 | 46 | return result; 47 | } 48 | 49 | 50 | public static string newPath(IFormFile file) 51 | { 52 | FileInfo ff = new FileInfo(file.FileName); 53 | string fileExtension = ff.Extension;//extension uzantı demek dosyanın uzantısını aldım png, jpeg gibi düşünün 54 | 55 | //string path = Environment.CurrentDirectory + @"\wwwroot\images"; //Environment.CurrentDirectory geçerli çalışma dizininin tam yolunu alır veya ayarlar 56 | var newPath = Guid.NewGuid().ToString() + "_" + DateTime.Now.Month + "_" + DateTime.Now.Day + "_" + DateTime.Now.Year + fileExtension; 57 | 58 | //string result = $@"{path}\{newPath}"; 59 | return newPath; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /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 | public class AspectInterceptorSelector : IInterceptorSelector 11 | { 12 | public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors) 13 | { 14 | var classAttributes = type.GetCustomAttributes 15 | (true).ToList(); 16 | var methodAttributes = type.GetMethod(method.Name) 17 | .GetCustomAttributes(true); 18 | classAttributes.AddRange(methodAttributes); 19 | 20 | return classAttributes.OrderBy(x => x.Priority).ToArray(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /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/IoC/ICoreModule.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Utilities.IoC 7 | { 8 | public interface ICoreModule 9 | { 10 | void Load(IServiceCollection serviceCollection); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Core/Utilities/IoC/ServiceTool.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Utilities.IoC 7 | { 8 | public static class ServiceTool 9 | { 10 | public static IServiceProvider ServiceProvider { get; private set; } 11 | 12 | public static IServiceCollection Create(IServiceCollection services) 13 | { 14 | ServiceProvider = services.BuildServiceProvider(); 15 | return services; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Core/Utilities/Results/Abstract/IDataResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results.Abstract 6 | { 7 | public interface IDataResult:IResult 8 | { 9 | T Data { get; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Core/Utilities/Results/Abstract/IResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results.Abstract 6 | { 7 | public interface IResult 8 | { 9 | bool Success { get; } 10 | string Message { get; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Core/Utilities/Results/Concrete/DataResult.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Utilities.Results.Concrete 7 | { 8 | public class DataResult : Result, IDataResult 9 | { 10 | public T Data { get; } 11 | 12 | public DataResult(T data,bool success,string message):base(success,message) 13 | { 14 | Data = data; 15 | } 16 | 17 | public DataResult(T data,bool success):base(success) 18 | { 19 | Data = data; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Core/Utilities/Results/Concrete/ErrorDataResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results.Concrete 6 | { 7 | public class ErrorDataResult : DataResult 8 | { 9 | public ErrorDataResult(T data, string message) : base(data, false, message) 10 | { 11 | 12 | } 13 | 14 | public ErrorDataResult(T data) : base(data, false) 15 | { 16 | 17 | } 18 | 19 | public ErrorDataResult(string message) : base(default, false, message) 20 | { 21 | 22 | } 23 | 24 | public ErrorDataResult() : base(default, false) 25 | { 26 | 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Core/Utilities/Results/Concrete/ErrorResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results.Concrete 6 | { 7 | public class ErrorResult:Result 8 | { 9 | public ErrorResult(string message) : base(false, message) 10 | { 11 | 12 | } 13 | 14 | public ErrorResult() : base(false) 15 | { 16 | 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Core/Utilities/Results/Concrete/Result.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Utilities.Results.Concrete 7 | { 8 | public class Result : IResult 9 | { 10 | public Result(bool success, string message):this(success) 11 | { 12 | Message = message; 13 | //Success = success; this(success) verdik diye bu satıra gerek yok 14 | } 15 | 16 | public Result(bool success) 17 | { 18 | Success = success; 19 | } 20 | public bool Success { get; } 21 | 22 | public string Message { get; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Core/Utilities/Results/Concrete/SuccessDataResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results.Concrete 6 | { 7 | public class SuccessDataResult:DataResult 8 | { 9 | public SuccessDataResult(T data,string message):base(data,true,message) 10 | { 11 | 12 | } 13 | 14 | public SuccessDataResult(T data):base(data, true) 15 | { 16 | 17 | } 18 | 19 | public SuccessDataResult(string message):base(default,true,message) 20 | { 21 | 22 | } 23 | 24 | public SuccessDataResult():base(default,true) 25 | { 26 | 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Core/Utilities/Results/Concrete/SuccessResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results.Concrete 6 | { 7 | public class SuccessResult : Result 8 | { 9 | public SuccessResult(string message):base(true,message) 10 | { 11 | 12 | } 13 | 14 | public SuccessResult() : base(true) 15 | { 16 | 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Core/Utilities/Security/Encryption/SecurityKeyHelper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.IdentityModel.Tokens; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Utilities.Security.Encryption 7 | { 8 | public class SecurityKeyHelper 9 | { 10 | public static SecurityKey CreateSecurityKey(string securityKey) 11 | { 12 | return new SymmetricSecurityKey(Encoding.UTF8.GetBytes(securityKey)); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Core/Utilities/Security/Encryption/SigningCredentialsHelper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.IdentityModel.Tokens; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Utilities.Security.Encryption 7 | { 8 | public class SigningCredentialsHelper 9 | { 10 | public static SigningCredentials CreateSigningCredentials(SecurityKey securityKey) 11 | { 12 | return new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha512Signature); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Core/Utilities/Security/Hashing/HashingHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Security.Hashing 6 | { 7 | public class HashingHelper 8 | { 9 | public static void CreatePasswordHash(string password, out byte[] paswordHash, out byte[] passwordSalt) 10 | { 11 | using (var hmac = new System.Security.Cryptography.HMACSHA512()) 12 | { 13 | passwordSalt = hmac.Key; 14 | paswordHash = hmac.ComputeHash(Encoding.UTF8.GetBytes(password)); 15 | } 16 | } 17 | 18 | public static bool VerifyPasswordHash(string password, byte[] paswordHash, byte[] passwordSalt) 19 | { 20 | using (var hmac = new System.Security.Cryptography.HMACSHA512(passwordSalt)) 21 | { 22 | var computedHash = hmac.ComputeHash(Encoding.UTF8.GetBytes(password)); 23 | for (int i = 0; i < computedHash.Length; i++) 24 | { 25 | if (computedHash[i]!=paswordHash[i]) 26 | { 27 | return false; 28 | } 29 | } 30 | return true; 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Core/Utilities/Security/JWT/AccessToken.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Security.JWT 6 | { 7 | public class AccessToken 8 | { 9 | public string Token { get; set; } 10 | public DateTime Expiration { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Core/Utilities/Security/JWT/ITokenHelper.cs: -------------------------------------------------------------------------------- 1 | using Entities.Concrete; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Utilities.Security.JWT 7 | { 8 | public interface ITokenHelper 9 | { 10 | AccessToken CreateToken(User user, List operationClaims); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Core/Utilities/Security/JWT/JwtHelper.cs: -------------------------------------------------------------------------------- 1 | using Core.Extensions; 2 | using Core.Utilities.Security.Encryption; 3 | using Entities.Concrete; 4 | using Microsoft.Extensions.Configuration; 5 | using Microsoft.IdentityModel.Tokens; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.IdentityModel.Tokens.Jwt; 9 | using System.Linq; 10 | using System.Security.Claims; 11 | using System.Text; 12 | 13 | namespace Core.Utilities.Security.JWT 14 | { 15 | public class JwtHelper : ITokenHelper 16 | { 17 | public IConfiguration Configuration { get; } 18 | private TokenOptions _tokenOptions; 19 | private DateTime _accessTokenExpiration; 20 | public JwtHelper(IConfiguration configuration) 21 | { 22 | Configuration = configuration; 23 | _tokenOptions = Configuration.GetSection("TokenOptions").Get(); 24 | 25 | } 26 | public AccessToken CreateToken(User user, List operationClaims) 27 | { 28 | _accessTokenExpiration = DateTime.Now.AddMinutes(_tokenOptions.AccessTokenExpiration); 29 | var securityKey = SecurityKeyHelper.CreateSecurityKey(_tokenOptions.SecurityKey); 30 | var signingCredentials = SigningCredentialsHelper.CreateSigningCredentials(securityKey); 31 | var jwt = CreateJwtSecurityToken(_tokenOptions, user, signingCredentials, operationClaims); 32 | var jwtSecurityTokenHandler = new JwtSecurityTokenHandler(); 33 | var token = jwtSecurityTokenHandler.WriteToken(jwt); 34 | 35 | return new AccessToken 36 | { 37 | Token = token, 38 | Expiration = _accessTokenExpiration 39 | }; 40 | 41 | } 42 | 43 | public JwtSecurityToken CreateJwtSecurityToken(TokenOptions tokenOptions, User user, 44 | SigningCredentials signingCredentials, List operationClaims) 45 | { 46 | var jwt = new JwtSecurityToken( 47 | issuer: tokenOptions.Issuer, 48 | audience: tokenOptions.Audience, 49 | expires: _accessTokenExpiration, 50 | notBefore: DateTime.Now, 51 | claims: SetClaims(user, operationClaims), 52 | signingCredentials: signingCredentials 53 | ); 54 | return jwt; 55 | } 56 | 57 | private IEnumerable SetClaims(User user, List operationClaims) 58 | { 59 | var claims = new List(); 60 | claims.AddNameIdentifier(user.Id.ToString()); 61 | claims.AddEmail(user.Email); 62 | claims.AddName($"{user.FirstName} {user.LastName}"); 63 | claims.AddRoles(operationClaims.Select(c => c.Name).ToArray()); 64 | 65 | return claims; 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Core/Utilities/Security/JWT/TokenOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Security.JWT 6 | { 7 | public class TokenOptions 8 | { 9 | public string Audience { get; set; } 10 | public string Issuer { get; set; } 11 | public int AccessTokenExpiration { get; set; } 12 | public string SecurityKey { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /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.Linq.Expressions; 7 | using System.Text; 8 | 9 | namespace DataAccess.Abstract 10 | { 11 | public interface ICarDal:IEntityRepository 12 | { 13 | List GetCarDetails(Expression> filter = null); 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /DataAccess/Abstract/ICarImageDal.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 ICarImageDal: IEntityRepository 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /DataAccess/Abstract/IColorDal.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 IColorDal:IEntityRepository 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /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.Linq.Expressions; 7 | using System.Text; 8 | 9 | namespace DataAccess.Abstract 10 | { 11 | public interface ICustomerDal:IEntityRepository 12 | { 13 | List GetCustomerDetails(Expression> filter = null); 14 | 15 | CustomerDetailDto GetByEmail(Expression> filter = null); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /DataAccess/Abstract/IPaymentDal.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 IPaymentDal:IEntityRepository 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /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.Linq.Expressions; 7 | using System.Text; 8 | 9 | namespace DataAccess.Abstract 10 | { 11 | public interface IRentalDal:IEntityRepository 12 | { 13 | List GetRentalDetails(Expression> filter = null); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /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 | List GetClaims(User user); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /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 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(Expression> filter = null) 17 | { 18 | using (ReCapDbContext context=new ReCapDbContext()) 19 | { 20 | IQueryable result = 21 | from car in filter is null ? context.Cars : context.Cars.Where(filter) 22 | join brand in context.Brands 23 | on car.BrandId equals brand.BrandId 24 | join color in context.Colors 25 | on car.ColorId equals color.ColorId 26 | select new CarDetailDto { 27 | Id=car.Id, 28 | BrandName = brand.BrandName, 29 | ColorName = color.ColorName, 30 | DailyPrice = car.DailyPrice, 31 | Description=car.Description, 32 | ModelYear=car.ModelYear, 33 | BrandId=brand.BrandId, 34 | ColorId=color.ColorId, 35 | ImagePath=(from i in context.CarImages where i.CarId==car.Id select i.ImagePath).FirstOrDefault(), 36 | FindexPoint=car.FindexPoint 37 | }; 38 | 39 | return result.ToList(); 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfCarImageDal.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 EfCarImageDal: EfEntityRepositoryBase, ICarImageDal 11 | { 12 | /*public CarImage GetImageMin(int carId) 13 | { 14 | using (RecapContext recapContext = new RecapContext()) 15 | { 16 | var Image = (from carImage in recapContext.CarImages where carImage.CarId == carId select carImage).FirstOrDefault(); 17 | return Image; 18 | } 19 | 20 | }*/ 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /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 Entities.DTOs; 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 EfCustomerDal:EfEntityRepositoryBase,ICustomerDal 14 | { 15 | public List GetCustomerDetails(Expression> filter = null) 16 | { 17 | using (ReCapDbContext context = new ReCapDbContext()) 18 | { 19 | var result = from customer in filter == null ? context.Customers : context.Customers.Where(filter) 20 | join user in context.Users 21 | on customer.UserId equals user.Id 22 | select new CustomerDetailDto 23 | { 24 | CustomerId = customer.Id, 25 | UserId = user.Id, 26 | CompanyName = customer.CompanyName, 27 | Email = user.Email, 28 | FirstName = user.FirstName, 29 | LastName = user.LastName, 30 | Status = user.Status, 31 | FindexPoint=customer.FindexPoint 32 | }; 33 | return result.ToList(); 34 | 35 | } 36 | } 37 | 38 | public CustomerDetailDto GetByEmail(Expression> filter = null) 39 | { 40 | using (ReCapDbContext context = new ReCapDbContext()) 41 | { 42 | var result = from customer in context.Customers 43 | join user in context.Users 44 | on customer.UserId equals user.Id 45 | select new CustomerDetailDto 46 | { 47 | CustomerId = customer.Id, 48 | UserId = user.Id, 49 | FirstName = user.FirstName, 50 | LastName = user.LastName, 51 | Email = user.Email, 52 | CompanyName = customer.CompanyName, 53 | FindexPoint = customer.FindexPoint 54 | }; 55 | return result.SingleOrDefault(filter); 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfPaymentDal.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 EfPaymentDal: EfEntityRepositoryBase, IPaymentDal 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfRentalDal.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 EfRentalDal : EfEntityRepositoryBase, IRentalDal 15 | { 16 | public List GetRentalDetails(Expression> filter = null) 17 | { 18 | using (ReCapDbContext context = new ReCapDbContext()) 19 | { 20 | var result = from rental in filter == null ? 21 | context.Rentals : context.Rentals.Where(filter) 22 | join car in context.Cars 23 | on rental.CarId equals car.Id 24 | join customer in context.Customers 25 | on rental.CustomerId equals customer.Id 26 | join user in context.Users 27 | on customer.UserId equals user.Id 28 | join brand in context.Brands 29 | on car.BrandId equals brand.BrandId 30 | join color in context.Colors 31 | on car.ColorId equals color.ColorId 32 | select new RentalDetailDto 33 | { 34 | Id=rental.Id, 35 | CarId = car.Id, 36 | BrandName = brand.BrandName, 37 | ColorName = color.ColorName, 38 | CustomerId=customer.Id, 39 | CustomerFirstName=user.FirstName, 40 | CustomerLastName = user.LastName, 41 | CompanyName=customer.CompanyName, 42 | CarModelYear=car.ModelYear, 43 | CarDailyPrice=car.DailyPrice, 44 | CarDescription=car.Description, 45 | ReturnDate = rental.ReturnDate, 46 | RentDate=rental.RentDate 47 | }; 48 | 49 | return result.ToList(); 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /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 | using System.Linq; 8 | 9 | namespace DataAccess.Concrete.EntityFramework 10 | { 11 | public class EfUserDal:EfEntityRepositoryBase,IUserDal 12 | { 13 | public List GetClaims(User user) 14 | { 15 | using (var context = new ReCapDbContext()) 16 | { 17 | var result = from operationClaim in context.OperationClaims 18 | join userOperationClaim in context.UserOperationClaims 19 | on operationClaim.Id equals userOperationClaim.OperationClaimId 20 | where userOperationClaim.UserId == user.Id 21 | select new OperationClaim 22 | { 23 | Id = operationClaim.Id, 24 | Name = operationClaim.Name 25 | }; 26 | return result.ToList(); 27 | 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/ReCapDbContext.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 ReCapDbContext:DbContext 10 | { 11 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 12 | { 13 | optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=ReCapDb;Trusted_Connection=true"); 14 | } 15 | public DbSet Cars { get; set; } 16 | public DbSet Colors { get; set; } 17 | public DbSet Brands { get; set; } 18 | public DbSet Customers { get; set; } 19 | public DbSet Users { get; set; } 20 | public DbSet Rentals { get; set; } 21 | public DbSet CarImages { get; set; } 22 | public DbSet OperationClaims { get; set; } 23 | public DbSet UserOperationClaims { get; set; } 24 | public DbSet Payments { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 | List _brands; 16 | List _colors; 17 | 18 | public InMemoryCarDal() 19 | { 20 | _brands = new List 21 | { 22 | new Brand{BrandId=1, BrandName="Alfa Romeo"}, 23 | new Brand{BrandId=2, BrandName="Audi"}, 24 | new Brand{BrandId=3, BrandName="Ferrari"}, 25 | new Brand{BrandId=4, BrandName="BMW"}, 26 | new Brand{BrandId=5, BrandName="Porsche"} 27 | }; 28 | 29 | _colors = new List 30 | { 31 | new Color{ColorId=1, ColorName="Black"}, 32 | new Color{ColorId=2, ColorName="White"}, 33 | new Color{ColorId=3, ColorName="Red"}, 34 | new Color{ColorId=4, ColorName="Grey"}, 35 | new Color{ColorId=5, ColorName="Blue"} 36 | }; 37 | 38 | _cars = new List 39 | { 40 | new Car{Id=1, BrandId=1, ColorId=2, ModelYear=2014, DailyPrice=300, Description="Fena değil"}, 41 | new Car{Id=2, BrandId=1, ColorId=2, ModelYear=2015, DailyPrice=320, Description="Fena değil"}, 42 | new Car{Id=3, BrandId=2, ColorId=2, ModelYear=2019, DailyPrice=390, Description="Bebek gibi"}, 43 | new Car{Id=4, BrandId=3, ColorId=2, ModelYear=2021, DailyPrice=850, Description="Adrenalin dolu bi yaşam"}, 44 | new Car{Id=5, BrandId=4, ColorId=2, ModelYear=2018, DailyPrice=470, Description="Havalı bir araba"}, 45 | new Car{Id=6, BrandId=5, ColorId=2, ModelYear=2017, DailyPrice=600, Description="Zorluklara karşı diren"}, 46 | new Car{Id=7, BrandId=4, ColorId=2, ModelYear=2016, DailyPrice=430, Description="Havalı bir araba"}, 47 | new Car{Id=8, BrandId=5, ColorId=2, ModelYear=2020, DailyPrice=680, Description="Zorluklara karşı diren"} 48 | }; 49 | } 50 | 51 | public void Add(Car car) 52 | { 53 | _cars.Add(car); 54 | Console.WriteLine("Yeni araba eklendi : " + car.Description); 55 | } 56 | 57 | public void Delete(Car car) 58 | { 59 | Car carToDelete = _cars.SingleOrDefault(c => c.Id == car.Id); 60 | _cars.Remove(carToDelete); 61 | Console.WriteLine("Araba silme işlemi tamamlandı"); 62 | } 63 | 64 | public Car Get(Expression> filter) 65 | { 66 | throw new NotImplementedException(); 67 | } 68 | 69 | public List GetAll() 70 | { 71 | return _cars; 72 | } 73 | 74 | public List GetAll(Expression> filter = null) 75 | { 76 | throw new NotImplementedException(); 77 | } 78 | 79 | public List GetCarDetails(Expression> filter = null) 80 | { 81 | throw new NotImplementedException(); 82 | } 83 | 84 | public void Update(Car car) 85 | { 86 | Car carToUpdate = _cars.SingleOrDefault(c => c.Id == car.Id); 87 | carToUpdate.Id = car.Id; 88 | carToUpdate.BrandId = car.BrandId; 89 | carToUpdate.ColorId = car.ColorId; 90 | carToUpdate.ModelYear = car.ModelYear; 91 | carToUpdate.DailyPrice = car.DailyPrice; 92 | carToUpdate.Description = car.Description; 93 | Console.WriteLine("Araba bilgileri güncellendi :" + carToUpdate.Description); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /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 Core.Entities.Abstract; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Entities.Concrete 8 | { 9 | public class Brand:IEntity 10 | { 11 | public int BrandId { get; set; } 12 | public string BrandName { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Entities/Concrete/Car.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using Core.Entities.Abstract; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Entities.Concrete 8 | { 9 | public class Car:IEntity 10 | { 11 | public int Id { get; set; } 12 | public int BrandId { get; set; } 13 | public int ColorId { get; set; } 14 | public int ModelYear { get; set; } 15 | public decimal DailyPrice { get; set; } 16 | public string Description { get; set; } 17 | public int FindexPoint { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Entities/Concrete/CarImage.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using Core.Entities.Abstract; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Entities.Concrete 8 | { 9 | public class CarImage:IEntity 10 | { 11 | public int Id { get; set; } 12 | public int CarId { get; set; } 13 | public string ImagePath { get; set; } 14 | public DateTime? Date { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Entities/Concrete/Color.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using Core.Entities.Abstract; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Entities.Concrete 8 | { 9 | public class Color:IEntity 10 | { 11 | public int ColorId { get; set; } 12 | public string ColorName { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Entities/Concrete/Customer.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using Core.Entities.Abstract; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Entities.Concrete 8 | { 9 | public class Customer:IEntity 10 | { 11 | public int Id { get; set; } 12 | public int UserId { get; set; } 13 | public string CompanyName { get; set; } 14 | public int FindexPoint { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Entities/Concrete/Payment.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class Payment:IEntity 9 | { 10 | public int PaymentId { get; set; } 11 | public int CustomerId { get; set; } 12 | public string CardNameSurname { get; set; } 13 | public string CardNumber { get; set; } 14 | public string CardCvv { get; set; } 15 | public string CardExpiryDate { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Entities/Concrete/Rental.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using Core.Entities.Abstract; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Entities.Concrete 8 | { 9 | public class Rental:IEntity 10 | { 11 | public int Id { get; set; } 12 | public int CarId { get; set; } 13 | public int CustomerId { get; set; } 14 | public DateTime RentDate { get; set; } 15 | public DateTime? ReturnDate { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Entities/DTOs/CarDetailDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using Core.Entities.Abstract; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Entities.DTOs 8 | { 9 | public class CarDetailDto:IDto 10 | { 11 | public int Id { get; set; } 12 | public string BrandName { get; set; } 13 | public string ColorName { get; set; } 14 | public decimal DailyPrice { get; set; } 15 | public string Description { get; set; } 16 | public int ModelYear { get; set; } 17 | public string ImagePath { get; set; } 18 | public int BrandId { get; set; } 19 | public int ColorId { get; set; } 20 | public int FindexPoint { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Entities/DTOs/CustomerDetailDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.DTOs 7 | { 8 | public class CustomerDetailDto:IDto 9 | { 10 | public int CustomerId { get; set; } 11 | public int UserId { get; set; } 12 | public string CompanyName { get; set; } 13 | public string FirstName { get; set; } 14 | public string LastName { get; set; } 15 | public string Email { get; set; } 16 | public bool Status { get; set; } 17 | public int FindexPoint { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Entities/DTOs/RentalDetailDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using Core.Entities.Abstract; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Entities.DTOs 8 | { 9 | public class RentalDetailDto:IDto 10 | { 11 | public int Id { get; set; } 12 | public int CarId { get; set; } 13 | public int CustomerId { get; set; } 14 | public string CustomerFirstName { get; set; } 15 | public string CustomerLastName { get; set; } 16 | public string BrandName { get; set; } 17 | public string ColorName { get; set; } 18 | public string CompanyName { get; set; } 19 | public int CarModelYear { get; set; } 20 | public decimal CarDailyPrice { get; set; } 21 | public string CarDescription { get; set; } 22 | public DateTime RentDate { get; set; } 23 | public DateTime? ReturnDate { get; set; } 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Entities/DTOs/UserForLoginDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.DTOs 7 | { 8 | public class UserForLoginDto : IDto 9 | { 10 | public string Email { get; set; } 11 | public string Password { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Entities/DTOs/UserForRegisterDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Abstract; 2 | 3 | namespace Entities.DTOs 4 | { 5 | public class UserForRegisterDto : IDto 6 | { 7 | public string Email { get; set; } 8 | public string Password { get; set; } 9 | public string FirstName { get; set; } 10 | public string LastName { get; set; } 11 | public string CompanyName { get; set; } 12 | public int FindexPoint { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Entities/DTOs/UserForUpdateDto .cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.DTOs 7 | { 8 | public class UserForUpdateDto:UserForRegisterDto,IDto 9 | { 10 | public int CustomerId { get; set; } 11 | public int UserId { get; set; } 12 | public int FindexPoint { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Entities/Entities.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | bcac8e2b-9b5a-4db3-93c5-7e50a9701c2b 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Sahil Rzayev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # *Car Rental Backend* :oncoming_automobile: :key: 2 | --- 3 | ![a+l](https://user-images.githubusercontent.com/58303745/115148240-bf865d00-a06f-11eb-8b97-ef5cfe732973.png) 4 | --- 5 | --- 6 | ## Contact Me 📫 7 | - [![Gmail Badge](https://img.shields.io/badge/Gmail-D14836?style=for-the-badge&logo=gmail&logoColor=white)](sahilrzayev200d@gmail.com) sahilrzayev200d@gmail.com 8 | - [![Linkedin Badge](https://img.shields.io/badge/sahilrzayev-follow%20on%20linkedin-blue?style=for-the-badge&logo=linkedin)](https://www.linkedin.com/in/sahilrzayev) 9 | --- 10 | --- 11 | --- 12 | **Bu proje _Araba Kiralama Sistemi_ ile ilgili bir projedir.Proje hem Çok katmanlı, hem Kurumsal Mimariler, hem de SOLID prensiplerine dayalı bir projedir.Önümüzdeki süreçlerde de projeye eklemeler yapılarak daha güzel bir proje haline getirilecektir.Kampda verilen adımlara uygun olarak gerçeklekleştirdiğim bu projeyi yakından inceleyelim.** 13 | --- 14 | --- 15 | --- 16 | 17 | # Katmanlar 18 | * ### Öncelikle Proje 6 katmandan oluşmaktadır: Business, DataAccess, Entities, ConcoleUI, Core, WebAPI 19 | ![katmanlar](https://user-images.githubusercontent.com/58303745/115146995-0bce9e80-a06a-11eb-9373-54860d150a44.jpg) 20 | --- 21 | ### 1._Business Katmanı_- Burada işle ilgili(iş kuralları) kodlar yer alır.Bu katman Abstract ve Concrete isimli klasörlerden oluşur.Abstract içinde soyut(yani interfaceler), Concrete içinde somut(yani class'lar) nesneler yer alır. 22 | 23 | ![business](https://user-images.githubusercontent.com/58303745/115147010-17ba6080-a06a-11eb-8fd3-8518254dfef7.png) 24 | * Sarı kutucuk - *NuGet paketi* --> Başkalarının yazdığı kodları(paket diyoruz) kullanıyoruz.Bu kodların ortak tutulduğu ve yönetildiği ortamın adına denir. 25 | * Kırmızı kutucuk - Business katmanının referans aldığı katmanlar 26 | * Yeşil kutucuk - Abstract klasörü içinde yer alan _interface'ler_ 27 | * Mavi kutucuk - Abstract klasörü içindeki interface'lerin implemente edildiği yer 28 | --- 29 | ### 2._DataAccess Katmanı_- Veriye erişmek için gerekli kodlar yazılan bu katman Abstract(soyut) ve Concrete(somut) isimli klasörlerden oluşur. 30 | 31 | ![dataaccess](https://user-images.githubusercontent.com/58303745/115146973-f8233800-a069-11eb-82f1-4752640737db.png) 32 | * Kırmızı kutucuk - DataAccess katmanının referans aldığı katmanlar 33 | * Yeşil kutucuk - Abstract klasörü içinde yer alan _interface'ler_ 34 | * Mavi kutucuk - Abstract klasörü içindeki interface'lerin implemente edildiği yer.Aynı zamanda burda _IEntityFramework_ isimli klasörde biz veri tabanı nesneleriyle(kısaca tablolarla) yazdığımız kodlar arasında bağ kuruyoruz. 35 | > _EntityFramework_ --> Veri tabanı tablolarıyla Nesne Yönelimli Programlama(OOP) arasında bir köprüdür. 36 | * Sarı kutucuk - *NuGet paketi* --> Başkalarının yazdığı kodları(paket diyoruz) kullanıyoruz.Bu kodların ortak tutulduğu ve yönetildiği ortamın adına denir. 37 | --- 38 | ### 3._Entities Katmanı_ - Veri tabanı nesneleri için oluşturulmuş olan bu katman Abstract(soyut) ve Concrete(somut) isimli klasörlerden oluşur. 39 | ![entities](https://user-images.githubusercontent.com/58303745/115147407-e04cb380-a06b-11eb-9a47-6df5a980714f.png) 40 | * Sarı kutucuk - *NuGet paketi* --> Başkalarının yazdığı kodları(paket diyoruz) kullanıyoruz.Bu kodların ortak tutulduğu ve yönetildiği ortamın adına denir. 41 | * Mavi kutucuk - Abstract klasörü içindeki interface'lerin implemente edildiği yer 42 | --- 43 | ### 4._ConsoleUI Katmanı_ - Yaptığımız işlemlerin sonuçlarını göreceğimiz bir katman 44 | ![consoleui](https://user-images.githubusercontent.com/58303745/115147011-1852f700-a06a-11eb-988e-51fc72e20ef9.png) 45 | * Kırmızı kutucuk - ConsoleUI katmanının referans aldığı katmanlar 46 | * Turuncu kutucuk - Bura main kısmıdır.Yani en sonda uyguladığımız işlemlerin sonucunu buradan görüyoruz. 47 | --- 48 | ### 5._Core Katmanı_ - Yaptığımız işlemlerin sonuçlarını göreceğimiz bir katman 49 | ![core](https://user-images.githubusercontent.com/58303745/115147012-18eb8d80-a06a-11eb-9c94-ccb7fe4f67bd.jpg) 50 | --- 51 | ### 6._WebAPI Katmanı_ - Yaptığımız işlemlerin sonuçlarını göreceğimiz bir katman 52 | ![webapi](https://user-images.githubusercontent.com/58303745/115147008-14bf7000-a06a-11eb-9adb-e7375dc23bc3.jpg) 53 | --- 54 | --- 55 | --- 56 | # Database and Tables 57 | * Bir database(veri tabanı) oluşturmak için: 58 | ``` 59 | CREATE DATABASE ReCapDb 60 | ``` 61 | ![1 2](https://user-images.githubusercontent.com/58303745/107301788-9a84d500-6a95-11eb-9104-823c84c307bb.jpg) 62 | --- 63 | --- 64 | 65 | * Tabloları oluşturmak için: 66 | _ReCapDb --> Sağ CLick --> New Query_ 67 | ``` 68 | Create table Brands( 69 | BrandId int Primary key, 70 | BrandName varchar(50) 71 | ) 72 | 73 | 74 | Create table Colors( 75 | ColorId int Primary key, 76 | ColorName varchar(20) 77 | ) 78 | 79 | 80 | 81 | Create table Cars( 82 | Id int Primary key identity, 83 | BrandId int, 84 | ColorId int, 85 | ModelYear int, 86 | DailyPrice decimal, 87 | Descriptions varchar(200), 88 | Foreign key(ColorId) References Colors(ColorId), 89 | Foreign key(BrandId) References Brands(BrandId) 90 | ) 91 | ``` 92 | 93 | _DİKKAT!!! **nvarcahr** yerine **varchar** kullanmak daha performanslı.Çünkü **varchar** kullanmadığımız karakter alanlarını boş bıraktığı halde, **nvarchar** onu boşluklarla doldurarak ekstradan bellek kaplamasına sebep oluyor_ 94 | 95 | ![d1](https://user-images.githubusercontent.com/58303745/107303009-aec9d180-6a97-11eb-844d-0654e9d87005.jpg) 96 | --- 97 | --- 98 | * Tabloya veri eklemek için: 99 | _ReCapDb --> Sağ CLick --> New Query_ 100 | ``` 101 | Insert into Brands(BrandId,BrandName) values (1,'Audi'),(2,'BMW'),(3,'Hyundai'),(4,'Mitsubishi'),(5,'Nissan'),(6,'Mazda'),(7,'Porsche'); 102 | 103 | Insert into Colors(ColorId,ColorName) values (1,'Black'),(2,'White'),(3,'Silver'),(4,'Blue'),(5,'Red'),(6,'Brown'),(7,'Green'); 104 | 105 | Insert into Cars(BrandId,ColorId,ModelYear,DailyPrice,Description) values 106 | (1,5,'2020',450,'AUDI Q8 - Red'), 107 | (2,2,'2018',370,'BMW 2 Gran Coupé - White'), 108 | (3,4,'2015',250,'HYUNDAI i10 - Blue'), 109 | (4,7,'2016',290,'Mitsubishi Outlander - Green'), 110 | (5,6,'2017',350,'NISSAN QASHQAI - Brown'), 111 | (6,3,'2019',630,'MAZDA CX-5 - Silver'), 112 | (7,1,'2021',720,'PORSCHE P911 Turbo S - Black'); 113 | ``` 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /ReCapProject.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31005.135 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataAccess", "DataAccess\DataAccess.csproj", "{CC558892-D180-49EF-9223-D0DDAC93C51E}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Business", "Business\Business.csproj", "{FEB94264-A88E-40FE-A546-BA637A41278D}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Entities", "Entities\Entities.csproj", "{F0C13930-6368-4E28-8D6C-EB3DCBDCAE61}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleUI", "ConsoleUI\ConsoleUI.csproj", "{9CF98EBB-DCB2-4BDF-A12E-A2E07BE659FD}" 13 | EndProject 14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core", "Core\Core.csproj", "{B3423F01-C653-4CEF-8670-C64A0E55504B}" 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAPI", "WebAPI\WebAPI.csproj", "{414526E6-20A4-48C3-BE6C-2AECD0782DCF}" 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 | {CC558892-D180-49EF-9223-D0DDAC93C51E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {CC558892-D180-49EF-9223-D0DDAC93C51E}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {CC558892-D180-49EF-9223-D0DDAC93C51E}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {CC558892-D180-49EF-9223-D0DDAC93C51E}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {FEB94264-A88E-40FE-A546-BA637A41278D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {FEB94264-A88E-40FE-A546-BA637A41278D}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {FEB94264-A88E-40FE-A546-BA637A41278D}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {FEB94264-A88E-40FE-A546-BA637A41278D}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {F0C13930-6368-4E28-8D6C-EB3DCBDCAE61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {F0C13930-6368-4E28-8D6C-EB3DCBDCAE61}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {F0C13930-6368-4E28-8D6C-EB3DCBDCAE61}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {F0C13930-6368-4E28-8D6C-EB3DCBDCAE61}.Release|Any CPU.Build.0 = Release|Any CPU 36 | {9CF98EBB-DCB2-4BDF-A12E-A2E07BE659FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 37 | {9CF98EBB-DCB2-4BDF-A12E-A2E07BE659FD}.Debug|Any CPU.Build.0 = Debug|Any CPU 38 | {9CF98EBB-DCB2-4BDF-A12E-A2E07BE659FD}.Release|Any CPU.ActiveCfg = Release|Any CPU 39 | {9CF98EBB-DCB2-4BDF-A12E-A2E07BE659FD}.Release|Any CPU.Build.0 = Release|Any CPU 40 | {B3423F01-C653-4CEF-8670-C64A0E55504B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 41 | {B3423F01-C653-4CEF-8670-C64A0E55504B}.Debug|Any CPU.Build.0 = Debug|Any CPU 42 | {B3423F01-C653-4CEF-8670-C64A0E55504B}.Release|Any CPU.ActiveCfg = Release|Any CPU 43 | {B3423F01-C653-4CEF-8670-C64A0E55504B}.Release|Any CPU.Build.0 = Release|Any CPU 44 | {414526E6-20A4-48C3-BE6C-2AECD0782DCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 45 | {414526E6-20A4-48C3-BE6C-2AECD0782DCF}.Debug|Any CPU.Build.0 = Debug|Any CPU 46 | {414526E6-20A4-48C3-BE6C-2AECD0782DCF}.Release|Any CPU.ActiveCfg = Release|Any CPU 47 | {414526E6-20A4-48C3-BE6C-2AECD0782DCF}.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 = {2674BBD5-E03F-45B1-B3AB-553220688F64} 54 | EndGlobalSection 55 | EndGlobal 56 | -------------------------------------------------------------------------------- /SQLQuery1.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE Users( 2 | Id INT PRIMARY KEY IDENTITY(1,1), 3 | FirstName VARCHAR(50), 4 | LastName VARCHAR(50), 5 | Email VARCHAR(50) UNIQUE, 6 | Password VARCHAR(50) 7 | ) 8 | 9 | CREATE TABLE Customers( 10 | Id INT PRIMARY KEY IDENTITY(1,1), 11 | UserId INT, 12 | CompanyName VARCHAR(50), 13 | FOREIGN KEY (UserId) REFERENCES Users(Id) 14 | ) 15 | 16 | CREATE TABLE Rentals( 17 | Id INT PRIMARY KEY IDENTITY(1,1), 18 | CarId INT, 19 | CustomerId INT, 20 | RentDate DATETIME, 21 | ReturnDate DATETIME, 22 | FOREIGN KEY (CarId) REFERENCES Cars(Id), 23 | FOREIGN KEY (CustomerId) REFERENCES Customers(Id) 24 | ) 25 | 26 | -------------------------------------------------------------------------------- /SQLQuery2.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO Users(FirstName,LastName,Email,Password) VALUES 2 | ('Engin','Demiroğ','engindemirog@gmail.com','123456'), 3 | ('Sahil','Rzayev','sahilrzayev@gmail.com','010203'), 4 | ('Selim','Öztürk','selimozturk@gmail.com','selim123'), 5 | ('Emre','Babacan','emrebabacan@gmail.com','babacan061'), 6 | ('Fariz','Türkoğlu','farizturkoglu@gmail.com','fariz1988'); 7 | 8 | 9 | INSERT INTO Customers(UserId,CompanyName) VALUES 10 | (1,'Audi Otomobil'), 11 | (2,'Hyundai Otomobil'), 12 | (3,'Bmw Otomobil'), 13 | (4,'Nissan Otomobil'), 14 | (5,'Cars otomobil'); 15 | 16 | 17 | INSERT INTO Rentals(CarId,CustomerId,RentDate,ReturnDate) VALUES 18 | (1,1,'2020-12-29 15:00:01','2021-01-05 16:16:05'), 19 | (2,2,'2020-12-30 10:34:09',null), 20 | (3,3,'2020-01-14 14:39:23','2020-01-20 12:02:48'), 21 | (4,4,'2015-11-05 17:45:53',null), 22 | (5,5,'2021-01-12 11:12:38','2021-01-16 18:01:41'); 23 | -------------------------------------------------------------------------------- /SQLQuery3.sql: -------------------------------------------------------------------------------- 1 |  2 | Insert into Cars(BrandId,ColorId,ModelYear,DailyPrice,Description) values 3 | (1,5,'2020',450,'Cömert, şık iç mekân, dokunmatik işletim konsepti ---> AUDI Q8 - Red'), 4 | (2,2,'2018',370,'Hem bir sedan hem bir coupé, hem konforlu hem de sportif ---> BMW 2 Gran Coupé - White'), 5 | (3,4,'2015',250,'Akıcı çizgilere sahip sınıfında eşi benzeri görülmemiş dinamik tasarımlı ---> HYUNDAI i10 - Blue'), 6 | (4,7,'2016',290,'Güçlü motoru, geniş iç hacmi ve güven veren dış görünümüyle ---> Mitsubishi Outlander - Green'), 7 | (5,6,'2017',350,'Rahat ve engeltanımaz ---> NISSAN QASHQAI - Brown'), 8 | (6,3,'2019',630,'Otomobil ve sürücüsünün mükemmel bir uyumu ---> MAZDA CX-5 - Silver'), 9 | (7,1,'2021',720,'Hız ve adrenalin dolu bir macera ---> PORSCHE P911 Turbo S - Black'); -------------------------------------------------------------------------------- /SQLQuery5.sql: -------------------------------------------------------------------------------- 1 | Create table Brands( 2 | BrandId int Primary key, 3 | BrandName varchar(50) 4 | ) 5 | 6 | 7 | Create table Colors( 8 | ColorId int Primary key, 9 | ColorName varchar(20) 10 | ) 11 | 12 | 13 | 14 | Create table Cars( 15 | Id int Primary key identity, 16 | BrandId int, 17 | ColorId int, 18 | ModelYear varchar(5), 19 | DailyPrice decimal, 20 | Descriptions varchar(200), 21 | Foreign key(ColorId) References Colors(ColorId), 22 | Foreign key(BrandId) References Brands(BrandId) 23 | ) -------------------------------------------------------------------------------- /SQLQuery7.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE CarImages( 2 | Id int Primary key identity, 3 | CarId int, 4 | ImagePath varchar(200), 5 | Dates DATETIME, 6 | FOREIGN KEY (CarId) REFERENCES Cars(Id), 7 | 8 | ) -------------------------------------------------------------------------------- /WebAPI/Controllers/AuthController.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Entities.DTOs; 3 | using Microsoft.AspNetCore.Mvc; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebAPI.Controllers 10 | { 11 | [Route("api/[controller]")] 12 | [ApiController] 13 | public class AuthController : Controller 14 | { 15 | private IAuthService _authService; 16 | private IUserService _userService; 17 | 18 | public AuthController(IAuthService authService,IUserService userService) 19 | { 20 | _authService = authService; 21 | _userService = userService; 22 | } 23 | 24 | [HttpPost("login")] 25 | public ActionResult Login(UserForLoginDto userForLoginDto) 26 | { 27 | var userToLogin = _authService.Login(userForLoginDto); 28 | if (!userToLogin.Success) 29 | { 30 | return BadRequest(userToLogin.Message); 31 | } 32 | 33 | var result = _authService.CreateAccessToken(userToLogin.Data); 34 | if (result.Success) 35 | { 36 | return Ok(result); 37 | } 38 | 39 | return BadRequest(result.Message); 40 | } 41 | 42 | [HttpPost("register")] 43 | public ActionResult Register(UserForRegisterDto userForRegisterDto) 44 | { 45 | var userExists = _authService.UserExists(userForRegisterDto.Email); 46 | if (!userExists.Success) 47 | { 48 | return BadRequest(userExists.Message); 49 | } 50 | 51 | var registerResult = _authService.Register(userForRegisterDto, userForRegisterDto.Password); 52 | var result = _authService.CreateAccessToken(registerResult.Data); 53 | if (result.Success) 54 | { 55 | return Ok(result); 56 | } 57 | 58 | return BadRequest(result.Message); 59 | } 60 | 61 | [HttpPost("update")] 62 | public ActionResult Update(UserForUpdateDto userForUpdate) 63 | { 64 | _authService.Update(userForUpdate); 65 | 66 | var user = _userService.GetById(userForUpdate.UserId); 67 | var result = _authService.CreateAccessToken(user.Data); 68 | 69 | if (result.Success) 70 | { 71 | return Ok(result); 72 | } 73 | return BadRequest(result.Message); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /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 | 23 | [HttpGet("getall")] 24 | public IActionResult GetAll() 25 | { 26 | var result = _brandService.GetAll(); 27 | if (result.Success) 28 | { 29 | return Ok(result); 30 | } 31 | return BadRequest(result); 32 | } 33 | 34 | [HttpGet("getbyid")] 35 | public IActionResult GetById(int id) 36 | { 37 | var result = _brandService.GetById(id); 38 | if (result.Success) 39 | { 40 | return Ok(result); 41 | } 42 | return BadRequest(result); 43 | } 44 | 45 | [HttpPost("add")] 46 | public IActionResult Add(Brand brand) 47 | { 48 | var result = _brandService.Add(brand); 49 | if (result.Success) 50 | { 51 | return Ok(result); 52 | } 53 | return BadRequest(result); 54 | } 55 | 56 | [HttpPost("delete")] 57 | public IActionResult Delete(Brand brand) 58 | { 59 | var result = _brandService.Delete(brand); 60 | if (result.Success) 61 | { 62 | return Ok(result); 63 | } 64 | return BadRequest(result); 65 | } 66 | 67 | [HttpPost("update")] 68 | public IActionResult Update(Brand brand) 69 | { 70 | var result = _brandService.Update(brand); 71 | if (result.Success) 72 | { 73 | return Ok(result); 74 | } 75 | return BadRequest(result); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /WebAPI/Controllers/CarImagesController.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 CarImagesController : ControllerBase 15 | { 16 | ICarImageService _carImageService; 17 | 18 | public CarImagesController(ICarImageService carImageService) 19 | { 20 | _carImageService = carImageService; 21 | } 22 | 23 | [HttpGet("getall")] 24 | public IActionResult GetAll() 25 | { 26 | var result = _carImageService.GetAll(); 27 | if (result.Success) 28 | { 29 | return Ok(result); 30 | } 31 | return BadRequest(result); 32 | } 33 | 34 | [HttpGet("getbyid")] 35 | public IActionResult GetById([FromForm(Name = ("Id"))] int Id) 36 | { 37 | var result = _carImageService.Get(Id); 38 | if (result.Success) 39 | { 40 | return Ok(result); 41 | } 42 | return BadRequest(result); 43 | } 44 | 45 | [HttpGet("getimagesbycarid")] 46 | public IActionResult GetImagesByCarId(int carId) 47 | { 48 | var result = _carImageService.GetImagesByCarId(carId); 49 | if (result.Success) 50 | { 51 | return Ok(result); 52 | } 53 | return BadRequest(result); 54 | } 55 | 56 | [HttpPost("add")] 57 | public IActionResult Add([FromForm(Name = ("Image"))] IFormFile file, [FromForm] CarImage carImage) 58 | { 59 | var result = _carImageService.Add(file, carImage); 60 | 61 | if (result.Success) 62 | { 63 | return Ok(result); 64 | } 65 | 66 | return BadRequest(result); 67 | } 68 | 69 | 70 | [HttpPost("delete")] 71 | public IActionResult Delete([FromForm(Name = ("Id"))] int Id) 72 | { 73 | 74 | var carImage = _carImageService.Get(Id).Data; 75 | 76 | var result = _carImageService.Delete(carImage); 77 | if (result.Success) 78 | { 79 | return Ok(result); 80 | } 81 | return BadRequest(result); 82 | } 83 | 84 | [HttpPost("update")] 85 | public IActionResult Update([FromForm(Name = ("Image"))] IFormFile file, [FromForm(Name = ("Id"))] int Id) 86 | { 87 | var carImage = _carImageService.Get(Id).Data; 88 | var result = _carImageService.Update(file, carImage); 89 | if (result.Success) 90 | { 91 | return Ok(result); 92 | } 93 | return BadRequest(result); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /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 | 18 | public CarsController(ICarService carService) 19 | { 20 | _carService = carService; 21 | } 22 | 23 | [HttpGet("getall")] 24 | public IActionResult GetAll() 25 | { 26 | var result = _carService.GetAll(); 27 | if (result.Success) 28 | { 29 | return Ok(result); 30 | } 31 | return BadRequest(result); 32 | } 33 | 34 | [HttpGet("getallcardetail")] 35 | public IActionResult GetAllCarDetails() 36 | { 37 | var result = _carService.GetCarDetails(); 38 | if (result.Success) 39 | { 40 | return Ok(result); 41 | } 42 | return BadRequest(result); 43 | } 44 | 45 | [HttpGet("getbyid")] 46 | public IActionResult GetById(int id) 47 | { 48 | var result = _carService.GetById(id); 49 | if (result.Success) 50 | { 51 | return Ok(result.Data); 52 | } 53 | return BadRequest(result.Message); 54 | } 55 | 56 | [HttpGet("getcarsbybrandid")] 57 | public IActionResult GetCarByBrandId(int brandId) 58 | { 59 | var result = _carService.GetCarByBrandId(brandId); 60 | if (result.Success) 61 | { 62 | return Ok(result); 63 | } 64 | return BadRequest(result); 65 | } 66 | 67 | [HttpGet("getcarsbycolorid")] 68 | public IActionResult GetCarByColord(int colorId) 69 | { 70 | var result = _carService.GetCarByColorId(colorId); 71 | if (result.Success) 72 | { 73 | return Ok(result); 74 | } 75 | return BadRequest(result); 76 | } 77 | 78 | [HttpGet("getcarsbydailyprice")] 79 | public IActionResult GetCarByDailyPrice(decimal min,decimal max) 80 | { 81 | var result = _carService.GetCarByDailyPrice(min,max); 82 | if (result.Success) 83 | { 84 | return Ok(result); 85 | } 86 | return BadRequest(result); 87 | } 88 | 89 | [HttpGet("getcardetails")] 90 | public IActionResult GetCarDetails() 91 | { 92 | var result = _carService.GetCarDetails(); 93 | if (result.Success) 94 | { 95 | return Ok(result); 96 | } 97 | return BadRequest(result); 98 | } 99 | 100 | [HttpGet("carlistbrandidcolorid")] 101 | public IActionResult CarListBrandIdColorId(int brandId,int colorId ) 102 | { 103 | var result = _carService.CarListBrandIdColorId(brandId, colorId); 104 | //var results = _carImageService.GetCarDtoImageList(carList.Data); 105 | return Ok(result); 106 | } 107 | 108 | [HttpPost("add")] 109 | public IActionResult Add(Car car) 110 | { 111 | var result = _carService.Add(car); 112 | if (result.Success) 113 | { 114 | return Ok(result); 115 | } 116 | return BadRequest(result); 117 | } 118 | 119 | [HttpPost("delete")] 120 | public IActionResult Delete(Car car) 121 | { 122 | var result = _carService.Delete(car); 123 | if (result.Success) 124 | { 125 | return Ok(result); 126 | } 127 | return BadRequest(result); 128 | } 129 | 130 | [HttpPost("update")] 131 | public IActionResult Update(Car car) 132 | { 133 | var result = _carService.Update(car); 134 | if (result.Success) 135 | { 136 | return Ok(result); 137 | } 138 | return BadRequest(result); 139 | } 140 | 141 | 142 | [HttpGet("getcardetailbycarid")] 143 | public IActionResult GetCarDetailByCarId(int carId) 144 | { 145 | var result = _carService.GetCarDetailByCarId(carId); 146 | if (result.Success) 147 | { 148 | return Ok(result); 149 | } 150 | return BadRequest(result); 151 | } 152 | 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /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 | 23 | [HttpGet("getall")] 24 | public IActionResult GetAll() 25 | { 26 | var result = _colorService.GetAll(); 27 | if (result.Success) 28 | { 29 | return Ok(result); 30 | } 31 | return BadRequest(result); 32 | } 33 | 34 | [HttpGet("getbyid")] 35 | public IActionResult GetById(int id) 36 | { 37 | var result = _colorService.GetById(id); 38 | if (result.Success) 39 | { 40 | return Ok(result); 41 | } 42 | return BadRequest(result); 43 | } 44 | 45 | [HttpPost("add")] 46 | public IActionResult Add(Color color) 47 | { 48 | var result = _colorService.Add(color); 49 | if (result.Success) 50 | { 51 | return Ok(result); 52 | } 53 | return BadRequest(result); 54 | } 55 | 56 | [HttpPost("delete")] 57 | public IActionResult Delete(Color color) 58 | { 59 | var result = _colorService.Delete(color); 60 | if (result.Success) 61 | { 62 | return Ok(result); 63 | } 64 | return BadRequest(result); 65 | } 66 | 67 | [HttpPost("update")] 68 | public IActionResult Update(Color color) 69 | { 70 | var result = _colorService.Update(color); 71 | if (result.Success) 72 | { 73 | return Ok(result); 74 | } 75 | return BadRequest(result); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /WebAPI/Controllers/CustomersController.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Core.Aspects.Autofac.Caching; 3 | using Entities.Concrete; 4 | using Microsoft.AspNetCore.Http; 5 | using Microsoft.AspNetCore.Mvc; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Threading.Tasks; 10 | 11 | namespace WebAPI.Controllers 12 | { 13 | [Route("api/[controller]")] 14 | [ApiController] 15 | public class CustomersController : ControllerBase 16 | { 17 | ICustomerService _customerService; 18 | 19 | public CustomersController(ICustomerService customerService) 20 | { 21 | _customerService = customerService; 22 | } 23 | 24 | [HttpPost("add")] 25 | public IActionResult Add(Customer customer) 26 | { 27 | var result = _customerService.Add(customer); 28 | if (result.Success) 29 | { 30 | return Ok(result); 31 | } 32 | return BadRequest(result.Message); 33 | } 34 | 35 | [HttpDelete("delete")] 36 | public IActionResult Delete(Customer customer) 37 | { 38 | var result = _customerService.Delete(customer); 39 | if (result.Success) 40 | { 41 | return Ok(result); 42 | } 43 | return BadRequest(result.Message); 44 | } 45 | 46 | [HttpPut("update")] 47 | public IActionResult Update(Customer customer) 48 | { 49 | var result = _customerService.Update(customer); 50 | if (result.Success) 51 | { 52 | return Ok(result); 53 | } 54 | return BadRequest(result.Message); 55 | } 56 | 57 | 58 | [HttpGet("getall")] 59 | public IActionResult GetAll() 60 | { 61 | var result = _customerService.GetAll(); 62 | if (result.Success) 63 | { 64 | return Ok(result); 65 | } 66 | return BadRequest(result); 67 | } 68 | 69 | [HttpGet("getbyid")] 70 | public IActionResult GetById(int id) 71 | { 72 | var result = _customerService.GetById(id); 73 | if (result.Success) 74 | { 75 | return Ok(result); 76 | } 77 | return BadRequest(result); 78 | } 79 | 80 | //[LogAspect(typeof(DatabaseLogger))] 81 | [CacheAspect] 82 | [HttpGet("getcustomerdetail")] 83 | public IActionResult GetCustomerDetail() 84 | { 85 | var result = _customerService.GetCustomerDetails(); 86 | if (result.Success) 87 | { 88 | return Ok(result); 89 | } 90 | 91 | return BadRequest(result); 92 | } 93 | 94 | [HttpGet("getcustomerdetailbycustomerid")] 95 | public IActionResult GetCustomerDetailById(int customerId) 96 | { 97 | var result = _customerService.GetCustomerDetailById(customerId); 98 | if (result.Success) 99 | { 100 | return Ok(result); 101 | } 102 | 103 | return BadRequest(result); 104 | } 105 | 106 | [HttpGet("getcustomerbyemail")] 107 | 108 | public IActionResult GetCustomerByEmail(string email) 109 | { 110 | var result = _customerService.GetByEmail(email); 111 | if (result.Success) 112 | { 113 | return Ok(result); 114 | } 115 | return BadRequest(result); 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /WebAPI/Controllers/PaymentsController.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 PaymentsController : ControllerBase 15 | { 16 | IPaymentService _paymentService; 17 | 18 | public PaymentsController(IPaymentService paymentService) 19 | { 20 | _paymentService = paymentService; 21 | } 22 | 23 | 24 | [HttpPost("add")] 25 | public IActionResult Add(Payment payment) 26 | { 27 | var result = _paymentService.Add(payment); 28 | if (result.Success) 29 | { 30 | return Ok(result); 31 | } 32 | 33 | return BadRequest(result); 34 | } 35 | 36 | [HttpPut("update")] 37 | public IActionResult Update(Payment payment) 38 | { 39 | var result = _paymentService.Update(payment); 40 | if (result.Success) 41 | { 42 | return Ok(result); 43 | } 44 | return BadRequest(result); 45 | } 46 | 47 | [HttpPost("delete")] 48 | public IActionResult Delete(Payment payment) 49 | { 50 | var result = _paymentService.Delete(payment); 51 | if (result.Success) 52 | { 53 | return Ok(result); 54 | } 55 | return BadRequest(result); 56 | } 57 | 58 | [HttpGet("getall")] 59 | public IActionResult GetAll() 60 | { 61 | var result = _paymentService.GetAll(); 62 | if (result.Success) 63 | { 64 | return Ok(result); 65 | } 66 | return BadRequest(result); 67 | } 68 | 69 | [HttpGet("getbyid")] 70 | public IActionResult GetById(int id) 71 | { 72 | var result = _paymentService.GetById(id); 73 | if (result.Success) 74 | { 75 | return Ok(result); 76 | } 77 | return BadRequest(result); 78 | } 79 | 80 | [HttpGet("getbycustomerid")] 81 | public IActionResult GetByCustomerId(int customerId) 82 | { 83 | var result = _paymentService.GetByCustomerId(customerId); 84 | if (!result.Success) 85 | { 86 | return BadRequest(result); 87 | } 88 | return Ok(result); 89 | } 90 | 91 | [HttpGet("getbycardnumber")] 92 | public IActionResult GetByCardNumber(string cardNumber) 93 | { 94 | var result = _paymentService.GetByCardNumber(cardNumber); 95 | if (result.Success) 96 | { 97 | return Ok(result); 98 | } 99 | return BadRequest(result); 100 | } 101 | 102 | [HttpPost("verifycard")] 103 | public IActionResult VerifyCard(Payment card) 104 | { 105 | var result = _paymentService.VerifyCard(card); 106 | if (result.Success) 107 | { 108 | return Ok(result); 109 | } 110 | return BadRequest(result); 111 | } 112 | //[HttpPost("iscardexist")] 113 | //public IActionResult IsCardExist(Payment payment) 114 | //{ 115 | // var result = _paymentService.IsCardExist(payment); 116 | // if (result.Success) 117 | // { 118 | // return Ok(result); 119 | // } 120 | // return Ok(result); 121 | //} 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /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.Data); 30 | } 31 | return BadRequest(result.Message); 32 | } 33 | 34 | [HttpGet("getrentaldetails")] 35 | public IActionResult GetRentalDetailsDto() 36 | { 37 | var result = _rentalService.GetRentalDetailsDto(); 38 | if (result.Success) 39 | { 40 | return Ok(result); 41 | } 42 | return BadRequest(result); 43 | } 44 | 45 | [HttpPost("add")] 46 | public IActionResult Add(Rental rental) 47 | { 48 | var result = _rentalService.Add(rental); 49 | if (result.Success) 50 | { 51 | return Ok(result); 52 | } 53 | return BadRequest(result); 54 | } 55 | 56 | [HttpPost("delete")] 57 | public IActionResult delete(Rental rental) 58 | { 59 | var result = _rentalService.Delete(rental); 60 | if (result.Success) 61 | { 62 | return Ok(result.Message); 63 | } 64 | return BadRequest(result.Message); 65 | } 66 | 67 | [HttpPost("update")] 68 | public IActionResult Update(Rental rental) 69 | { 70 | var result = _rentalService.Update(rental); 71 | if (result.Success) 72 | { 73 | return Ok(result.Message); 74 | } 75 | return BadRequest(result.Message); 76 | } 77 | 78 | [HttpGet("getbycustomerid")] 79 | public IActionResult GetByCustomerId(int id) 80 | { 81 | var result = _rentalService.GetByCustomerId(id); 82 | if (result.Success) 83 | { 84 | return Ok(result); 85 | } 86 | 87 | return BadRequest(result); 88 | } 89 | 90 | [HttpGet("getrentaldetailbycarid")] 91 | public IActionResult GetRentalDetailsByCarId(int carId) 92 | { 93 | var result = _rentalService.GetRentalDetailsByCarId(carId); 94 | if (result.Success) 95 | { 96 | return Ok(result); 97 | } 98 | 99 | return BadRequest(result); 100 | } 101 | 102 | 103 | [HttpPost("checkrule")] 104 | public IActionResult CheckRule(Rental rental) 105 | { 106 | var result = _rentalService.CheckRule(rental); 107 | if (result.Success) 108 | { 109 | return Ok(result); 110 | } 111 | return BadRequest(result); 112 | } 113 | 114 | [HttpGet("checkrent")] 115 | public IActionResult CheckRent(int carId) 116 | { 117 | var result = _rentalService.CheckRent(carId); 118 | if (result.Success) 119 | { 120 | return Ok(result); 121 | } 122 | return BadRequest(result); 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /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 | [HttpGet] 24 | public IActionResult GetAll() 25 | { 26 | var result = _userService.GetAll(); 27 | 28 | if (!result.Success) 29 | { 30 | return BadRequest(result); 31 | } 32 | 33 | return Ok(result); 34 | } 35 | 36 | [HttpGet("getbyid")] 37 | 38 | public IActionResult GetById(int id) 39 | { 40 | var result = _userService.GetById(id); 41 | if (result.Success) 42 | { 43 | return Ok(result); 44 | } 45 | return BadRequest(result); 46 | } 47 | 48 | [HttpPost("add")] 49 | 50 | public IActionResult Add(User user) 51 | { 52 | var result = _userService.Add(user); 53 | 54 | if (result.Success) 55 | { 56 | return Ok(result); 57 | } 58 | return BadRequest(result); 59 | } 60 | 61 | [HttpPost("delete")] 62 | 63 | public IActionResult Delete(User user) 64 | { 65 | var result = _userService.Delete(user); 66 | 67 | if (result.Success) 68 | { 69 | return Ok(result); 70 | } 71 | return BadRequest(result); 72 | } 73 | 74 | [HttpPost("update")] 75 | 76 | public IActionResult Update(User user) 77 | { 78 | var result = _userService.Update(user); 79 | 80 | if (result.Success) 81 | { 82 | return Ok(result); 83 | } 84 | return BadRequest(result); 85 | } 86 | 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /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 | .ConfigureWebHostDefaults(webBuilder => 31 | { 32 | webBuilder.UseStartup(); 33 | }); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /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:64957", 8 | "sslPort": 44358 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 Core.DependencyResolvers; 4 | using Core.Extensions; 5 | using Core.Utilities.IoC; 6 | using Core.Utilities.Security.Encryption; 7 | using Core.Utilities.Security.JWT; 8 | using DataAccess.Abstract; 9 | using DataAccess.Concrete.EntityFramework; 10 | using Microsoft.AspNetCore.Authentication.JwtBearer; 11 | using Microsoft.AspNetCore.Builder; 12 | using Microsoft.AspNetCore.Hosting; 13 | using Microsoft.AspNetCore.Http; 14 | using Microsoft.AspNetCore.HttpsPolicy; 15 | using Microsoft.AspNetCore.Mvc; 16 | using Microsoft.Extensions.Configuration; 17 | using Microsoft.Extensions.DependencyInjection; 18 | using Microsoft.Extensions.Hosting; 19 | using Microsoft.Extensions.Logging; 20 | using Microsoft.IdentityModel.Tokens; 21 | using System; 22 | using System.Collections.Generic; 23 | using System.Linq; 24 | using System.Threading.Tasks; 25 | 26 | namespace WebAPI 27 | { 28 | public class Startup 29 | { 30 | public Startup(IConfiguration configuration) 31 | { 32 | Configuration = configuration; 33 | } 34 | 35 | public IConfiguration Configuration { get; } 36 | 37 | // This method gets called by the runtime. Use this method to add services to the container. 38 | public void ConfigureServices(IServiceCollection services) 39 | { 40 | services.AddControllers(); 41 | 42 | services.AddControllers().AddNewtonsoftJson(); 43 | 44 | services.AddCors(); 45 | 46 | //services.AddSingleton(); 47 | 48 | var tokenOptions = Configuration.GetSection("TokenOptions").Get(); 49 | 50 | services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) 51 | .AddJwtBearer(options => 52 | { 53 | options.TokenValidationParameters = new TokenValidationParameters 54 | { 55 | ValidateIssuer = true, 56 | ValidateAudience = true, 57 | ValidateLifetime = true, 58 | ValidIssuer = tokenOptions.Issuer, 59 | ValidAudience = tokenOptions.Audience, 60 | ValidateIssuerSigningKey = true, 61 | IssuerSigningKey = SecurityKeyHelper.CreateSecurityKey(tokenOptions.SecurityKey) 62 | }; 63 | }); 64 | 65 | services.AddDependencyResolvers(new ICoreModule[] { 66 | new CoreModule() 67 | }); 68 | 69 | } 70 | 71 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 72 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 73 | { 74 | if (env.IsDevelopment()) 75 | { 76 | app.UseDeveloperExceptionPage(); 77 | } 78 | 79 | 80 | app.ConfigureCustomExceptionMiddleware(); 81 | 82 | app.UseCors(builder => builder.WithOrigins("http://localhost:4200").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin()); 83 | 84 | app.UseHttpsRedirection(); 85 | 86 | app.UseRouting(); 87 | 88 | app.UseAuthentication(); 89 | 90 | app.UseAuthorization(); 91 | 92 | app.UseStaticFiles(); 93 | 94 | app.UseEndpoints(endpoints => 95 | { 96 | endpoints.MapControllers(); 97 | }); 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /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 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /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 | "TokenOptions": { 3 | "Audience": "sahil@gmail.com", 4 | "Issuer": "sahil@gmail.com", 5 | "AccessTokenExpiration": 10, 6 | "SecurityKey": "mysupersecretkeymysupersecretkey" 7 | }, 8 | "Logging": { 9 | "LogLevel": { 10 | "Default": "Information", 11 | "Microsoft": "Warning", 12 | "Microsoft.Hosting.Lifetime": "Information" 13 | } 14 | }, 15 | "AllowedHosts": "*" 16 | } 17 | -------------------------------------------------------------------------------- /WebAPI/wwwroot/images/29e59136-9487-4fd7-aead-6ec45257a523_3_1_2021.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rzayevsahil/ReCapProject/a3b05a92c2f076ffa4f30b5c4d27a0f833c8eded/WebAPI/wwwroot/images/29e59136-9487-4fd7-aead-6ec45257a523_3_1_2021.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/images/41951129-4e62-4787-ab21-f4adb43b95f2_3_21_2021.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rzayevsahil/ReCapProject/a3b05a92c2f076ffa4f30b5c4d27a0f833c8eded/WebAPI/wwwroot/images/41951129-4e62-4787-ab21-f4adb43b95f2_3_21_2021.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/images/c4b00bb4-8ac0-4b55-b69a-39f5584908fe_3_1_2021.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rzayevsahil/ReCapProject/a3b05a92c2f076ffa4f30b5c4d27a0f833c8eded/WebAPI/wwwroot/images/c4b00bb4-8ac0-4b55-b69a-39f5584908fe_3_1_2021.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/images/c59673e9-3e85-4777-b4e9-3860a36940da_2_28_2021.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rzayevsahil/ReCapProject/a3b05a92c2f076ffa4f30b5c4d27a0f833c8eded/WebAPI/wwwroot/images/c59673e9-3e85-4777-b4e9-3860a36940da_2_28_2021.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/images/cd7b1686-33a1-4c87-baae-44a8f96e61eb_3_21_2021.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rzayevsahil/ReCapProject/a3b05a92c2f076ffa4f30b5c4d27a0f833c8eded/WebAPI/wwwroot/images/cd7b1686-33a1-4c87-baae-44a8f96e61eb_3_21_2021.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/images/d5764523-dade-4589-9354-448ce38bba5d_3_21_2021.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rzayevsahil/ReCapProject/a3b05a92c2f076ffa4f30b5c4d27a0f833c8eded/WebAPI/wwwroot/images/d5764523-dade-4589-9354-448ce38bba5d_3_21_2021.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/images/null.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rzayevsahil/ReCapProject/a3b05a92c2f076ffa4f30b5c4d27a0f833c8eded/WebAPI/wwwroot/images/null.jpg --------------------------------------------------------------------------------