├── SQLQuery2.sql ├── WebAPI ├── wwwroot │ └── images │ │ ├── 0965c1fd-64b1-4513-af3f-c3206303c4c8.jpg │ │ ├── 0d984b2c-fe62-4830-ac93-8b44b5f5dd6e.jpg │ │ ├── 1c237bd2-6961-49fc-8062-73511def6d16.jpg │ │ ├── 3a9d6a5a-22c6-49bd-9aee-3ac4b024a2de.jpg │ │ ├── 70c565b5-f12e-4b73-8d05-a4fd536058fe.jpg │ │ ├── 7ded20cf-ff98-443e-ad51-a817edf2b3e5.jpg │ │ ├── 878b2a36-92e9-4e93-8a53-a760cfd367dd.jpg │ │ ├── 94677ac1-020b-4e49-a586-c29f2440e4ec.jpg │ │ ├── 94c1f079-6695-47f6-9c93-d429d98655ce.jpg │ │ ├── c28f1f12-099f-4931-8e4f-94c10d71cb1b.jpg │ │ ├── dfecdc04-415f-42b5-ab8b-3d71bb92080c.jpg │ │ ├── e822376b-057a-4b1c-aabd-55e2d36eed43.jpg │ │ ├── e9c17fe5-fee4-4e98-8141-ce41c8239b5e.jpg │ │ └── f57e1531-bf07-4baa-85af-2001fb031210.jpg ├── appsettings.Development.json ├── appsettings.json ├── WebAPI.csproj ├── Properties │ └── launchSettings.json ├── Program.cs ├── Controllers │ ├── AuthController.cs │ ├── ColorsController.cs │ ├── BrandsController.cs │ ├── UsersController.cs │ ├── RentalsController.cs │ ├── CustomersController.cs │ ├── CarImagesController.cs │ └── CarsController.cs └── Startup.cs ├── Core ├── Abstract │ ├── IDto.cs │ └── IEntity.cs ├── Utilities │ ├── Results │ │ ├── IDataResult.cs │ │ ├── IResult.cs │ │ ├── ErrorResult.cs │ │ ├── SuccessResult.cs │ │ ├── Result.cs │ │ ├── DataResult.cs │ │ ├── ErrorDataResult.cs │ │ └── SuccessDataResult.cs │ ├── IoC │ │ ├── ICoreModule.cs │ │ ├── ServiceTool.cs │ │ └── CoreModule.cs │ ├── Security │ │ ├── Jwt │ │ │ ├── AccessToken.cs │ │ │ ├── ITokenHelper.cs │ │ │ ├── TokenOptions.cs │ │ │ └── JwtHelper.cs │ │ ├── Encryption │ │ │ ├── SecurityKeyHelper.cs │ │ │ └── SigningCredentialsHelper.cs │ │ └── Hashing │ │ │ └── HashingHelper.cs │ ├── Business │ │ └── BusinessRules.cs │ ├── Interceptors │ │ ├── MethodInterceptionBaseAttribute.cs │ │ ├── AspectInterceptorSelector.cs │ │ └── MethodInterception.cs │ └── Helpers │ │ └── FileHelper.cs ├── Entities │ └── Concrete │ │ ├── OperationClaim.cs │ │ ├── UserOperationClaim.cs │ │ └── User.cs ├── CrossCuttingConcerns │ ├── Caching │ │ ├── ICacheManager.cs │ │ └── Microsoft │ │ │ └── MemoryCacheManager.cs │ └── Validation │ │ └── ValidationTool.cs ├── DataAccess │ ├── IEntityRepository.cs │ └── EfEntityRepositoryBase.cs ├── Extensions │ ├── ServiceCollectionExtensions.cs │ ├── ClaimsPrincipalExtensions.cs │ └── ClaimExtensions.cs ├── Aspects │ └── Autofac │ │ ├── Caching │ │ ├── CacheRemoveAspect.cs │ │ └── CacheAspect.cs │ │ ├── Transaction │ │ └── TransactionScopeAspect.cs │ │ ├── Performance │ │ └── PerformanceAspect.cs │ │ └── Validation │ │ └── ValidationAspect.cs └── Core.csproj ├── DataAccess ├── Abstract │ ├── IBrandDal.cs │ ├── IColorDal.cs │ ├── IRentalDal.cs │ ├── ICarImageDal.cs │ ├── ICustomerDal.cs │ ├── IUserDal.cs │ └── ICarDal.cs ├── Concrete │ ├── EntityFramework │ │ ├── EfBrandDal.cs │ │ ├── EfColorDal.cs │ │ ├── EfRentalDal.cs │ │ ├── EfCarImageDal.cs │ │ ├── EfCustomerDal.cs │ │ ├── CRContext.cs │ │ ├── EfUserDal.cs │ │ └── EfCarDal.cs │ └── InMemory │ │ └── InMemoryCarDal.cs └── DataAccess.csproj ├── Entities ├── Concrete │ ├── Brand.cs │ ├── Color.cs │ ├── Customer.cs │ ├── Rental.cs │ ├── Car.cs │ └── CarImage.cs ├── DTOs │ ├── UserForLoginDto.cs │ ├── CarDetailDto.cs │ └── UserForRegisterDto.cs └── Entities.csproj ├── Business ├── ValidationRules │ └── FluentValidation │ │ ├── CarImageValidator.cs │ │ ├── ColorValidator.cs │ │ ├── BrandValidator.cs │ │ ├── CustomerValidator.cs │ │ ├── UserForLoginDTOValidator.cs │ │ ├── RentalValidator.cs │ │ ├── CarValidator.cs │ │ ├── UserValidator.cs │ │ └── UserForRegisterDTOValidator.cs ├── Abstract │ ├── IBrandService.cs │ ├── IColorService.cs │ ├── IRentalService.cs │ ├── ICustomerService.cs │ ├── IAuthService.cs │ ├── IUserService.cs │ ├── ICarImageService.cs │ └── ICarService.cs ├── Logics │ ├── CommonLogics.cs │ ├── UserLogics.cs │ ├── ColorLogics.cs │ ├── BrandLogics.cs │ ├── CustomerLogics.cs │ ├── RentalLogics.cs │ └── CarLogics.cs ├── Business.csproj ├── Aspects │ └── Autofac │ │ └── SecuredOperation.cs ├── DependencyResolvers │ └── Autofac │ │ └── AutofacBusinessModule.cs ├── Concrete │ ├── ColorManager.cs │ ├── CustomerManager.cs │ ├── RentalManager.cs │ ├── BrandManager.cs │ ├── AuthManager.cs │ ├── UserManager.cs │ ├── CarManager.cs │ └── CarImageManager.cs └── Constants │ └── Messages.cs ├── ConsoleUI ├── ConsoleUI.csproj └── Program.cs ├── .gitattributes ├── CarRentalProject.sln └── .gitignore /SQLQuery2.sql: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /WebAPI/wwwroot/images/0965c1fd-64b1-4513-af3f-c3206303c4c8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyusufkocak/CarRentalProject/HEAD/WebAPI/wwwroot/images/0965c1fd-64b1-4513-af3f-c3206303c4c8.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/images/0d984b2c-fe62-4830-ac93-8b44b5f5dd6e.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyusufkocak/CarRentalProject/HEAD/WebAPI/wwwroot/images/0d984b2c-fe62-4830-ac93-8b44b5f5dd6e.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/images/1c237bd2-6961-49fc-8062-73511def6d16.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyusufkocak/CarRentalProject/HEAD/WebAPI/wwwroot/images/1c237bd2-6961-49fc-8062-73511def6d16.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/images/3a9d6a5a-22c6-49bd-9aee-3ac4b024a2de.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyusufkocak/CarRentalProject/HEAD/WebAPI/wwwroot/images/3a9d6a5a-22c6-49bd-9aee-3ac4b024a2de.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/images/70c565b5-f12e-4b73-8d05-a4fd536058fe.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyusufkocak/CarRentalProject/HEAD/WebAPI/wwwroot/images/70c565b5-f12e-4b73-8d05-a4fd536058fe.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/images/7ded20cf-ff98-443e-ad51-a817edf2b3e5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyusufkocak/CarRentalProject/HEAD/WebAPI/wwwroot/images/7ded20cf-ff98-443e-ad51-a817edf2b3e5.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/images/878b2a36-92e9-4e93-8a53-a760cfd367dd.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyusufkocak/CarRentalProject/HEAD/WebAPI/wwwroot/images/878b2a36-92e9-4e93-8a53-a760cfd367dd.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/images/94677ac1-020b-4e49-a586-c29f2440e4ec.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyusufkocak/CarRentalProject/HEAD/WebAPI/wwwroot/images/94677ac1-020b-4e49-a586-c29f2440e4ec.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/images/94c1f079-6695-47f6-9c93-d429d98655ce.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyusufkocak/CarRentalProject/HEAD/WebAPI/wwwroot/images/94c1f079-6695-47f6-9c93-d429d98655ce.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/images/c28f1f12-099f-4931-8e4f-94c10d71cb1b.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyusufkocak/CarRentalProject/HEAD/WebAPI/wwwroot/images/c28f1f12-099f-4931-8e4f-94c10d71cb1b.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/images/dfecdc04-415f-42b5-ab8b-3d71bb92080c.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyusufkocak/CarRentalProject/HEAD/WebAPI/wwwroot/images/dfecdc04-415f-42b5-ab8b-3d71bb92080c.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/images/e822376b-057a-4b1c-aabd-55e2d36eed43.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyusufkocak/CarRentalProject/HEAD/WebAPI/wwwroot/images/e822376b-057a-4b1c-aabd-55e2d36eed43.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/images/e9c17fe5-fee4-4e98-8141-ce41c8239b5e.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyusufkocak/CarRentalProject/HEAD/WebAPI/wwwroot/images/e9c17fe5-fee4-4e98-8141-ce41c8239b5e.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/images/f57e1531-bf07-4baa-85af-2001fb031210.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyusufkocak/CarRentalProject/HEAD/WebAPI/wwwroot/images/f57e1531-bf07-4baa-85af-2001fb031210.jpg -------------------------------------------------------------------------------- /Core/Abstract/IDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Abstract 6 | { 7 | public interface IDto 8 | { 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Core/Abstract/IEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Abstract 6 | { 7 | public interface IEntity 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /WebAPI/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Core/Utilities/Results/IDataResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities 6 | { 7 | public interface IDataResult:IResult 8 | { 9 | T Data { get; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Core/Utilities/Results/IResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities 6 | { 7 | public interface IResult 8 | { 9 | bool Success { get; } 10 | string Message { get; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /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/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/IRentalDal.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 IRentalDal : IEntityRepository 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Core/Entities/Concrete/OperationClaim.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Entities.Concrete 6 | { 7 | public class OperationClaim 8 | { 9 | public int Id { get; set; } 10 | public string Name { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /DataAccess/Abstract/ICustomerDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Entities.Concrete; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace DataAccess.Abstract 8 | { 9 | public interface ICustomerDal : IEntityRepository 10 | { 11 | 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /Entities/Concrete/Brand.cs: -------------------------------------------------------------------------------- 1 | using Core.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class Brand:IEntity 9 | { 10 | public int BrandId { get; set; } 11 | public string BrandName { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /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/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 | } 14 | -------------------------------------------------------------------------------- /Entities/Concrete/Color.cs: -------------------------------------------------------------------------------- 1 | using Core.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class Color:IEntity 9 | 10 | { 11 | public int ColorId { get; set; } 12 | public string ColorName { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Entities/DTOs/UserForLoginDto.cs: -------------------------------------------------------------------------------- 1 | using Core.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 | -------------------------------------------------------------------------------- /Core/Utilities/Security/Jwt/ITokenHelper.cs: -------------------------------------------------------------------------------- 1 | using Core.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 | -------------------------------------------------------------------------------- /DataAccess/Abstract/IUserDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Core.Entities.Concrete; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace DataAccess.Abstract 8 | { 9 | public interface IUserDal:IEntityRepository 10 | { 11 | 12 | List GetClaims(User user); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Core/Entities/Concrete/UserOperationClaim.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Entities.Concrete 6 | { 7 | public class UserOperationClaim 8 | { 9 | public int Id { get; set; } 10 | public int UserId { get; set; } 11 | public int OperationClaimId { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Entities/Entities.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /DataAccess/Abstract/ICarDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Core.Utilities; 3 | using Entities.Concrete; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace DataAccess.Abstract 9 | { 10 | public interface ICarDal : IEntityRepository 11 | { 12 | List GetCarDetails(); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Entities/Concrete/Customer.cs: -------------------------------------------------------------------------------- 1 | using Core.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class Customer:IEntity 9 | { 10 | public int Id { get; set; } 11 | public int UserId { get; set; } 12 | public string CompanyName { get; set; } 13 | 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Core/Utilities/Results/ErrorResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities 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 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfBrandDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using DataAccess.Abstract; 3 | using DataAccess.EntityFramework; 4 | using Entities.Concrete; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Text; 8 | 9 | namespace DataAccess.Concrete.EntityFramework 10 | { 11 | public class EfBrandDal:EfEntityRepositoryBase,IBrandDal 12 | { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfColorDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using DataAccess.Abstract; 3 | using DataAccess.EntityFramework; 4 | using Entities.Concrete; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Text; 8 | 9 | namespace DataAccess.Concrete.EntityFramework 10 | { 11 | public class EfColorDal:EfEntityRepositoryBase,IColorDal 12 | { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Core/Utilities/Results/SuccessResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities 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 | } 21 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfRentalDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using DataAccess.Abstract; 3 | using DataAccess.EntityFramework; 4 | using Entities.Concrete; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Text; 8 | 9 | namespace DataAccess.Concrete.EntityFramework 10 | { 11 | public class EfRentalDal : EfEntityRepositoryBase, IRentalDal 12 | { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfCarImageDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using DataAccess.Abstract; 3 | using DataAccess.EntityFramework; 4 | using Entities.Concrete; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Text; 8 | 9 | namespace DataAccess.Concrete.EntityFramework 10 | { 11 | public class EfCarImageDal : EfEntityRepositoryBase, ICarImageDal 12 | { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfCustomerDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using DataAccess.Abstract; 3 | using DataAccess.EntityFramework; 4 | using Entities.Concrete; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Text; 8 | 9 | namespace DataAccess.Concrete.EntityFramework 10 | { 11 | public class EfCustomerDal : EfEntityRepositoryBase,ICustomerDal 12 | { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /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/DataAccess.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Entities/DTOs/CarDetailDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class CarDetailDto : IDto 9 | { 10 | public string CarName { get; set; } 11 | public string BrandName { get; set; } 12 | public string ColorName { get; set; } 13 | public int DailyPrice { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /WebAPI/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "TokenOptions": { 3 | "Audience": "www.engin.com", 4 | "Issuer": "www.engin.com", 5 | "AccessTokenExpiration": 10, 6 | "SecurityKey": "mysecretkeymysecretkey" 7 | }, 8 | 9 | "Logging": { 10 | "LogLevel": { 11 | "Default": "Information", 12 | "Microsoft": "Warning", 13 | "Microsoft.Hosting.Lifetime": "Information" 14 | } 15 | }, 16 | "AllowedHosts": "*" 17 | } 18 | -------------------------------------------------------------------------------- /Entities/DTOs/UserForRegisterDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.DTOs 7 | { 8 | public class UserForRegisterDto : IDto 9 | { 10 | public string Email { get; set; } 11 | public string Password { get; set; } 12 | public string FirstName { get; set; } 13 | public string LastName { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /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 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ConsoleUI/ConsoleUI.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Entities/Concrete/Rental.cs: -------------------------------------------------------------------------------- 1 | using Core.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class Rental:IEntity 9 | { 10 | public int Id { get; set; } 11 | public int CarID { get; set; } 12 | public int CustomerId { get; set; } 13 | public DateTime RentDate { get; set; } 14 | public DateTime? ReturnDate { get; set; } 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Business/Abstract/IBrandService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities; 2 | using Entities.Concrete; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Business.Abstract 8 | { 9 | public interface IBrandService 10 | { 11 | IDataResult> GetAll(); 12 | IDataResult GetById(int id); 13 | 14 | IResult Add(Brand brand); 15 | IResult Delete(Brand brand); 16 | IResult Update(Brand brand); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Business/Abstract/IColorService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities; 2 | using Entities.Concrete; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Business.Abstract 8 | { 9 | public interface IColorService 10 | { 11 | IDataResult> GetAll(); 12 | IDataResult GetById(int id); 13 | 14 | IResult Add(Color color); 15 | IResult Delete(Color color); 16 | IResult Update(Color color); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /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 data, int duration); 12 | bool IsAdd(string key); 13 | void Remove(string key); 14 | void RemoveByPattern(string pattern); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Business/Abstract/IRentalService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities; 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 IRentalService 10 | { 11 | IDataResult> GetAll(); 12 | IDataResult GetById(int id); 13 | 14 | 15 | IResult Add(Rental rental); 16 | IResult Delete(Rental rental); 17 | IResult Update(Rental rental); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Entities/Concrete/Car.cs: -------------------------------------------------------------------------------- 1 | 2 | using Core.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 string CarName { get; set; } 13 | public int BrandId { get; set; } 14 | public int ColorId { get; set; } 15 | public int ModelYear { get; set; } 16 | public int DailyPrice { get; set; } 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Entities/Concrete/CarImage.cs: -------------------------------------------------------------------------------- 1 | using Core.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class CarImage : IEntity 9 | { 10 | public int Id { get; set; } 11 | public int CarId { get; set; } 12 | public string ImagePath { get; set; } 13 | public DateTime Date { get; set; } 14 | 15 | public CarImage() 16 | { 17 | Date = DateTime.Now; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Business/Abstract/ICustomerService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities; 2 | using Entities.Concrete; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Business.Abstract 8 | { 9 | public interface ICustomerService 10 | { 11 | IDataResult> GetAll(); 12 | IDataResult GetById(int id); 13 | 14 | IResult Add(Customer customer); 15 | IResult Delete(Customer customer); 16 | IResult Update(Customer customer); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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.HmacSha256Signature); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Core/DataAccess/IEntityRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.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); 13 | void Add(T entity); 14 | void Delete(T entity); 15 | void Update(T entity); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Core/Utilities/Results/Result.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities 6 | { 7 | public class Result : IResult 8 | { 9 | 10 | public Result(bool success,string message):this(success) 11 | { 12 | Message = message; 13 | } 14 | 15 | public Result (bool success) 16 | { 17 | Success = success; 18 | } 19 | 20 | public bool Success { get; } 21 | public string Message { get; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Core/Utilities/Business/BusinessRules.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Business 6 | { 7 | public class BusinessRules 8 | { 9 | public static IResult Run(params IResult[] logics) 10 | { 11 | foreach (var logic in logics) 12 | { 13 | if (!logic.Success) 14 | { 15 | return logic; 16 | } 17 | } 18 | return null; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Business/Logics/CommonLogics.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Business.Logics 7 | { 8 | public class CommonLogics 9 | { 10 | 11 | public static IResult SystemMaintenanceTime() 12 | { 13 | 14 | if (DateTime.Now.Hour == 22) 15 | { 16 | return new ErrorResult(Messages.MaintenanceTime); 17 | } 18 | 19 | return new SuccessResult(); 20 | 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /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 | } 20 | -------------------------------------------------------------------------------- /Core/Entities/Concrete/User.cs: -------------------------------------------------------------------------------- 1 | using Core.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Entities.Concrete 7 | { 8 | public class User : IEntity 9 | { 10 | 11 | public int Id { get; set; } 12 | public string FirstName { get; set; } 13 | public string LastName { get; set; } 14 | public string Email { get; set; } 15 | public byte[] PasswordSalt { get; set; } 16 | public byte[] PasswordHash { get; set; } 17 | public bool Status { get; set; } 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /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 | RuleFor(c => c.CompanyName).NotEmpty(); 15 | RuleFor(c => c.CompanyName).MinimumLength(2); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Business/Abstract/IAuthService.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Concrete; 2 | using Core.Utilities; 3 | using Core.Utilities.Security.Jwt; 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); 14 | IDataResult Login(UserForLoginDto userForLoginDto); 15 | IResult UserExists(string email); 16 | IDataResult CreateAccessToken(User user); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/UserForLoginDTOValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.DTOs; 2 | using FluentValidation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Business.ValidationRules.FluentValidation 8 | { 9 | 10 | public class UserForLoginDTOValidator : AbstractValidator 11 | { 12 | public UserForLoginDTOValidator() 13 | { 14 | RuleFor(u => u.Email).NotEmpty(); 15 | RuleFor(u => u.Email).EmailAddress(); 16 | RuleFor(u => u.Password).NotEmpty(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Core/Utilities/Results/DataResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities 6 | { 7 | public class DataResult : Result,IDataResult 8 | { 9 | 10 | 11 | public DataResult(T data, bool success, string message) : base(success, message) 12 | { 13 | Data = data; 14 | } 15 | public DataResult(T data, bool success) : base(success) 16 | { 17 | Data = data; 18 | } 19 | 20 | public T Data { get; } 21 | 22 | 23 | 24 | 25 | 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/RentalValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.Concrete; 2 | using FluentValidation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Business.ValidationRules.FluentValidation 8 | { 9 | public class RentalValidator : AbstractValidator 10 | { 11 | public RentalValidator() 12 | { 13 | RuleFor(r => r.RentDate).NotEmpty(); 14 | RuleFor(r => r.ReturnDate).NotEmpty(); 15 | RuleFor(r => r.CarID).NotEmpty(); 16 | RuleFor(r => r.CustomerId).NotEmpty(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Business/Abstract/IUserService.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Concrete; 2 | using Core.Utilities; 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 IUserService 11 | { 12 | IDataResult> GetAll(); 13 | IDataResult GetById(int id); 14 | IDataResult> GetClaims(User user); 15 | IDataResult GetByMail(string email); 16 | IResult Add(User user); 17 | IResult Delete(User user); 18 | IResult Update(User user); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Business/Logics/UserLogics.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities; 2 | using DataAccess.Abstract; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Business.Logics 8 | { 9 | public class UserLogics 10 | { 11 | public static IResult CheckIfEmailAlreadyExist(IUserDal userDal, string email) 12 | { 13 | var result = userDal.Get(u => u.Email == email); 14 | if (result == null) 15 | { 16 | return new SuccessResult(); 17 | } 18 | 19 | return new ErrorResult(); 20 | 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Business/Abstract/ICarImageService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities; 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 | IResult Add(IFormFile file, CarImage carImage); 13 | IResult Delete(CarImage carImage); 14 | IResult Update(IFormFile file, CarImage carImage); 15 | IDataResult Get(int id); 16 | IDataResult> GetAll(); 17 | IDataResult> GetCarImagesByCarId(int id); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Business/Abstract/ICarService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities; 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 ICarService 10 | { 11 | IDataResult> GetAll(); 12 | IDataResult GetById(int id); 13 | IDataResult> GetCarsByBrandId(int id); 14 | IDataResult> GetCarsByColorId(int id); 15 | IDataResult> GetCarDetails(); 16 | IResult Add(Car car); 17 | IResult Delete(Car car); 18 | IResult Update(Car car); 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /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 services,ICoreModule[] modules) 12 | { 13 | foreach (var module in modules) 14 | { 15 | module.Load(services); 16 | } 17 | return ServiceTool.Create(services); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Core/Utilities/Interceptors/MethodInterceptionBaseAttribute.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Utilities.Interceptors 7 | { 8 | 9 | 10 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] 11 | public abstract class MethodInterceptionBaseAttribute : Attribute, IInterceptor 12 | { 13 | public int Priority { get; set; } 14 | 15 | public virtual void Intercept(IInvocation invocation) 16 | { 17 | 18 | } 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /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 | } 22 | -------------------------------------------------------------------------------- /Business/Logics/ColorLogics.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities; 2 | using DataAccess.Abstract; 3 | using Entities.Concrete; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace Business.Logics 9 | { 10 | public class ColorLogics 11 | { 12 | public static IResult CheckIfColorAlreadyExist(IColorDal colorDal, Color color) 13 | { 14 | var result = colorDal.Get(c => c.ColorName== color.ColorName); 15 | 16 | if (result != null) 17 | { 18 | return new SuccessResult(); 19 | } 20 | return new ErrorResult(); 21 | 22 | 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Core/Utilities/Results/ErrorDataResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities 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/SuccessDataResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities 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 | -------------------------------------------------------------------------------- /Business/Logics/BrandLogics.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities; 2 | using DataAccess.Abstract; 3 | using Entities.Concrete; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace Business.Logics 9 | { 10 | public class BrandLogics 11 | { 12 | public static IResult CheckIfBrandAlreadyExist(IBrandDal brandDal, Brand brand) 13 | { 14 | var result = brandDal.Get(b => b.BrandName == brand.BrandName); 15 | 16 | if (result != null) 17 | { 18 | return new SuccessResult(); 19 | } 20 | 21 | return new ErrorResult(); 22 | 23 | 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Business/Logics/CustomerLogics.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities; 2 | using DataAccess.Abstract; 3 | using Entities.Concrete; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace Business.Logics 9 | { 10 | public class CustomerLogics 11 | { 12 | public static IResult CheckIfCustomerAlreadyExist(ICustomerDal customerDal, Customer customer) 13 | { 14 | var result = customerDal.Get(c => c.CompanyName == customer.CompanyName); 15 | 16 | if (result == null) 17 | { 18 | return new SuccessResult(); 19 | } 20 | return new ErrorResult(); 21 | 22 | 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Business/Business.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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.CarName).NotEmpty(); 14 | RuleFor(c => c.CarName).MinimumLength(3); 15 | RuleFor(c => c.DailyPrice).NotEmpty(); 16 | RuleFor(c => c.DailyPrice).GreaterThan(0); 17 | RuleFor(c => c.ModelYear).NotEmpty(); 18 | RuleFor(c => c.ColorId).NotEmpty(); 19 | RuleFor(c => c.BrandId).NotEmpty(); 20 | 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/UserValidator.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Concrete; 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).NotEmpty(); 15 | RuleFor(u => u.FirstName).MinimumLength(2); 16 | RuleFor(u => u.LastName).NotEmpty(); 17 | RuleFor(u => u.LastName).MinimumLength(2); 18 | RuleFor(u => u.Email).NotEmpty(); 19 | RuleFor(u => u.Email).EmailAddress().WithMessage("Invalid email address"); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Core/Utilities/IoC/CoreModule.cs: -------------------------------------------------------------------------------- 1 | using Core.CrossCuttingConcerns.Caching; 2 | using Core.CrossCuttingConcerns.Caching.Microsoft; 3 | using Core.Extensions; 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.Utilities.IoC 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 | -------------------------------------------------------------------------------- /Business/Logics/RentalLogics.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Core.Utilities; 3 | using DataAccess.Abstract; 4 | using Entities.Concrete; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | 10 | namespace Business.Logics 11 | { 12 | public class RentalLogics 13 | { 14 | 15 | 16 | 17 | 18 | public static IResult CheckIfCarAlreadyRented(IRentalDal rentalDal, Rental rental) 19 | { 20 | var existRental = rentalDal.GetAll(r => r.CarID == rental.CarID).OrderBy(r => r.RentDate).FirstOrDefault(); 21 | 22 | if (existRental == null || (existRental.ReturnDate != null && existRental.ReturnDate < DateTime.Now)) 23 | { 24 | return new SuccessResult(); 25 | } 26 | 27 | return new ErrorResult(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Aspects/Autofac/Caching/CacheRemoveAspect.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using Core.CrossCuttingConcerns.Caching; 3 | using Core.Utilities.IoC; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | using Microsoft.Extensions.DependencyInjection; 8 | using Core.Utilities.Interceptors; 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/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(); 20 | } 21 | catch (System.Exception e) 22 | { 23 | transactionScope.Dispose(); 24 | throw; 25 | } 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /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:54665", 8 | "sslPort": 44382 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 | -------------------------------------------------------------------------------- /Core/Core.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Core/Utilities/Interceptors/AspectInterceptorSelector.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using Core.Aspects.Autofac.Transaction; 3 | using System; 4 | using System.Linq; 5 | using System.Reflection; 6 | 7 | namespace Core.Utilities.Interceptors 8 | { 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 | classAttributes.Add(new TransactionScopeAspect()); 20 | 21 | 22 | return classAttributes.OrderBy(x => x.Priority).ToArray(); 23 | } 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/UserForRegisterDTOValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.DTOs; 2 | using FluentValidation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | 8 | namespace Business.ValidationRules.FluentValidation 9 | { 10 | public class UserForRegisterDTOValidator : AbstractValidator 11 | { 12 | public UserForRegisterDTOValidator() 13 | { 14 | RuleFor(u => u.Email).NotEmpty(); 15 | RuleFor(u => u.Email).EmailAddress(); 16 | RuleFor(u => u.Password).NotEmpty(); 17 | RuleFor(u => u.Password).Must(PasswordStrong).WithMessage(Messages.PasswordNotStrongEnough); 18 | } 19 | 20 | private bool PasswordStrong(string password) 21 | { 22 | return password.Any(char.IsDigit) 23 | && password.Any(char.IsLetter) 24 | && password.Any(char.IsUpper) 25 | && password.Any(char.IsLower) 26 | && password.Any(char.IsSymbol); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/CRContext.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Concrete; 2 | using Entities.Concrete; 3 | using Microsoft.EntityFrameworkCore; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | 9 | namespace DataAccess.EntityFramework 10 | { 11 | public class CRContext : DbContext 12 | { 13 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 14 | { 15 | optionsBuilder.UseSqlServer(@"Server=(localdb)\MSSQLLocalDB;Database=CarRental;Trusted_Connection=True"); 16 | } 17 | 18 | public DbSet Cars { get; set; } 19 | public DbSet Brands { get; set; } 20 | public DbSet Colors { get; set; } 21 | public DbSet Rentals { get; set; } 22 | public DbSet Users { get; set; } 23 | public DbSet Customers { get; set; } 24 | public DbSet CarImages { get; set; } 25 | public DbSet OperationClaims { get; set; } 26 | public DbSet UserOperationClaims { get; set; } 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfUserDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Core.Entities.Concrete; 3 | using DataAccess.Abstract; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | using System.Linq; 8 | using System.Linq.Expressions; 9 | using DataAccess.EntityFramework; 10 | 11 | namespace DataAccess.Concrete.EntityFramework 12 | { 13 | public class EfUserDal : EfEntityRepositoryBase, IUserDal 14 | { 15 | public List GetClaims(User user) 16 | { 17 | using (var context = new CRContext()) 18 | { 19 | var result = from operationClaim in context.OperationClaims 20 | join userOperationClaim in context.UserOperationClaims 21 | on operationClaim.Id equals userOperationClaim.OperationClaimId 22 | where userOperationClaim.UserId == user.Id 23 | select new OperationClaim { Id = operationClaim.Id, Name = operationClaim.Name }; 24 | return result.ToList(); 25 | 26 | } 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /WebAPI/Program.cs: -------------------------------------------------------------------------------- 1 | using Autofac; 2 | using Autofac.Extensions.DependencyInjection; 3 | using Business.DependencyResolvers.Autofac; 4 | using Microsoft.AspNetCore.Hosting; 5 | using Microsoft.Extensions.Configuration; 6 | using Microsoft.Extensions.Hosting; 7 | using Microsoft.Extensions.Logging; 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Linq; 11 | using System.Threading.Tasks; 12 | 13 | namespace WebAPI 14 | { 15 | public class Program 16 | { 17 | public static void Main(string[] args) 18 | { 19 | CreateHostBuilder(args).Build().Run(); 20 | } 21 | 22 | public static IHostBuilder CreateHostBuilder(string[] args) => 23 | Host.CreateDefaultBuilder(args) 24 | .UseServiceProviderFactory(new AutofacServiceProviderFactory()) 25 | .ConfigureContainer(builder => 26 | { 27 | builder.RegisterModule(new AutofacBusinessModule()); 28 | }) 29 | .ConfigureWebHostDefaults(webBuilder => 30 | { 31 | webBuilder.UseStartup(); 32 | }); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Business/Logics/CarLogics.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities; 2 | using DataAccess.Abstract; 3 | using Entities.Concrete; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace Business.Logics 9 | { 10 | public class CarLogics 11 | { 12 | 13 | 14 | public static IResult CheckIfCarExists(ICarDal carDal, Car car) 15 | { 16 | var result = carDal.Get(c => c.BrandId == car.BrandId 17 | && c.ColorId == car.ColorId 18 | && c.ModelYear == car.ModelYear 19 | && c.CarName == car.CarName); 20 | 21 | if (result!=null) 22 | { 23 | return new SuccessResult(); 24 | } 25 | return new ErrorResult(); 26 | 27 | } 28 | 29 | public static IResult CheckIfCarCountOfBrandCorrect(ICarDal carDal, int brandId) 30 | { 31 | var result = carDal.GetAll(c => c.BrandId == brandId); 32 | 33 | if (result.Count <= 3) 34 | { 35 | return new SuccessResult(); 36 | } 37 | 38 | return new ErrorResult(); 39 | 40 | } 41 | 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfCarDal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq.Expressions; 4 | using System.Linq; 5 | using System.Text; 6 | using DataAccess.Abstract; 7 | using Entities.Concrete; 8 | using Microsoft.EntityFrameworkCore; 9 | using Core.DataAccess; 10 | using Core.Utilities; 11 | 12 | namespace DataAccess.EntityFramework 13 | { 14 | public class EfCarDal : EfEntityRepositoryBase, ICarDal 15 | { 16 | public List GetCarDetails() 17 | { 18 | using (CRContext context = new CRContext()) 19 | { 20 | var result = from cr in context.Cars 21 | join b in context.Brands 22 | on cr.BrandId equals b.BrandId 23 | join c in context.Colors 24 | on cr.ColorId equals c.ColorId 25 | select new CarDetailDto {CarName=cr.CarName,BrandName=b.BrandName,ColorName=c.ColorName,DailyPrice=cr.DailyPrice}; 26 | 27 | return result.ToList(); 28 | 29 | } 30 | 31 | 32 | 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Business/Aspects/Autofac/SecuredOperation.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using Core.Extensions; 3 | using Core.Utilities.Interceptors; 4 | using Core.Utilities.IoC; 5 | using Microsoft.AspNetCore.Http; 6 | using Microsoft.Extensions.DependencyInjection; 7 | using System; 8 | using System.Collections.Generic; 9 | using System.Text; 10 | 11 | namespace Business.Aspects.Autofac 12 | { 13 | public class SecuredOperation : MethodInterception 14 | { 15 | private string[] _roles; 16 | private IHttpContextAccessor _httpContextAccessor; 17 | 18 | public SecuredOperation(string roles) 19 | { 20 | _roles = roles.Split(','); 21 | _httpContextAccessor = ServiceTool.ServiceProvider.GetService(); 22 | 23 | } 24 | 25 | protected override void OnBefore(IInvocation invocation) 26 | { 27 | var roleClaims = _httpContextAccessor.HttpContext.User.ClaimRoles(); 28 | foreach (var role in _roles) 29 | { 30 | if (roleClaims.Contains(role)) 31 | { 32 | return; 33 | } 34 | } 35 | throw new Exception(Messages.AuthorizationDenied); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /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/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[] passwordHash, out byte[] passwordSalt) 10 | { 11 | using (var hmac = new System.Security.Cryptography.HMACSHA512()) 12 | { 13 | passwordSalt = hmac.Key; 14 | passwordHash = hmac.ComputeHash(Encoding.UTF8.GetBytes(password)); 15 | } 16 | } 17 | 18 | public static bool VerifyPasswordHash(string password, byte[] passwordHash, 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] != passwordHash[i]) 26 | { 27 | return false; 28 | } 29 | } 30 | } 31 | 32 | return true; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Core/Aspects/Autofac/Validation/ValidationAspect.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using Core.CrossCuttingConcerns.Validation; 3 | using Core.Utilities.Interceptors; 4 | using FluentValidation; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | 10 | namespace Core.Aspects.Autofac.Validation 11 | { 12 | public class ValidationAspect:MethodInterception 13 | { 14 | private Type _validatorType; 15 | public ValidationAspect(Type validatorType) 16 | { 17 | if (!typeof(IValidator).IsAssignableFrom(validatorType)) 18 | { 19 | throw new System.Exception("BU bir doğrulama sınıfı değil"); 20 | } 21 | 22 | _validatorType = validatorType; 23 | } 24 | protected override void OnBefore(IInvocation invocation) 25 | { 26 | var validator = (IValidator)Activator.CreateInstance(_validatorType); 27 | var entityType = _validatorType.BaseType.GetGenericArguments()[0]; 28 | var entities = invocation.Arguments.Where(t => t.GetType() == entityType); 29 | foreach (var entity in entities) 30 | { 31 | ValidationTool.Validate(validator, entity); 32 | } 33 | } 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /Core/Utilities/Interceptors/MethodInterception.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using System; 3 | 4 | namespace Core.Utilities.Interceptors 5 | { 6 | 7 | public abstract class MethodInterception : MethodInterceptionBaseAttribute 8 | { 9 | protected virtual void OnBefore(IInvocation invocation) { } 10 | protected virtual void OnAfter(IInvocation invocation) { } 11 | protected virtual void OnException(IInvocation invocation, System.Exception e) { } 12 | protected virtual void OnSuccess(IInvocation invocation) { } 13 | public override void Intercept(IInvocation invocation) 14 | { 15 | var isSuccess = true; 16 | OnBefore(invocation); 17 | try 18 | { 19 | invocation.Proceed(); 20 | } 21 | catch (Exception e) 22 | { 23 | isSuccess = false; 24 | OnException(invocation, e); 25 | throw; 26 | } 27 | finally 28 | { 29 | if (isSuccess) 30 | { 31 | OnSuccess(invocation); 32 | } 33 | } 34 | OnAfter(invocation); 35 | } 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /ConsoleUI/Program.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Concrete; 3 | using DataAccess.Abstract; 4 | using DataAccess.Concrete; 5 | using DataAccess.Concrete.EntityFramework; 6 | using DataAccess.Concrete.InMemory; 7 | using DataAccess.EntityFramework; 8 | using Entities; 9 | using Entities.Concrete; 10 | using System; 11 | 12 | namespace ConsoleUI 13 | { 14 | class Program 15 | { 16 | static void Main(string[] args) 17 | { 18 | CarManager carManager = new CarManager(new EfCarDal()); 19 | 20 | 21 | RentalManager rentalManager = new RentalManager(new EfRentalDal()); 22 | rentalManager.Add(new Rental { CarID = 1, CustomerId = 3, RentDate = DateTime.Now, }); 23 | 24 | //UserManager userManager = new UserManager(new EfUserDal()); 25 | //User user1 = new User(); 26 | //user1.FirstName = "Batuhan"; 27 | //user1.LastName = "Cömert"; 28 | //user1.Email = "batuhancömert@hotmail.com"; 29 | //user1.Password = "123456 "; 30 | //userManager.Add(user1); 31 | 32 | //Customer customer1 = new Customer(); 33 | //customer1.UserId = 1; 34 | //customer1.CompanyName = "Google"; 35 | 36 | //CustomerManager customerManager = new CustomerManager(new EfCustomerDal()); 37 | //customerManager.Add(customer1); 38 | 39 | 40 | 41 | 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /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.Text; 8 | using Microsoft.Extensions.DependencyInjection; 9 | using System.Linq; 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 | -------------------------------------------------------------------------------- /WebAPI/Controllers/AuthController.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Entities.DTOs; 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 AuthController : ControllerBase 15 | { 16 | private IAuthService _authService; 17 | 18 | public AuthController(IAuthService authService) 19 | { 20 | _authService = authService; 21 | } 22 | 23 | [HttpPost("login")] 24 | public ActionResult Login(UserForLoginDto userForLoginDto) 25 | { 26 | var userToLogin = _authService.Login(userForLoginDto); 27 | if (!userToLogin.Success) 28 | { 29 | return BadRequest(userToLogin.Message); 30 | } 31 | 32 | var result = _authService.CreateAccessToken(userToLogin.Data); 33 | if (result.Success) 34 | { 35 | return Ok(result.Data); 36 | } 37 | 38 | return BadRequest(result.Message); 39 | } 40 | 41 | [HttpPost("register")] 42 | public ActionResult Register(UserForRegisterDto userForRegisterDto) 43 | { 44 | var userExists = _authService.UserExists(userForRegisterDto.Email); 45 | if (userExists.Success) 46 | { 47 | return BadRequest(userExists.Message); 48 | } 49 | 50 | var registerResult = _authService.Register(userForRegisterDto); 51 | var result = _authService.CreateAccessToken(registerResult.Data); 52 | if (result.Success) 53 | { 54 | return Ok(result.Data); 55 | } 56 | 57 | return BadRequest(result.Message); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Core/DataAccess/EfEntityRepositoryBase.cs: -------------------------------------------------------------------------------- 1 | using Core.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 10 | { 11 | public class EfEntityRepositoryBase : IEntityRepository 12 | where TEntity : class, IEntity, new() 13 | where TContext : DbContext, new() 14 | 15 | { 16 | public void Add(TEntity entity) 17 | { 18 | using (TContext context = new TContext()) 19 | { 20 | 21 | var addedEntity = context.Entry(entity); 22 | addedEntity.State = EntityState.Added; 23 | context.SaveChanges(); 24 | 25 | 26 | } 27 | } 28 | 29 | public void Delete(TEntity entity) 30 | { 31 | using (TContext context = new TContext()) 32 | { 33 | var deletedEntity = context.Entry(entity); 34 | deletedEntity.State = EntityState.Deleted; 35 | context.SaveChanges(); 36 | } 37 | } 38 | 39 | public TEntity Get(Expression> filter) 40 | { 41 | using (TContext context = new TContext()) 42 | { 43 | return context.Set().SingleOrDefault(filter); 44 | } 45 | } 46 | 47 | public List GetAll(Expression> filter = null) 48 | { 49 | using (TContext context = new TContext()) 50 | { 51 | return filter == null ? 52 | context.Set().ToList() : 53 | context.Set().Where(filter).ToList(); 54 | } 55 | } 56 | 57 | public void Update(TEntity entity) 58 | { 59 | using (TContext context = new TContext()) 60 | { 61 | var UpdatedEntity = context.Entry(entity); 62 | UpdatedEntity.State = EntityState.Modified; 63 | context.SaveChanges(); 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /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 | [HttpPost("add")] 24 | public IActionResult Add(Color color) 25 | { 26 | var result = _colorService.Add(color); 27 | 28 | if (result.Success) 29 | { 30 | return Ok(result); 31 | } 32 | return BadRequest(result); 33 | } 34 | 35 | [HttpDelete("delete")] 36 | public IActionResult Delete(Color color) 37 | { 38 | var result = _colorService.Delete(color); 39 | 40 | if (result.Success) 41 | { 42 | return Ok(result); 43 | } 44 | return BadRequest(result); 45 | } 46 | 47 | [HttpPut("update")] 48 | public IActionResult Update(Color color) 49 | { 50 | var result = _colorService.Add(color); 51 | 52 | if (result.Success) 53 | { 54 | return Ok(result); 55 | } 56 | return BadRequest(result); 57 | } 58 | 59 | [HttpGet("getall")] 60 | public IActionResult GetAll() 61 | { 62 | var result = _colorService.GetAll(); 63 | 64 | if (result.Success) 65 | { 66 | return Ok(result); 67 | } 68 | return BadRequest(result); 69 | } 70 | 71 | [HttpGet("getbyid")] 72 | public IActionResult GetAll(int id) 73 | { 74 | var result = _colorService.GetById(id); 75 | 76 | if (result.Success) 77 | { 78 | return Ok(result); 79 | } 80 | return BadRequest(result); 81 | } 82 | 83 | 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /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 | [HttpPost("add")] 24 | public IActionResult Add(Brand brand) 25 | { 26 | var result = _brandService.Add(brand); 27 | 28 | if (result.Success) 29 | { 30 | return Ok(result); 31 | } 32 | return BadRequest(result); 33 | } 34 | 35 | [HttpDelete("delete")] 36 | public IActionResult Delete(Brand brand) 37 | { 38 | var result = _brandService.Delete(brand); 39 | 40 | if (result.Success) 41 | { 42 | return Ok(result); 43 | } 44 | return BadRequest(result); 45 | } 46 | 47 | [HttpPut("update")] 48 | public IActionResult Update(Brand brand) 49 | { 50 | var result = _brandService.Add(brand); 51 | 52 | if (result.Success) 53 | { 54 | return Ok(result); 55 | } 56 | return BadRequest(result); 57 | } 58 | 59 | [HttpGet("getall")] 60 | public IActionResult GetAll() 61 | { 62 | var result = _brandService.GetAll(); 63 | 64 | if (result.Success) 65 | { 66 | return Ok(result); 67 | } 68 | return BadRequest(result); 69 | } 70 | 71 | [HttpGet("getbyid")] 72 | public IActionResult GetAll(int id) 73 | { 74 | var result = _brandService.GetById(id); 75 | 76 | if (result.Success) 77 | { 78 | return Ok(result); 79 | } 80 | return BadRequest(result); 81 | } 82 | 83 | 84 | 85 | 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /WebAPI/Controllers/UsersController.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Core.Entities.Concrete; 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 UsersController : ControllerBase 16 | { 17 | IUserService _userService; 18 | 19 | public UsersController(IUserService userService) 20 | { 21 | _userService = userService; 22 | } 23 | 24 | [HttpPost("add")] 25 | public IActionResult Add(User user) 26 | { 27 | var result = _userService.Add(user); 28 | 29 | if (result.Success) 30 | { 31 | return Ok(result); 32 | } 33 | return BadRequest(result); 34 | } 35 | 36 | [HttpDelete("delete")] 37 | public IActionResult Delete(User user) 38 | { 39 | var result = _userService.Delete(user); 40 | 41 | if (result.Success) 42 | { 43 | return Ok(result); 44 | } 45 | return BadRequest(result); 46 | } 47 | 48 | [HttpPut("update")] 49 | public IActionResult Update(User user) 50 | { 51 | var result = _userService.Add(user); 52 | 53 | if (result.Success) 54 | { 55 | return Ok(result); 56 | } 57 | return BadRequest(result); 58 | } 59 | 60 | [HttpGet("getall")] 61 | public IActionResult GetAll() 62 | { 63 | var result = _userService.GetAll(); 64 | 65 | if (result.Success) 66 | { 67 | return Ok(result); 68 | } 69 | return BadRequest(result); 70 | } 71 | 72 | [HttpGet("getbyid")] 73 | public IActionResult GetAll(int id) 74 | { 75 | var result = _userService.GetById(id); 76 | 77 | if (result.Success) 78 | { 79 | return Ok(result); 80 | } 81 | return BadRequest(result); 82 | } 83 | 84 | 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /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 | 17 | IRentalService _rentalService; 18 | 19 | public RentalsController(IRentalService rentalService) 20 | { 21 | _rentalService = rentalService; 22 | } 23 | 24 | [HttpPost("add")] 25 | public IActionResult Add(Rental rental) 26 | { 27 | var result = _rentalService.Add(rental); 28 | 29 | if (result.Success) 30 | { 31 | return Ok(result); 32 | } 33 | return BadRequest(result); 34 | } 35 | 36 | [HttpDelete("delete")] 37 | public IActionResult Delete(Rental rental) 38 | { 39 | var result = _rentalService.Delete(rental); 40 | 41 | if (result.Success) 42 | { 43 | return Ok(result); 44 | } 45 | return BadRequest(result); 46 | } 47 | 48 | [HttpPut("update")] 49 | public IActionResult Update(Rental rental) 50 | { 51 | var result = _rentalService.Add(rental); 52 | 53 | if (result.Success) 54 | { 55 | return Ok(result); 56 | } 57 | return BadRequest(result); 58 | } 59 | 60 | [HttpGet("getall")] 61 | public IActionResult GetAll() 62 | { 63 | var result = _rentalService.GetAll(); 64 | 65 | if (result.Success) 66 | { 67 | return Ok(result); 68 | } 69 | return BadRequest(result); 70 | } 71 | 72 | [HttpGet("getbyid")] 73 | public IActionResult GetAll(int id) 74 | { 75 | var result = _rentalService.GetById(id); 76 | 77 | if (result.Success) 78 | { 79 | return Ok(result); 80 | } 81 | return BadRequest(result); 82 | } 83 | 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /WebAPI/Controllers/CustomersController.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Entities.Concrete; 3 | using Microsoft.AspNetCore.Http; 4 | using Microsoft.AspNetCore.Mvc; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace WebAPI.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class CustomersController : ControllerBase 15 | { 16 | 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 | 29 | if (result.Success) 30 | { 31 | return Ok(result); 32 | } 33 | return BadRequest(result); 34 | } 35 | 36 | [HttpDelete("delete")] 37 | public IActionResult Delete(Customer customer) 38 | { 39 | var result = _customerService.Delete(customer); 40 | 41 | if (result.Success) 42 | { 43 | return Ok(result); 44 | } 45 | return BadRequest(result); 46 | } 47 | 48 | [HttpPut("update")] 49 | public IActionResult Update(Customer customer) 50 | { 51 | var result = _customerService.Add(customer); 52 | 53 | if (result.Success) 54 | { 55 | return Ok(result); 56 | } 57 | return BadRequest(result); 58 | } 59 | 60 | [HttpGet("getall")] 61 | public IActionResult GetAll() 62 | { 63 | var result = _customerService.GetAll(); 64 | 65 | if (result.Success) 66 | { 67 | return Ok(result); 68 | } 69 | return BadRequest(result); 70 | } 71 | 72 | [HttpGet("getbyid")] 73 | public IActionResult GetAll(int id) 74 | { 75 | var result = _customerService.GetById(id); 76 | 77 | if (result.Success) 78 | { 79 | return Ok(result); 80 | } 81 | return BadRequest(result); 82 | } 83 | 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /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.Linq; 6 | using System.Text; 7 | using System.Text.RegularExpressions; 8 | using Microsoft.Extensions.DependencyInjection; 9 | 10 | namespace Core.CrossCuttingConcerns.Caching.Microsoft 11 | { 12 | public class MemoryCacheManager : ICacheManager 13 | { 14 | private IMemoryCache _cache; 15 | public MemoryCacheManager() 16 | { 17 | _cache = ServiceTool.ServiceProvider.GetService(); 18 | } 19 | public T Get(string key) 20 | { 21 | return _cache.Get(key); 22 | } 23 | 24 | public object Get(string key) 25 | { 26 | return _cache.Get(key); 27 | } 28 | 29 | public void Add(string key, object data, int duration) 30 | { 31 | _cache.Set(key, data, TimeSpan.FromMinutes(duration)); 32 | } 33 | 34 | public bool IsAdd(string key) 35 | { 36 | return _cache.TryGetValue(key, out _); 37 | } 38 | 39 | public void Remove(string key) 40 | { 41 | _cache.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(_cache) 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 | _cache.Remove(key); 62 | } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Business/DependencyResolvers/Autofac/AutofacBusinessModule.cs: -------------------------------------------------------------------------------- 1 | using Autofac; 2 | using Autofac.Extras.DynamicProxy; 3 | using Business.Abstract; 4 | using Business.Concrete; 5 | using Castle.DynamicProxy; 6 | using Core.Utilities.Interceptors; 7 | using Core.Utilities.Security.Jwt; 8 | using DataAccess.Abstract; 9 | using DataAccess.Concrete.EntityFramework; 10 | using DataAccess.EntityFramework; 11 | using System; 12 | using System.Collections.Generic; 13 | using System.Text; 14 | 15 | namespace Business.DependencyResolvers.Autofac 16 | { 17 | public class AutofacBusinessModule:Module 18 | { 19 | protected override void Load(ContainerBuilder builder) 20 | { 21 | builder.RegisterType().As().SingleInstance(); 22 | builder.RegisterType().As().SingleInstance(); 23 | 24 | builder.RegisterType().As().SingleInstance(); 25 | builder.RegisterType().As().SingleInstance(); 26 | 27 | builder.RegisterType().As().SingleInstance(); 28 | builder.RegisterType().As().SingleInstance(); 29 | 30 | builder.RegisterType().As().SingleInstance(); 31 | builder.RegisterType().As().SingleInstance(); 32 | 33 | builder.RegisterType().As().SingleInstance(); 34 | builder.RegisterType().As().SingleInstance(); 35 | 36 | builder.RegisterType().As().SingleInstance(); 37 | builder.RegisterType().As().SingleInstance(); 38 | 39 | builder.RegisterType().As().SingleInstance(); 40 | builder.RegisterType().As().SingleInstance(); 41 | 42 | builder.RegisterType().As().SingleInstance(); 43 | builder.RegisterType().As().SingleInstance(); 44 | 45 | builder.RegisterType().As().SingleInstance(); 46 | builder.RegisterType().As().SingleInstance(); 47 | 48 | 49 | 50 | 51 | var assembly = System.Reflection.Assembly.GetExecutingAssembly(); 52 | 53 | builder.RegisterAssemblyTypes(assembly).AsImplementedInterfaces() 54 | .EnableInterfaceInterceptors(new ProxyGenerationOptions() 55 | { 56 | Selector = new AspectInterceptorSelector() 57 | }).SingleInstance(); 58 | 59 | 60 | 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /Core/Utilities/Security/Jwt/JwtHelper.cs: -------------------------------------------------------------------------------- 1 | 2 | using Core.Entities.Concrete; 3 | using Core.Extensions; 4 | using Core.Utilities.Security.Encryption; 5 | using Microsoft.Extensions.Configuration; 6 | using Microsoft.IdentityModel.Tokens; 7 | using System; 8 | using System.Collections.Generic; 9 | using System.IdentityModel.Tokens.Jwt; 10 | using System.Linq; 11 | using System.Security.Claims; 12 | using System.Text; 13 | 14 | namespace Core.Utilities.Security.Jwt 15 | { 16 | public class JwtHelper : ITokenHelper 17 | { 18 | public IConfiguration Configuration { get; } 19 | private TokenOptions _tokenOptions; 20 | private DateTime _accessTokenExpiration; 21 | public JwtHelper(IConfiguration configuration) 22 | { 23 | Configuration = configuration; 24 | _tokenOptions = Configuration.GetSection("TokenOptions").Get(); 25 | 26 | } 27 | public AccessToken CreateToken(User user, List operationClaims) 28 | { 29 | _accessTokenExpiration = DateTime.Now.AddMinutes(_tokenOptions.AccessTokenExpiration); 30 | var securityKey = SecurityKeyHelper.CreateSecurityKey(_tokenOptions.SecurityKey); 31 | var signingCredentials = SigningCredentialsHelper.CreateSigningCredentials(securityKey); 32 | var jwt = CreateJwtSecurityToken(_tokenOptions, user, signingCredentials, operationClaims); 33 | var jwtSecurityTokenHandler = new JwtSecurityTokenHandler(); 34 | var token = jwtSecurityTokenHandler.WriteToken(jwt); 35 | 36 | return new AccessToken 37 | { 38 | Token = token, 39 | Expiration = _accessTokenExpiration 40 | }; 41 | 42 | } 43 | 44 | public JwtSecurityToken CreateJwtSecurityToken(TokenOptions tokenOptions, User user, 45 | SigningCredentials signingCredentials, List operationClaims) 46 | { 47 | var jwt = new JwtSecurityToken( 48 | issuer: tokenOptions.Issuer, 49 | audience: tokenOptions.Audience, 50 | expires: _accessTokenExpiration, 51 | notBefore: DateTime.Now, 52 | claims: SetClaims(user, operationClaims), 53 | signingCredentials: signingCredentials 54 | ); 55 | return jwt; 56 | } 57 | 58 | private IEnumerable SetClaims(User user, List operationClaims) 59 | { 60 | var claims = new List(); 61 | claims.AddNameIdentifier(user.Id.ToString()); 62 | claims.AddEmail(user.Email); 63 | claims.AddName($"{user.FirstName} {user.LastName}"); 64 | claims.AddRoles(operationClaims.Select(c => c.Name).ToArray()); 65 | 66 | return claims; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /DataAccess/Concrete/InMemory/InMemoryCarDal.cs: -------------------------------------------------------------------------------- 1 | using DataAccess.Abstract; 2 | using Entities.Concrete; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Linq.Expressions; 7 | using System.Text; 8 | 9 | namespace DataAccess.Concrete.InMemory 10 | { 11 | 12 | public class InMemoryCarDal : ICarDal 13 | { 14 | List _cars; 15 | public InMemoryCarDal() 16 | { 17 | _cars=new List { 18 | new Car { Id = 1, BrandId = 1, ColorId = 1, DailyPrice = 140,ModelYear=2016,CarName= "Deneme1" }, 19 | new Car { Id = 2, BrandId = 1, ColorId = 2, DailyPrice = 153,ModelYear=2019,CarName= "Deneme2" }, 20 | new Car { Id = 3, BrandId = 2, ColorId = 2, DailyPrice = 146,ModelYear=2017,CarName= "Deneme3" }, 21 | new Car { Id = 4, BrandId = 4, ColorId = 3, DailyPrice = 149,ModelYear=2017,CarName= "Deneme4" }, 22 | new Car { Id = 5, BrandId = 3, ColorId = 1, DailyPrice = 151,ModelYear=2018,CarName= "Deneme5" }, 23 | new Car { Id = 6, BrandId = 2, ColorId = 1, DailyPrice = 150,ModelYear=2019,CarName= "Deneme6" }, 24 | new Car { Id = 7, BrandId = 1, ColorId = 1, DailyPrice = 141,ModelYear=2017,CarName= "Deneme7" } 25 | }; 26 | } 27 | public void Add(Car car) 28 | { 29 | _cars.Add(car); 30 | 31 | } 32 | 33 | public void Delete(Car car) 34 | { 35 | Car CarToDelete = _cars.SingleOrDefault(c => c.Id == car.Id); 36 | _cars.Remove(CarToDelete); 37 | } 38 | 39 | public Car Get(Expression> filter) 40 | { 41 | throw new NotImplementedException(); 42 | } 43 | 44 | public List GetAll() 45 | { 46 | return _cars.ToList(); 47 | } 48 | 49 | public List GetAll(Expression> filter = null) 50 | { 51 | throw new NotImplementedException(); 52 | } 53 | 54 | public Car GetById(int Id) 55 | { 56 | return _cars.SingleOrDefault(c=>c.Id==Id); 57 | } 58 | 59 | public List GetCarDetails() 60 | { 61 | throw new NotImplementedException(); 62 | } 63 | 64 | public void Update(Car car) 65 | { 66 | Car CarToUpdate = _cars.SingleOrDefault(c=>c.Id==car.Id); 67 | CarToUpdate.Id = car.Id; 68 | CarToUpdate.BrandId = car.BrandId; 69 | CarToUpdate.ColorId = car.ColorId; 70 | CarToUpdate.DailyPrice = car.DailyPrice; 71 | CarToUpdate.ModelYear = car.ModelYear; 72 | CarToUpdate.CarName= car.CarName; 73 | 74 | 75 | 76 | 77 | } 78 | 79 | List ICarDal.GetCarDetails() 80 | { 81 | throw new NotImplementedException(); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /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 | private ICarImageService _carImageService; 17 | 18 | public CarImagesController(ICarImageService carmagesService) 19 | { 20 | _carImageService = carmagesService; 21 | } 22 | 23 | [HttpPost("add")] 24 | public IActionResult Add([FromForm(Name = ("CarImage"))] IFormFile file, [FromForm] CarImage carImage) 25 | { 26 | var result = _carImageService.Add(file, carImage); 27 | if (result.Success) 28 | { 29 | return Ok(result); 30 | } 31 | return BadRequest(result); 32 | } 33 | 34 | [HttpPost("delete")] 35 | public IActionResult Delete([FromForm(Name = ("Id"))] int Id) 36 | { 37 | 38 | var carImage = _carImageService.Get(Id).Data; 39 | 40 | var result = _carImageService.Delete(carImage); 41 | if (result.Success) 42 | { 43 | return Ok(result); 44 | } 45 | return BadRequest(result); 46 | } 47 | 48 | [HttpPost("update")] 49 | public IActionResult Update([FromForm(Name = ("CarImage"))] IFormFile file, [FromForm(Name = ("Id"))] int Id) 50 | { 51 | var carImage = _carImageService.Get(Id).Data; 52 | var result = _carImageService.Update(file, carImage); 53 | if (result.Success) 54 | { 55 | return Ok(result); 56 | } 57 | return BadRequest(result); 58 | } 59 | 60 | [HttpGet("getbyid")] 61 | public IActionResult GetById(int id) 62 | { 63 | var result = _carImageService.GetCarImagesByCarId(id); 64 | if (result.Success) 65 | { 66 | return Ok(result.Data); 67 | } 68 | return BadRequest(result); 69 | } 70 | 71 | [HttpGet("getall")] 72 | public IActionResult GetAll() 73 | { 74 | var result = _carImageService.GetAll(); 75 | if (result.Success) 76 | { 77 | return Ok(result); 78 | } 79 | return BadRequest(result); 80 | } 81 | 82 | [HttpGet("getimagesbycarid")] 83 | public IActionResult GetImagesById([FromForm(Name = ("CarId"))] int carId) 84 | { 85 | var result = _carImageService.GetCarImagesByCarId(carId); 86 | if (result.Success) 87 | { 88 | return Ok(result); 89 | } 90 | return BadRequest(result); 91 | } 92 | 93 | 94 | 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /WebAPI/Startup.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Concrete; 3 | using Core.Utilities.IoC; 4 | using Core.Utilities.Security.Jwt; 5 | using DataAccess.Abstract; 6 | using DataAccess.Concrete.EntityFramework; 7 | using DataAccess.EntityFramework; 8 | using Microsoft.AspNetCore.Builder; 9 | using Microsoft.AspNetCore.Hosting; 10 | using Microsoft.AspNetCore.Http; 11 | using Microsoft.AspNetCore.HttpsPolicy; 12 | using Microsoft.AspNetCore.Mvc; 13 | using Microsoft.Extensions.Configuration; 14 | using Microsoft.Extensions.DependencyInjection; 15 | using Microsoft.Extensions.Hosting; 16 | using Microsoft.Extensions.Logging; 17 | using System; 18 | using System.Collections.Generic; 19 | using System.Linq; 20 | using System.Threading.Tasks; 21 | using Microsoft.AspNetCore.Authentication.JwtBearer; 22 | using Core.Utilities.Security.Encryption; 23 | using Microsoft.IdentityModel.Tokens; 24 | using Core.Extensions; 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 | 43 | services.AddSingleton(); 44 | 45 | var tokenOptions = Configuration.GetSection("TokenOptions").Get(); 46 | 47 | services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) 48 | .AddJwtBearer(options => 49 | { 50 | options.TokenValidationParameters = new TokenValidationParameters 51 | { 52 | ValidateIssuer = true, 53 | ValidateAudience = true, 54 | ValidateLifetime = true, 55 | ValidIssuer = tokenOptions.Issuer, 56 | ValidAudience = tokenOptions.Audience, 57 | ValidateIssuerSigningKey = true, 58 | IssuerSigningKey = SecurityKeyHelper.CreateSecurityKey(tokenOptions.SecurityKey) 59 | }; 60 | }); 61 | 62 | 63 | services.AddDependencyResolvers(new ICoreModule[] {new CoreModule()}); 64 | 65 | 66 | } 67 | 68 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 69 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 70 | { 71 | if (env.IsDevelopment()) 72 | { 73 | app.UseDeveloperExceptionPage(); 74 | } 75 | 76 | app.UseHttpsRedirection(); 77 | 78 | app.UseRouting(); 79 | 80 | app.UseAuthentication(); 81 | 82 | app.UseAuthorization(); 83 | 84 | 85 | app.UseEndpoints(endpoints => 86 | { 87 | endpoints.MapControllers(); 88 | }); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /Business/Concrete/ColorManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Core.Utilities; 3 | using DataAccess.Abstract; 4 | using Entities.Concrete; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Text; 8 | using Core.Aspects.Autofac.Validation; 9 | using Business.ValidationRules.FluentValidation; 10 | using Business.Aspects.Autofac; 11 | using Core.Utilities.Business; 12 | using Business.Logics; 13 | using Core.Aspects.Autofac.Caching; 14 | 15 | namespace Business.Concrete 16 | { 17 | public class ColorManager : IColorService 18 | { 19 | 20 | IColorDal _colorDal; 21 | 22 | public ColorManager(IColorDal colorDal) 23 | { 24 | _colorDal = colorDal; 25 | } 26 | [SecuredOperation("admin")] 27 | [ValidationAspect(typeof(ColorValidator))] 28 | [CacheRemoveAspect("IColorService.Get")] 29 | public IResult Add(Color color) 30 | { 31 | IResult result = BusinessRules.Run( 32 | ColorLogics.CheckIfColorAlreadyExist(_colorDal, color), CommonLogics.SystemMaintenanceTime()); 33 | if (!result.Success) 34 | { 35 | return new ErrorResult(result.Message); 36 | } 37 | 38 | _colorDal.Add(color); 39 | return new SuccessResult(Messages.ColorAdded); 40 | 41 | 42 | 43 | 44 | } 45 | [SecuredOperation("admin")] 46 | [CacheRemoveAspect("IColorService.Get")] 47 | public IResult Delete(Color color) 48 | { 49 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 50 | 51 | if (!result.Success) 52 | { 53 | return new ErrorResult(result.Message); 54 | } 55 | 56 | _colorDal.Delete(color); 57 | return new SuccessResult(Messages.ColorDeleted); 58 | 59 | } 60 | [CacheAspect] 61 | public IDataResult> GetAll() 62 | { 63 | 64 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 65 | 66 | if (!result.Success) 67 | { 68 | return new ErrorDataResult>(result.Message); 69 | } 70 | 71 | return new SuccessDataResult>(_colorDal.GetAll()); 72 | 73 | } 74 | [CacheAspect(10)] 75 | public IDataResult GetById(int id) 76 | { 77 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 78 | 79 | if (!result.Success) 80 | { 81 | return new ErrorDataResult(result.Message); 82 | } 83 | 84 | return new SuccessDataResult(_colorDal.Get(c => c.ColorId == id)); 85 | 86 | } 87 | [ValidationAspect(typeof(ColorValidator))] 88 | [SecuredOperation("admin")] 89 | [CacheRemoveAspect("IColorService.Get")] 90 | public IResult Update(Color color) 91 | { 92 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 93 | 94 | if (!result.Success) 95 | { 96 | return new ErrorResult(result.Message); 97 | } 98 | 99 | _colorDal.Update(color); 100 | return new SuccessResult(Messages.ColorUpdated); 101 | 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /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 | [HttpPost("add")] 24 | public IActionResult Add(Car car) 25 | { 26 | var result = _carService.Add(car); 27 | 28 | if (result.Success) 29 | { 30 | return Ok(result); 31 | } 32 | return BadRequest(result); 33 | } 34 | 35 | [HttpDelete("delete")] 36 | public IActionResult Delete(Car car) 37 | { 38 | var result = _carService.Delete(car); 39 | 40 | if (result.Success) 41 | { 42 | return Ok(result); 43 | } 44 | return BadRequest(result); 45 | } 46 | 47 | [HttpPut("update")] 48 | public IActionResult Update(Car car) 49 | { 50 | var result = _carService.Update(car); 51 | 52 | if (result.Success) 53 | { 54 | return Ok(result); 55 | } 56 | return BadRequest(result); 57 | } 58 | 59 | 60 | [HttpGet("getall")] 61 | public IActionResult GetAll() 62 | { 63 | var result = _carService.GetAll(); 64 | 65 | if (result.Success) 66 | { 67 | return Ok(result); 68 | } 69 | return BadRequest(result); 70 | } 71 | 72 | 73 | [HttpGet("getbyid")] 74 | public IActionResult GetById(int id) 75 | { 76 | var result = _carService.GetById(id); 77 | 78 | if (result.Success) 79 | { 80 | return Ok(result); 81 | } 82 | return BadRequest(result); 83 | } 84 | 85 | [HttpGet("getcarsbybrandid")] 86 | public IActionResult GetCarsByBrandId(int id) 87 | { 88 | var result = _carService.GetCarsByBrandId(id); 89 | 90 | if (result.Success) 91 | { 92 | return Ok(result); 93 | } 94 | return BadRequest(result); 95 | } 96 | 97 | [HttpGet("getcarsbycolorid")] 98 | public IActionResult GetCarsByColorId(int id) 99 | { 100 | var result = _carService.GetCarsByColorId(id); 101 | 102 | if (result.Success) 103 | { 104 | return Ok(result); 105 | } 106 | return BadRequest(result); 107 | } 108 | 109 | [HttpGet("getcardetails")] 110 | public IActionResult GetCarDetails() 111 | { 112 | var result = _carService.GetCarDetails(); 113 | 114 | 115 | if (result.Success) 116 | { 117 | return Ok(result); 118 | } 119 | return BadRequest(result); 120 | } 121 | 122 | 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /Business/Constants/Messages.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Concrete; 2 | using Entities.Concrete; 3 | using System.Collections.Generic; 4 | using System.Runtime.Serialization; 5 | 6 | namespace Business 7 | { 8 | public static class Messages 9 | { 10 | public static string MaintenanceTime = "Sistem Bakımda"; 11 | 12 | 13 | public static string CarAdded = "Araba Eklendi"; 14 | public static string CarNameInvalid = "Geçersiz Araba İsmi"; 15 | public static string CarDeleted = "Araba Silindi"; 16 | public static string CarIdInvalid = "Geçersiz Araba Id"; 17 | public static string CarUpdated = "Araba Güncellendi"; 18 | 19 | 20 | public static string ColorAdded = "Renk Eklendi"; 21 | public static string ColorNameInvalid = "Geçersiz Renk İsmi"; 22 | public static string ColorDeleted = "Renk Silindi"; 23 | public static string ColorIdInvalid = "Geçersiz Renk Id"; 24 | public static string ColorUpdated = "Renk Güncellendi"; 25 | 26 | 27 | public static string BrandAdded = "Marka Eklendi"; 28 | public static string BrandNameInvalid = "Geçersiz Marka İsmi"; 29 | public static string BrandDeleted = "Marka Silindi"; 30 | public static string BrandIdInvalid = "Geçersiz Marka Id"; 31 | public static string BrandUpdated = "Marka Güncellendi"; 32 | 33 | 34 | public static string CustomerAdded = "Müşteri Eklendi"; 35 | public static string CustomerNameInvalid = "Geçersiz Müşteri İsmi"; 36 | public static string CustomerDeleted = "Müşteri Silindi"; 37 | public static string CustomerIdInvalid = "Geçersiz Müşteri Id"; 38 | public static string CustomerUpdated = "Müşteri Güncellendi"; 39 | 40 | 41 | public static string UserAdded = "Kullanıcı Eklendi"; 42 | public static string UserNameInvalid = "Geçersiz Kullanıcı İsmi"; 43 | public static string UserDeleted = "Kullanıcı Silindi"; 44 | public static string UserIdInvalid = "Geçersiz Kullanıcı Id"; 45 | public static string UserUpdated = "Kullanıcı Güncellendi"; 46 | 47 | 48 | public static string RentalAdded = "Kiralama Oluşturuldu"; 49 | public static string RentalDeleted = "Kiralama Silindi"; 50 | public static string RentalUpdated = "Kiralama Güncellendi"; 51 | public static string DeleteInvalidRental = "Şart Sağlanmadı,Silme İşlemi Başarısız"; 52 | public static string RentalInvalid = "Geçersiz Kiralama"; 53 | 54 | 55 | public static string CarImageAdded = " Resim Eklendi"; 56 | public static string CarImageDeleted = " Resim Silindi"; 57 | public static string CarImageIdInvalid = "Geçersiz Id"; 58 | public static string CarImageUpdated = "Resim Güncellendi"; 59 | public static string CarImageInvalid = " Geçersiz Resim"; 60 | public static string CarImageLimitFail = "Resim Limit Hatası"; 61 | public static string CarImageNotFound = "Resim Bulanamadı"; 62 | 63 | 64 | public static string AuthorizationDenied = "Yetkilendirme Hatası"; 65 | public static string UserRegistered = "Kullanıcı Kaydı Başarılı"; 66 | public static string PasswordNotStrongEnough = "Şifre Yeterince Güçlü Değil"; 67 | public static string PasswordError = "Hatalı Şifre"; 68 | public static string SuccessLogin = "Başarılı Giriş"; 69 | public static string UserAlreadyExists = "Kullanıcı zaten var"; 70 | public static string UserNotFound = "Kullanıcı Bulunamadı"; 71 | 72 | } 73 | } -------------------------------------------------------------------------------- /Business/Concrete/CustomerManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Core.Utilities; 3 | using DataAccess.Abstract; 4 | using Entities.Concrete; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Text; 8 | using Core.Aspects.Autofac.Validation; 9 | using Business.ValidationRules.FluentValidation; 10 | using Core.Utilities.Business; 11 | using Business.Logics; 12 | using Business.Aspects.Autofac; 13 | using Core.Aspects.Autofac.Caching; 14 | 15 | namespace Business.Concrete 16 | { 17 | public class CustomerManager : ICustomerService 18 | { 19 | 20 | ICustomerDal _customerDal; 21 | 22 | public CustomerManager(ICustomerDal customerDal) 23 | { 24 | _customerDal = customerDal; 25 | } 26 | 27 | [SecuredOperation("customer.add")] 28 | [ValidationAspect(typeof(CustomerValidator))] 29 | [CacheRemoveAspect("ICustomerService.Get")] 30 | public IResult Add(Customer customer) 31 | { 32 | 33 | IResult result = BusinessRules.Run(CustomerLogics.CheckIfCustomerAlreadyExist(_customerDal, customer), CommonLogics.SystemMaintenanceTime()); 34 | if (!result.Success) 35 | { 36 | return new ErrorResult(result.Message); 37 | } 38 | 39 | _customerDal.Add(customer); 40 | return new SuccessResult(Messages.CustomerAdded); 41 | 42 | 43 | 44 | } 45 | [CacheRemoveAspect("ICustomerService.Get")] 46 | public IResult Delete(Customer customer) 47 | { 48 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 49 | 50 | if (!result.Success) 51 | { 52 | return new ErrorResult(result.Message); 53 | } 54 | 55 | _customerDal.Delete(customer); 56 | return new SuccessResult(Messages.CustomerDeleted); 57 | 58 | 59 | } 60 | [CacheAspect] 61 | public IDataResult> GetAll() 62 | { 63 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 64 | 65 | if (!result.Success) 66 | { 67 | return new ErrorDataResult>(result.Message); 68 | } 69 | 70 | return new SuccessDataResult>(_customerDal.GetAll()); 71 | 72 | 73 | 74 | 75 | } 76 | [CacheAspect(10)] 77 | public IDataResult GetById(int id) 78 | { 79 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 80 | 81 | if (!result.Success) 82 | { 83 | return new ErrorDataResult(result.Message); 84 | } 85 | 86 | return new SuccessDataResult(_customerDal.Get(c => c.Id == id)); 87 | 88 | } 89 | 90 | [SecuredOperation("customer.add")] 91 | [ValidationAspect(typeof(CustomerValidator))] 92 | [CacheRemoveAspect("ICustomerService.Get")] 93 | public IResult Update(Customer customer) 94 | { 95 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 96 | 97 | if (!result.Success) 98 | { 99 | return new ErrorResult(result.Message); 100 | } 101 | 102 | _customerDal.Update(customer); 103 | return new SuccessResult(Messages.CustomerUpdated); 104 | 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /Business/Concrete/RentalManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Core.Utilities; 3 | using DataAccess.Abstract; 4 | using Entities.Concrete; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Text; 8 | using Core.Aspects.Autofac.Validation; 9 | using Business.ValidationRules.FluentValidation; 10 | using Business.Logics; 11 | using Core.Utilities.Business; 12 | using Business.Aspects.Autofac; 13 | using Core.Aspects.Autofac.Caching; 14 | 15 | namespace Business.Concrete 16 | { 17 | public class RentalManager : IRentalService 18 | { 19 | IRentalDal _rentalDal; 20 | 21 | 22 | public RentalManager(IRentalDal rentalDal) 23 | { 24 | _rentalDal = rentalDal; 25 | 26 | } 27 | 28 | 29 | [SecuredOperation("admin,rental.add")] 30 | [ValidationAspect(typeof(RentalValidator))] 31 | [CacheRemoveAspect("IRentalService.Get")] 32 | public IResult Add(Rental rental) 33 | { 34 | IResult result = BusinessRules.Run( 35 | RentalLogics.CheckIfCarAlreadyRented(_rentalDal, rental), 36 | CommonLogics.SystemMaintenanceTime()); 37 | if (!result.Success) 38 | { 39 | return new ErrorResult(result.Message); 40 | } 41 | 42 | _rentalDal.Add(rental); 43 | return new SuccessResult(Messages.RentalAdded); 44 | 45 | 46 | } 47 | [CacheRemoveAspect("IRentalService.Get")] 48 | public IResult Delete(Rental rental) 49 | { 50 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 51 | 52 | if (!result.Success) 53 | { 54 | return new ErrorResult(result.Message); 55 | } 56 | 57 | _rentalDal.Delete(rental); 58 | return new SuccessResult(Messages.RentalDeleted); 59 | 60 | } 61 | [CacheAspect] 62 | public IDataResult> GetAll() 63 | { 64 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 65 | 66 | if (!result.Success) 67 | { 68 | return new ErrorDataResult>(result.Message); 69 | } 70 | 71 | 72 | return new SuccessDataResult>(_rentalDal.GetAll()); 73 | 74 | 75 | } 76 | [CacheAspect(5)] 77 | public IDataResult GetById(int id) 78 | { 79 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 80 | 81 | if (!result.Success) 82 | { 83 | return new ErrorDataResult(result.Message); 84 | } 85 | 86 | return new SuccessDataResult(_rentalDal.Get(c => c.Id == id)); 87 | 88 | 89 | } 90 | 91 | [SecuredOperation("admin,rental.add")] 92 | [ValidationAspect(typeof(RentalValidator))] 93 | [CacheRemoveAspect("IRentalService.Get")] 94 | public IResult Update(Rental rental) 95 | { 96 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 97 | 98 | if (!result.Success) 99 | { 100 | return new ErrorResult(result.Message); 101 | } 102 | 103 | _rentalDal.Update(rental); 104 | return new SuccessResult(Messages.RentalUpdated); 105 | 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /CarRentalProject.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31129.286 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataAccess", "DataAccess\DataAccess.csproj", "{6569CDD4-E932-44DB-A398-B771BF47DEA2}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Entities", "Entities\Entities.csproj", "{FA9F1EF2-7389-4AF3-A606-37914FA2D44F}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleUI", "ConsoleUI\ConsoleUI.csproj", "{20FC91F2-AC58-4771-A693-09E03504E4ED}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Business", "Business\Business.csproj", "{975A1F19-2619-45EB-8C7E-753D93D91329}" 13 | EndProject 14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core", "Core\Core.csproj", "{EA5BE687-0CC0-4B00-89BE-17500D3CA03D}" 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAPI", "WebAPI\WebAPI.csproj", "{9E553CFD-2746-494E-9C59-6D6681C39F5F}" 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 | {6569CDD4-E932-44DB-A398-B771BF47DEA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {6569CDD4-E932-44DB-A398-B771BF47DEA2}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {6569CDD4-E932-44DB-A398-B771BF47DEA2}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {6569CDD4-E932-44DB-A398-B771BF47DEA2}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {FA9F1EF2-7389-4AF3-A606-37914FA2D44F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {FA9F1EF2-7389-4AF3-A606-37914FA2D44F}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {FA9F1EF2-7389-4AF3-A606-37914FA2D44F}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {FA9F1EF2-7389-4AF3-A606-37914FA2D44F}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {20FC91F2-AC58-4771-A693-09E03504E4ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {20FC91F2-AC58-4771-A693-09E03504E4ED}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {20FC91F2-AC58-4771-A693-09E03504E4ED}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {20FC91F2-AC58-4771-A693-09E03504E4ED}.Release|Any CPU.Build.0 = Release|Any CPU 36 | {975A1F19-2619-45EB-8C7E-753D93D91329}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 37 | {975A1F19-2619-45EB-8C7E-753D93D91329}.Debug|Any CPU.Build.0 = Debug|Any CPU 38 | {975A1F19-2619-45EB-8C7E-753D93D91329}.Release|Any CPU.ActiveCfg = Release|Any CPU 39 | {975A1F19-2619-45EB-8C7E-753D93D91329}.Release|Any CPU.Build.0 = Release|Any CPU 40 | {EA5BE687-0CC0-4B00-89BE-17500D3CA03D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 41 | {EA5BE687-0CC0-4B00-89BE-17500D3CA03D}.Debug|Any CPU.Build.0 = Debug|Any CPU 42 | {EA5BE687-0CC0-4B00-89BE-17500D3CA03D}.Release|Any CPU.ActiveCfg = Release|Any CPU 43 | {EA5BE687-0CC0-4B00-89BE-17500D3CA03D}.Release|Any CPU.Build.0 = Release|Any CPU 44 | {9E553CFD-2746-494E-9C59-6D6681C39F5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 45 | {9E553CFD-2746-494E-9C59-6D6681C39F5F}.Debug|Any CPU.Build.0 = Debug|Any CPU 46 | {9E553CFD-2746-494E-9C59-6D6681C39F5F}.Release|Any CPU.ActiveCfg = Release|Any CPU 47 | {9E553CFD-2746-494E-9C59-6D6681C39F5F}.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 = {F6EEF3A3-E54C-48EF-8936-16B99D35502F} 54 | EndGlobalSection 55 | EndGlobal 56 | -------------------------------------------------------------------------------- /Business/Concrete/BrandManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Core.Aspects.Autofac.Validation; 3 | using Core.Utilities; 4 | using DataAccess.Abstract; 5 | using Entities.Concrete; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Text; 9 | using Business.ValidationRules.FluentValidation; 10 | using Business.Aspects.Autofac; 11 | using Core.Utilities.Business; 12 | using Business.Logics; 13 | using Core.Aspects.Autofac.Caching; 14 | using Core.Aspects.Autofac.Performance; 15 | 16 | namespace Business.Concrete 17 | { 18 | public class BrandManager : IBrandService 19 | { 20 | IBrandDal _brandDal; 21 | 22 | public BrandManager(IBrandDal brandDal) 23 | { 24 | _brandDal = brandDal; 25 | } 26 | 27 | [SecuredOperation("admin")] 28 | [ValidationAspect(typeof(BrandValidator))] 29 | [CacheRemoveAspect("IBrandService.Get")] 30 | public IResult Add(Brand brand) 31 | { 32 | var result = BusinessRules.Run(BrandLogics.CheckIfBrandAlreadyExist(_brandDal, brand),CommonLogics.SystemMaintenanceTime()); 33 | 34 | if (!result.Success) 35 | { 36 | return new ErrorResult(result.Message); 37 | } 38 | 39 | _brandDal.Add(brand); 40 | return new SuccessResult(Messages.BrandAdded); 41 | 42 | 43 | } 44 | 45 | [CacheRemoveAspect("IBrandService.Get")] 46 | 47 | public IResult Delete(Brand brand) 48 | { 49 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 50 | 51 | if (!result.Success) 52 | { 53 | return new ErrorResult(result.Message); 54 | } 55 | 56 | _brandDal.Delete(brand); 57 | return new SuccessResult(Messages.BrandDeleted); 58 | 59 | } 60 | 61 | [PerformanceAspect(5)] 62 | [CacheAspect] 63 | public IDataResult> GetAll() 64 | { 65 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 66 | 67 | if (!result.Success) 68 | { 69 | return new ErrorDataResult>(result.Message); 70 | } 71 | 72 | 73 | return new SuccessDataResult>(_brandDal.GetAll()); 74 | 75 | 76 | 77 | } 78 | 79 | [PerformanceAspect(5)] 80 | [CacheAspect(5)] 81 | public IDataResult GetById(int id) 82 | { 83 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 84 | 85 | if (!result.Success) 86 | { 87 | return new ErrorDataResult(result.Message); 88 | } 89 | 90 | 91 | return new SuccessDataResult(_brandDal.Get(c => c.BrandId == id)); 92 | 93 | 94 | 95 | 96 | } 97 | [SecuredOperation("admin")] 98 | [ValidationAspect(typeof(BrandValidator))] 99 | [CacheRemoveAspect("IBrandService.Get")] 100 | public IResult Update(Brand brand) 101 | { 102 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 103 | 104 | if (!result.Success) 105 | { 106 | return new ErrorResult(result.Message); 107 | } 108 | 109 | _brandDal.Update(brand); 110 | return new SuccessResult(Messages.BrandUpdated); 111 | 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /Business/Concrete/AuthManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Logics; 3 | using Business.ValidationRules.FluentValidation; 4 | using Core.Aspects.Autofac.Validation; 5 | using Core.Entities.Concrete; 6 | using Core.Utilities; 7 | using Core.Utilities.Business; 8 | using Core.Utilities.Security.Hashing; 9 | using Core.Utilities.Security.Jwt; 10 | using Entities.DTOs; 11 | using System; 12 | using System.Collections.Generic; 13 | using System.Text; 14 | 15 | namespace Business.Concrete 16 | { 17 | public class AuthManager : IAuthService 18 | { 19 | private IUserService _userService; 20 | private ITokenHelper _tokenHelper; 21 | 22 | public AuthManager(IUserService userService, ITokenHelper tokenHelper) 23 | { 24 | _userService = userService; 25 | _tokenHelper = tokenHelper; 26 | } 27 | [ValidationAspect(typeof(UserForRegisterDTOValidator))] 28 | public IDataResult Register(UserForRegisterDto userForRegisterDto) 29 | { 30 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 31 | if (!result.Success) 32 | { 33 | return new ErrorDataResult(result.Message); 34 | } 35 | byte[] passwordHash, passwordSalt; 36 | HashingHelper.CreatePasswordHash(userForRegisterDto.Password, out passwordHash, out passwordSalt); 37 | var user = new User 38 | { 39 | Email = userForRegisterDto.Email, 40 | FirstName = userForRegisterDto.FirstName, 41 | LastName = userForRegisterDto.LastName, 42 | PasswordHash = passwordHash, 43 | PasswordSalt = passwordSalt, 44 | Status = true 45 | }; 46 | _userService.Add(user); 47 | return new SuccessDataResult(user, Messages.UserRegistered); 48 | } 49 | 50 | [ValidationAspect(typeof(UserForLoginDTOValidator))] 51 | public IDataResult Login(UserForLoginDto userForLoginDto) 52 | { 53 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 54 | if (!result.Success) 55 | { 56 | return new ErrorDataResult(result.Message); 57 | } 58 | 59 | var userToCheck = _userService.GetByMail(userForLoginDto.Email).Data; 60 | if (userToCheck == null) 61 | { 62 | return new ErrorDataResult(userToCheck,Messages.UserNotFound); 63 | } 64 | 65 | if (!HashingHelper.VerifyPasswordHash(userForLoginDto.Password, userToCheck.PasswordHash, userToCheck.PasswordSalt)) 66 | { 67 | return new ErrorDataResult(userToCheck,Messages.PasswordError); 68 | } 69 | 70 | return new SuccessDataResult(userToCheck, Messages.SuccessLogin); 71 | } 72 | 73 | public IResult UserExists(string email) 74 | { 75 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 76 | if (!result.Success) 77 | { 78 | return new ErrorDataResult(); 79 | } 80 | 81 | var data = _userService.GetByMail(email); 82 | if (data.Data == null) 83 | { 84 | return new ErrorResult(); 85 | } 86 | return new SuccessResult(Messages.UserAlreadyExists); 87 | } 88 | 89 | public IDataResult CreateAccessToken(User user) 90 | { 91 | 92 | var claims = _userService.GetClaims(user).Data; 93 | var accessToken = _tokenHelper.CreateToken(user, claims); 94 | return new SuccessDataResult(accessToken); 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /Core/Utilities/Helpers/FileHelper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Text; 6 | 7 | namespace Core.Utilities.Helpers 8 | { 9 | public class FileHelper 10 | { 11 | private static string _currentDirectory = Environment.CurrentDirectory + "\\wwwroot"; 12 | private static string _folderName = "\\images\\"; 13 | 14 | public static IResult Upload(IFormFile file) 15 | { 16 | var fileExists = CheckFileExists(file); 17 | if (fileExists.Message != null) 18 | { 19 | return new ErrorResult(fileExists.Message); 20 | } 21 | 22 | var type = Path.GetExtension(file.FileName); 23 | var typeValid = CheckFileTypeValid(type); 24 | var randomName = Guid.NewGuid().ToString(); 25 | 26 | if (typeValid.Message != null) 27 | { 28 | return new ErrorResult(typeValid.Message); 29 | } 30 | 31 | CheckDirectoryExists(_currentDirectory + _folderName); 32 | CreateImageFile(_currentDirectory + _folderName + randomName + type, file); 33 | return new SuccessResult((_folderName + randomName + type).Replace("\\", "/")); 34 | 35 | 36 | 37 | } 38 | 39 | public static IResult Update(IFormFile file, string imagePath) 40 | { 41 | var fileExists = CheckFileExists(file); 42 | if (fileExists.Message != null) 43 | { 44 | return new ErrorResult(fileExists.Message); 45 | } 46 | 47 | var type = Path.GetExtension(file.FileName); 48 | var typeValid = CheckFileTypeValid(type); 49 | var randomName = Guid.NewGuid().ToString(); 50 | 51 | if (typeValid.Message != null) 52 | { 53 | return new ErrorResult(typeValid.Message); 54 | } 55 | 56 | DeleteOldImageFile((_currentDirectory + imagePath).Replace("/", "\\")); 57 | CheckDirectoryExists(_currentDirectory + _folderName); 58 | CreateImageFile(_currentDirectory + _folderName + randomName + type, file); 59 | return new SuccessResult((_folderName + randomName + type).Replace("\\", "/")); 60 | } 61 | 62 | public static IResult Delete(string path) 63 | { 64 | DeleteOldImageFile((_currentDirectory + path).Replace("/", "\\")); 65 | return new SuccessResult(); 66 | } 67 | 68 | 69 | 70 | 71 | private static IResult CheckFileExists(IFormFile file) 72 | { 73 | if (file != null && file.Length > 0) 74 | { 75 | return new SuccessResult(); 76 | } 77 | return new ErrorResult("File doesn't exists."); 78 | } 79 | 80 | 81 | private static IResult CheckFileTypeValid(string type) 82 | { 83 | if (type != ".jpeg" && type != ".png" && type != ".jpg") 84 | { 85 | return new ErrorResult("Wrong file type."); 86 | } 87 | return new SuccessResult(); 88 | } 89 | 90 | private static void CheckDirectoryExists(string directory) 91 | { 92 | if (!Directory.Exists(directory)) 93 | { 94 | Directory.CreateDirectory(directory); 95 | } 96 | } 97 | private static void CreateImageFile(string directory, IFormFile file) 98 | { 99 | using (FileStream fs = File.Create(directory)) 100 | { 101 | file.CopyTo(fs); 102 | fs.Flush(); 103 | } 104 | } 105 | 106 | private static void DeleteOldImageFile(string directory) 107 | { 108 | if (File.Exists(directory.Replace("/", "\\"))) 109 | { 110 | File.Delete(directory.Replace("/", "\\")); 111 | } 112 | 113 | } 114 | 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /Business/Concrete/UserManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Core.Utilities; 3 | using DataAccess.Abstract; 4 | using Entities.Concrete; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Text; 8 | using Core.Aspects.Autofac.Validation; 9 | using Business.ValidationRules.FluentValidation; 10 | using Core.Entities.Concrete; 11 | using Business.Aspects.Autofac; 12 | using Core.Utilities.Business; 13 | using Business.Logics; 14 | using Core.Aspects.Autofac.Caching; 15 | using Core.Aspects.Autofac.Performance; 16 | 17 | namespace Business.Concrete 18 | { 19 | public class UserManager : IUserService 20 | { 21 | IUserDal _userDal; 22 | 23 | public UserManager(IUserDal userDal) 24 | { 25 | _userDal = userDal; 26 | } 27 | 28 | [SecuredOperation("user")] 29 | [ValidationAspect(typeof(UserValidator))] 30 | [CacheRemoveAspect("IUserService.Get")] 31 | public IResult Add(User user) 32 | { 33 | IResult result = BusinessRules.Run( 34 | UserLogics.CheckIfEmailAlreadyExist(_userDal, user.Email), 35 | CommonLogics.SystemMaintenanceTime()); 36 | if (!result.Success) 37 | { 38 | return new ErrorResult(result.Message); 39 | } 40 | 41 | _userDal.Add(user); 42 | return new SuccessResult(Messages.UserAdded); 43 | 44 | 45 | } 46 | [SecuredOperation("user")] 47 | [CacheRemoveAspect("IUserService.Get")] 48 | public IResult Delete(User user) 49 | { 50 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 51 | 52 | if (!result.Success) 53 | { 54 | return new ErrorResult(result.Message); 55 | } 56 | 57 | _userDal.Delete(user); 58 | return new SuccessResult(Messages.UserDeleted); 59 | 60 | } 61 | 62 | [CacheAspect] 63 | public IDataResult> GetAll() 64 | { 65 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 66 | 67 | if (!result.Success) 68 | { 69 | return new ErrorDataResult>(result.Message); 70 | } 71 | 72 | return new SuccessDataResult>(_userDal.GetAll()); 73 | 74 | } 75 | [PerformanceAspect(5)] 76 | [CacheAspect(5)] 77 | public IDataResult GetByMail(string email) 78 | { 79 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 80 | 81 | if (!result.Success) 82 | { 83 | return new ErrorDataResult(result.Message); 84 | } 85 | 86 | return new SuccessDataResult(_userDal.Get(u => u.Email == email)); 87 | } 88 | [PerformanceAspect(5)] 89 | [CacheAspect(10)] 90 | public IDataResult GetById(int id) 91 | { 92 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 93 | 94 | if (!result.Success) 95 | { 96 | return new ErrorDataResult(result.Message); 97 | } 98 | 99 | return new SuccessDataResult(_userDal.Get(u => u.Id == id)); 100 | 101 | } 102 | [PerformanceAspect(5)] 103 | [CacheAspect] 104 | public IDataResult> GetClaims(User user) 105 | { 106 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 107 | 108 | if (!result.Success) 109 | { 110 | return new ErrorDataResult>(result.Message); 111 | } 112 | 113 | return new SuccessDataResult>(_userDal.GetClaims(user)); 114 | } 115 | 116 | [SecuredOperation("user")] 117 | [ValidationAspect(typeof(UserValidator))] 118 | [CacheRemoveAspect("IUserService.Get")] 119 | public IResult Update(User user) 120 | { 121 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 122 | 123 | if (!result.Success) 124 | { 125 | return new ErrorResult(result.Message); 126 | } 127 | _userDal.Update(user); 128 | return new SuccessResult(Messages.UserUpdated); 129 | 130 | } 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /Business/Concrete/CarManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Aspects.Autofac; 3 | using Business.Logics; 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; 9 | using Core.Utilities.Business; 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 CarManager : ICarService 19 | { 20 | ICarDal _carDal; 21 | 22 | public CarManager(ICarDal carDal) 23 | { 24 | _carDal = carDal; 25 | } 26 | 27 | [SecuredOperation("car.add")] 28 | [ValidationAspect(typeof(CarValidator))] 29 | [CacheRemoveAspect("ICarService.Get")] 30 | public IResult Add(Car car) 31 | { 32 | IResult result = BusinessRules.Run( 33 | CarLogics.CheckIfCarExists(_carDal, car), 34 | CarLogics.CheckIfCarCountOfBrandCorrect(_carDal, car.BrandId), 35 | CommonLogics.SystemMaintenanceTime()); 36 | if (!result.Success) 37 | { 38 | return new ErrorResult(result.Message); 39 | } 40 | 41 | _carDal.Add(car); 42 | return new SuccessResult(Messages.CarAdded); 43 | 44 | } 45 | 46 | 47 | [SecuredOperation("car.delete")] 48 | [CacheRemoveAspect("ICarService.Get")] 49 | public IResult Delete(Car car) 50 | { 51 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 52 | 53 | if (!result.Success) 54 | { 55 | return new ErrorResult(result.Message); 56 | } 57 | 58 | _carDal.Delete(car); 59 | return new SuccessResult(Messages.CarDeleted); 60 | 61 | } 62 | [PerformanceAspect(5)] 63 | [SecuredOperation("car.list")] 64 | [CacheAspect] 65 | public IDataResult> GetAll() 66 | { 67 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 68 | 69 | if (!result.Success) 70 | { 71 | return new ErrorDataResult>(result.Message); 72 | } 73 | 74 | return new SuccessDataResult>(_carDal.GetAll()); 75 | 76 | } 77 | [PerformanceAspect(5)] 78 | [CacheAspect(10)] 79 | public IDataResult GetById(int id) 80 | { 81 | 82 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 83 | 84 | if (!result.Success) 85 | { 86 | return new ErrorDataResult(result.Message); 87 | } 88 | 89 | return new SuccessDataResult(_carDal.Get(c => c.Id == id)); 90 | 91 | 92 | } 93 | [PerformanceAspect(5)] 94 | [CacheAspect] 95 | public IDataResult> GetCarDetails() 96 | { 97 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 98 | 99 | if (!result.Success) 100 | { 101 | return new ErrorDataResult>(result.Message); 102 | } 103 | 104 | 105 | return new SuccessDataResult>(_carDal.GetCarDetails()); 106 | 107 | 108 | 109 | 110 | } 111 | [CacheAspect(5)] 112 | public IDataResult> GetCarsByBrandId(int id) 113 | { 114 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 115 | 116 | if (!result.Success) 117 | { 118 | return new ErrorDataResult>(result.Message); 119 | } 120 | 121 | 122 | return new SuccessDataResult>(_carDal.GetAll(c => c.BrandId == id)); 123 | 124 | 125 | } 126 | [CacheAspect(5)] 127 | public IDataResult> GetCarsByColorId(int id) 128 | { 129 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 130 | 131 | if (!result.Success) 132 | { 133 | return new ErrorDataResult>(result.Message); 134 | } 135 | 136 | 137 | return new SuccessDataResult>(_carDal.GetAll(c => c.ColorId == id)); 138 | 139 | 140 | 141 | } 142 | 143 | 144 | [SecuredOperation("car.update")] 145 | [ValidationAspect(typeof(CarValidator))] 146 | [CacheRemoveAspect("ICarService.Get")] 147 | public IResult Update(Car car) 148 | { 149 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 150 | 151 | if (!result.Success) 152 | { 153 | return new ErrorResult(result.Message); 154 | } 155 | 156 | _carDal.Update(car); 157 | return new SuccessResult(Messages.CarUpdated); 158 | 159 | } 160 | 161 | 162 | 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /Business/Concrete/CarImageManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Aspects.Autofac; 3 | using Business.Logics; 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; 9 | using Core.Utilities.Business; 10 | using Core.Utilities.Helpers; 11 | using DataAccess.Abstract; 12 | using Entities.Concrete; 13 | using Microsoft.AspNetCore.Http; 14 | using System; 15 | using System.Collections.Generic; 16 | using System.IO; 17 | using System.Linq; 18 | using System.Text; 19 | 20 | namespace Business.Concrete 21 | { 22 | public class CarImageManager : ICarImageService 23 | { 24 | 25 | ICarImageDal _carImageDal; 26 | 27 | public CarImageManager(ICarImageDal carImageDal) 28 | { 29 | _carImageDal = carImageDal; 30 | } 31 | 32 | [SecuredOperation("admin")] 33 | [ValidationAspect(typeof(CarImageValidator))] 34 | [CacheRemoveAspect("ICarImageService.Get")] 35 | public IResult Add(IFormFile file, CarImage carImage) 36 | { 37 | var result = BusinessRules.Run(CheckIfCarImageLimit(carImage.CarId) 38 | ,CommonLogics.SystemMaintenanceTime()); 39 | 40 | if (!result.Success) 41 | { 42 | return new ErrorResult(result.Message); 43 | } 44 | 45 | var imageResult = FileHelper.Upload(file); 46 | 47 | if (!imageResult.Success) 48 | { 49 | return new ErrorResult(imageResult.Message); 50 | } 51 | carImage.ImagePath = imageResult.Message; 52 | _carImageDal.Add(carImage); 53 | return new SuccessResult(Messages.CarImageAdded); 54 | } 55 | 56 | [SecuredOperation("admin")] 57 | public IResult Delete(CarImage carImage) 58 | { 59 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 60 | if (!result.Success) 61 | { 62 | return new ErrorResult(result.Message); 63 | } 64 | 65 | 66 | var image = _carImageDal.Get(c => c.Id == carImage.Id); 67 | if (image == null) 68 | { 69 | return new ErrorResult(Messages.CarImageNotFound); 70 | } 71 | 72 | FileHelper.Delete(image.ImagePath); 73 | _carImageDal.Delete(carImage); 74 | return new SuccessResult(Messages.CarImageDeleted); 75 | } 76 | 77 | [SecuredOperation("admin")] 78 | [ValidationAspect(typeof(CarImageValidator))] 79 | [CacheRemoveAspect("ICarImageService.Get")] 80 | public IResult Update(IFormFile file, CarImage carImage) 81 | { 82 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 83 | if (!result.Success) 84 | { 85 | return new ErrorResult(result.Message); 86 | } 87 | 88 | var isImage = _carImageDal.Get(c => c.Id == carImage.Id); 89 | if (isImage == null) 90 | { 91 | return new ErrorResult(Messages.CarImageNotFound); 92 | } 93 | 94 | var updatedFile = FileHelper.Update(file, isImage.ImagePath); 95 | if (!updatedFile.Success) 96 | { 97 | return new ErrorResult(updatedFile.Message); 98 | } 99 | carImage.ImagePath = updatedFile.Message; 100 | _carImageDal.Update(carImage); 101 | return new SuccessResult(Messages.CarImageUpdated); 102 | } 103 | 104 | [PerformanceAspect(5)] 105 | [CacheAspect(10)] 106 | public IDataResult Get(int id) 107 | { 108 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 109 | if (!result.Success) 110 | { 111 | return new ErrorDataResult(result.Message); 112 | } 113 | 114 | return new SuccessDataResult(_carImageDal.Get(p => p.Id == id)); 115 | } 116 | [PerformanceAspect(5)] 117 | [CacheAspect] 118 | public IDataResult> GetAll() 119 | { 120 | var result = BusinessRules.Run(CommonLogics.SystemMaintenanceTime()); 121 | if (!result.Success) 122 | { 123 | return new ErrorDataResult>(result.Message); 124 | } 125 | return new SuccessDataResult>(_carImageDal.GetAll()); 126 | } 127 | 128 | [PerformanceAspect(5)] 129 | [CacheAspect] 130 | public IDataResult> GetCarImagesByCarId(int id) 131 | { 132 | 133 | IResult result = BusinessRules.Run(CheckIfCarImageNull(id) 134 | ,CommonLogics.SystemMaintenanceTime()); 135 | 136 | if (!result.Success) 137 | { 138 | return new ErrorDataResult>(result.Message); 139 | } 140 | 141 | return new SuccessDataResult>(CheckIfCarImageNull(id).Data); 142 | } 143 | 144 | //Business Rules 145 | 146 | public IDataResult> CheckIfCarImageNull(int id) 147 | { 148 | try 149 | { 150 | string path = @"\images\logo.jpg"; 151 | var result = _carImageDal.GetAll(c => c.CarId == id).Any(); 152 | if (!result) 153 | { 154 | List carImage = new List(); 155 | carImage.Add(new CarImage { CarId = id, ImagePath = path, Date = DateTime.Now }); 156 | return new SuccessDataResult>(carImage); 157 | } 158 | } 159 | catch (Exception exception) 160 | { 161 | 162 | return new ErrorDataResult>(exception.Message); 163 | } 164 | 165 | return new SuccessDataResult>(_carImageDal.GetAll(p => p.CarId == id).ToList()); 166 | } 167 | 168 | private IResult CheckIfCarImageLimit(int carImageId) 169 | { 170 | var result = _carImageDal.GetAll(c => c.CarId == carImageId).Count; 171 | 172 | if (result > 5) 173 | { 174 | return new ErrorResult(Messages.CarImageLimitFail); 175 | } 176 | return new SuccessResult(); 177 | 178 | } 179 | 180 | private IResult CarImageDelete(CarImage carImage) 181 | { 182 | try 183 | { 184 | File.Delete(carImage.ImagePath); 185 | } 186 | catch (Exception exception) 187 | { 188 | 189 | return new ErrorResult(exception.Message); 190 | } 191 | 192 | return new SuccessResult(); 193 | } 194 | 195 | } 196 | 197 | } 198 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd --------------------------------------------------------------------------------