├── Core ├── Entities │ ├── Abstract │ │ ├── IDto.cs │ │ ├── IEntity.cs │ │ └── IEntityService.cs │ └── Concrete │ │ ├── OperationClaim.cs │ │ ├── UserOperationClaim.cs │ │ └── User.cs ├── Utilities │ ├── Results │ │ ├── IDataResult.cs │ │ ├── IResult.cs │ │ ├── ErrorResult.cs │ │ ├── SuccessResult.cs │ │ ├── DataResult.cs │ │ ├── Result.cs │ │ ├── SuccessDataResult.cs │ │ └── ErrorDataResult.cs │ ├── IoC │ │ ├── ICoreModule.cs │ │ └── ServiceTool.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 ├── CrossCuttingConcerns │ ├── Caching │ │ ├── ICacheManager.cs │ │ └── Microsoft │ │ │ └── MemoryCacheManager.cs │ └── Validation │ │ └── ValidationTool.cs ├── DataAccess │ ├── IEntityRepository.cs │ └── EntityFramework │ │ └── EfEntityRepositoryBase.cs ├── Extensions │ ├── ServiceCollectionExtensions.cs │ ├── ClaimsPrincipalExtensions.cs │ └── ClaimExtensions.cs ├── DependencyResolves │ └── CoreModule.cs ├── Aspects │ └── Autofac │ │ ├── Caching │ │ ├── CacheRemoveAspect.cs │ │ └── CacheAspect.cs │ │ ├── Transaction │ │ └── TransactionScopeAspect.cs │ │ ├── Performance │ │ └── PerformanceAspect.cs │ │ └── Validation │ │ └── ValidationAspect.cs └── Core.csproj ├── WebAPI ├── Images │ ├── 2dc2265a-aedb-4fca-9e99-9e9a73e0da6c.jpg │ ├── 2e03fb1d-311f-4b5c-a226-c176f4e856c3.jpg │ ├── 593ce513-35b9-4f0c-bda0-970a4296867a.jpg │ ├── 9657cc27-2910-4480-bdee-713343802172.jpg │ ├── c15fe8b7-0a87-4001-91b2-81a1c4903d11.jpg │ ├── 770030d0-419d-4207-bba8-319ab1a5fb53_3_5_2021.jpg │ └── c98018fe-1b2a-437e-b53c-d959918923b8_3_5_2021.jpg ├── appsettings.Development.json ├── WeatherForecast.cs ├── appsettings.json ├── WebAPI.csproj ├── Properties │ └── launchSettings.json ├── Program.cs ├── Controllers │ ├── WeatherForecastController.cs │ ├── AuthController.cs │ ├── BrandsController.cs │ ├── ColorsController.cs │ ├── UsersController.cs │ ├── CustomersController.cs │ ├── RentCarsController.cs │ ├── CarImagesController.cs │ └── CarsController.cs └── Startup.cs ├── DataAccess ├── Abstract │ ├── IBrandsDal.cs │ ├── IColorDal.cs │ ├── ICarImageDal.cs │ ├── ICustomerDal.cs │ ├── IUserDal.cs │ ├── IRentCarDal.cs │ └── ICarDal.cs ├── Concrete │ ├── EntityFrameWork │ │ ├── EfCarImageDal.cs │ │ ├── EfCustomerDal.cs │ │ ├── EfColorDal.cs │ │ ├── EfBrandDal.cs │ │ ├── CarsRentalContext.cs │ │ ├── EfUserDal.cs │ │ ├── EfCarDal.cs │ │ └── EfRentCarDal.cs │ └── InMemory │ │ └── InMemoryCarDal.cs └── DataAccess.csproj ├── Business ├── CCS │ ├── ILogger.cs │ ├── DatabaseLogger.cs │ └── FileLogger.cs ├── Abstract │ ├── IColorService.cs │ ├── IBrandService.cs │ ├── ICustomerService.cs │ ├── IUserService.cs │ ├── IRentCarService.cs │ ├── ICarService.cs │ ├── IAuthService.cs │ └── ICarImageService.cs ├── ValidationRules │ └── FluentValidation │ │ ├── CarImageValidator.cs │ │ ├── BrandValidator.cs │ │ ├── ColorValidator.cs │ │ ├── RentCarValidator.cs │ │ ├── CustomerValidator.cs │ │ ├── UserValidator.cs │ │ └── CarValidator.cs ├── Business.csproj ├── BusinessAspects │ └── Autofac │ │ └── SecuredOperation.cs ├── Concrete │ ├── CustomerManager.cs │ ├── ColorManager.cs │ ├── BrandManager.cs │ ├── RentCarManager.cs │ ├── AuthManager.cs │ ├── CarManager.cs │ ├── UserManager.cs │ └── CarImageManager.cs ├── DependencyResolves │ └── Autofac │ │ └── AutofacBusinessModule.cs └── Constants │ └── Messages.cs ├── Entities ├── Concrete │ ├── Brand.cs │ ├── Color.cs │ ├── Customer.cs │ ├── CarImage.cs │ ├── CarRental.cs │ └── Car.cs ├── DTOs │ ├── UserForLoginDto.cs │ ├── UserForRegisterDto.cs │ ├── CarDetailDto.cs │ └── CarsRentalDetailDto.cs └── Entities.csproj ├── ReCap ├── ReCap.csproj └── Program.cs ├── .gitattributes ├── ReCapProject.sln └── .gitignore /Core/Entities/Abstract/IDto.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Entities.Abstract 2 | { 3 | public interface IDto 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /Core/Entities/Abstract/IEntity.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Entities.Abstract 2 | { 3 | public interface IEntity 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /WebAPI/Images/2dc2265a-aedb-4fca-9e99-9e9a73e0da6c.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maliyalcin/ReCapProject/HEAD/WebAPI/Images/2dc2265a-aedb-4fca-9e99-9e9a73e0da6c.jpg -------------------------------------------------------------------------------- /WebAPI/Images/2e03fb1d-311f-4b5c-a226-c176f4e856c3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maliyalcin/ReCapProject/HEAD/WebAPI/Images/2e03fb1d-311f-4b5c-a226-c176f4e856c3.jpg -------------------------------------------------------------------------------- /WebAPI/Images/593ce513-35b9-4f0c-bda0-970a4296867a.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maliyalcin/ReCapProject/HEAD/WebAPI/Images/593ce513-35b9-4f0c-bda0-970a4296867a.jpg -------------------------------------------------------------------------------- /WebAPI/Images/9657cc27-2910-4480-bdee-713343802172.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maliyalcin/ReCapProject/HEAD/WebAPI/Images/9657cc27-2910-4480-bdee-713343802172.jpg -------------------------------------------------------------------------------- /WebAPI/Images/c15fe8b7-0a87-4001-91b2-81a1c4903d11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maliyalcin/ReCapProject/HEAD/WebAPI/Images/c15fe8b7-0a87-4001-91b2-81a1c4903d11.jpg -------------------------------------------------------------------------------- /WebAPI/Images/770030d0-419d-4207-bba8-319ab1a5fb53_3_5_2021.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maliyalcin/ReCapProject/HEAD/WebAPI/Images/770030d0-419d-4207-bba8-319ab1a5fb53_3_5_2021.jpg -------------------------------------------------------------------------------- /WebAPI/Images/c98018fe-1b2a-437e-b53c-d959918923b8_3_5_2021.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maliyalcin/ReCapProject/HEAD/WebAPI/Images/c98018fe-1b2a-437e-b53c-d959918923b8_3_5_2021.jpg -------------------------------------------------------------------------------- /DataAccess/Abstract/IBrandsDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Entities.Concrete; 3 | 4 | namespace DataAccess.Abstract 5 | { 6 | public interface IBrandsDal:IEntityRepository 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Business/CCS/ILogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Business.CCS 6 | { 7 | public interface ILogger 8 | { 9 | void Log(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /WebAPI/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Entities/Concrete/Brand.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Abstract; 2 | 3 | namespace Entities.Concrete 4 | { 5 | public class Brand:IEntity 6 | { 7 | public int BrandId { get; set; } 8 | public string BrandName { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Core/Utilities/Results/IDataResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results 6 | { 7 | public interface IDataResult:IResult 8 | { 9 | T Data { get; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Entities/DTOs/UserForLoginDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Abstract; 2 | 3 | namespace Entities.DTOs 4 | { 5 | public class UserForLoginDto : IDto 6 | { 7 | public string Email { get; set; } 8 | public string Password { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /Business/CCS/DatabaseLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Business.CCS 4 | { 5 | public class DatabaseLogger : ILogger 6 | { 7 | public void Log() 8 | { 9 | Console.WriteLine("Veri tabanına loglandı."); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Core/Utilities/Results/IResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results 6 | { 7 | public interface IResult 8 | { 9 | bool Success { get; } 10 | string Message { get; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /DataAccess/Abstract/IColorDal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.DataAccess; 5 | using Entities.Concrete; 6 | 7 | namespace DataAccess.Abstract 8 | { 9 | public interface IColorDal:IEntityRepository 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /DataAccess/Abstract/ICarImageDal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.DataAccess; 5 | using Entities.Concrete; 6 | 7 | namespace DataAccess.Abstract 8 | { 9 | public interface ICarImageDal:IEntityRepository 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /DataAccess/Abstract/ICustomerDal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.DataAccess; 5 | using Entities.Concrete; 6 | 7 | namespace DataAccess.Abstract 8 | { 9 | public interface ICustomerDal:IEntityRepository 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Business/CCS/FileLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Business.CCS 6 | { 7 | public class FileLogger:ILogger 8 | { 9 | public void Log() 10 | { 11 | Console.WriteLine("Dosyaya loglandı."); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Business/Abstract/IColorService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.Entities; 5 | using Core.Entities.Abstract; 6 | using Entities.Concrete; 7 | 8 | namespace Business.Abstract 9 | { 10 | public interface IColorService:IEntityService 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Core/Utilities/IoC/ICoreModule.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Microsoft.Extensions.DependencyInjection; 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 | -------------------------------------------------------------------------------- /Core/Entities/Concrete/OperationClaim.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.Entities.Abstract; 5 | 6 | namespace Core.Entities.Concrete 7 | { 8 | public class OperationClaim:IEntity 9 | { 10 | public int Id { get; set; } 11 | public string Name { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Core/Utilities/Security/JWT/ITokenHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.Entities.Concrete; 5 | 6 | namespace Core.Utilities.Security.JWT 7 | { 8 | public interface ITokenHelper 9 | { 10 | AccessToken CreateToken(User user, List operationClaims); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Business/Abstract/IBrandService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.Entities; 5 | using Core.Entities.Abstract; 6 | using Core.Utilities.Results; 7 | using Entities.Concrete; 8 | 9 | namespace Business.Abstract 10 | { 11 | public interface IBrandService:IEntityService 12 | { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Entities/Concrete/Color.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.Entities; 5 | using Core.Entities.Abstract; 6 | 7 | namespace Entities.Concrete 8 | { 9 | public class Color:IEntity 10 | { 11 | public int ColorId { get; set; } 12 | public string ColorName { get; set; } 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Entities/Entities.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /WebAPI/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace WebAPI 4 | { 5 | public class WeatherForecast 6 | { 7 | public DateTime Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | 13 | public string Summary { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Business/Abstract/ICustomerService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.Entities; 5 | using Core.Entities.Abstract; 6 | using Core.Utilities.Results; 7 | using Entities.Concrete; 8 | 9 | namespace Business.Abstract 10 | { 11 | public interface ICustomerService:IEntityService 12 | { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /DataAccess/Abstract/IUserDal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.DataAccess; 5 | using Core.Entities.Concrete; 6 | using Entities.Concrete; 7 | 8 | namespace DataAccess.Abstract 9 | { 10 | public interface IUserDal:IEntityRepository 11 | { 12 | List GetClaims(User user); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /DataAccess/Abstract/IRentCarDal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.DataAccess; 5 | using Entities.Concrete; 6 | using Entities.DTOs; 7 | 8 | namespace DataAccess.Abstract 9 | { 10 | public interface IRentCarDal:IEntityRepository 11 | { 12 | List GetCarsRentalDetail(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /DataAccess/Abstract/ICarDal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.DataAccess; 5 | using Core.Utilities.Results; 6 | using Entities.Concrete; 7 | using Entities.DTOs; 8 | 9 | namespace DataAccess.Abstract 10 | { 11 | public interface ICarDal:IEntityRepository 12 | { 13 | List GetCarDetails(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Core/Utilities/Results/ErrorResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results 6 | { 7 | public class ErrorResult:Result 8 | { 9 | public ErrorResult(string message) : base(false, message) 10 | { 11 | } 12 | 13 | public ErrorResult() : base(false) 14 | { 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Core/Utilities/Results/SuccessResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results 6 | { 7 | public class SuccessResult:Result 8 | { 9 | public SuccessResult(string message) : base(true, message) 10 | { 11 | } 12 | 13 | public SuccessResult() : base(true) 14 | { 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Core/Entities/Concrete/UserOperationClaim.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.Entities.Abstract; 5 | 6 | namespace Core.Entities.Concrete 7 | { 8 | public class UserOperationClaim : IEntity 9 | { 10 | public int Id { get; set; } 11 | public int UserId { get; set; } 12 | public int OperationClaimId { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFrameWork/EfCarImageDal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.DataAccess.EntityFramework; 5 | using DataAccess.Abstract; 6 | using Entities.Concrete; 7 | 8 | namespace DataAccess.Concrete.EntityFrameWork 9 | { 10 | public class EfCarImageDal:EfEntityRepositoryBase,ICarImageDal 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFrameWork/EfCustomerDal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.DataAccess.EntityFramework; 5 | using DataAccess.Abstract; 6 | using Entities.Concrete; 7 | 8 | namespace DataAccess.Concrete.EntityFrameWork 9 | { 10 | public class EfCustomerDal:EfEntityRepositoryBase,ICustomerDal 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Entities/Concrete/Customer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.Entities; 5 | using Core.Entities.Abstract; 6 | 7 | namespace Entities.Concrete 8 | { 9 | public class Customer:IEntity 10 | { 11 | public int CustomerId { get; set; } 12 | public int UserId { get; set; } 13 | public string CompanyName { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Core/Entities/Abstract/IEntityService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Core.Utilities.Results; 3 | 4 | namespace Core.Entities.Abstract 5 | { 6 | public interface IEntityService 7 | { 8 | IDataResult> GetAll(); 9 | IDataResult GetById(int id); 10 | IResult Add(T entity); 11 | IResult Update(T entity); 12 | IResult Delete(T entity); 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 | -------------------------------------------------------------------------------- /WebAPI/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "TokenOptions": { 3 | "Audience": "ali@ali.com", 4 | "Issuer": "ali@ali.com", 5 | "AccessTokenExpiration": 10, 6 | "SecurityKey": "mysupersecretkeymysupersecretkey" 7 | }, 8 | "Logging": { 9 | "LogLevel": { 10 | "Default": "Information", 11 | "Microsoft": "Warning", 12 | "Microsoft.Hosting.Lifetime": "Information" 13 | } 14 | }, 15 | "AllowedHosts": "*" 16 | } 17 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFrameWork/EfColorDal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq.Expressions; 4 | using System.Text; 5 | using Core.DataAccess.EntityFramework; 6 | using DataAccess.Abstract; 7 | using Entities.Concrete; 8 | 9 | namespace DataAccess.Concrete.EntityFrameWork 10 | { 11 | public class EfColorDal:EfEntityRepositoryBase,IColorDal 12 | { 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Entities/DTOs/UserForRegisterDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.Entities.Abstract; 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/Abstract/IUserService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.Entities; 5 | using Core.Entities.Abstract; 6 | using Core.Entities.Concrete; 7 | using Entities.Concrete; 8 | 9 | namespace Business.Abstract 10 | { 11 | public interface IUserService :IEntityService 12 | { 13 | List GetClaims(User user); 14 | User GetByMail(string email); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Entities/Concrete/CarImage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.Entities; 5 | using Core.Entities.Abstract; 6 | 7 | namespace Entities.Concrete 8 | { 9 | public class CarImage:IEntity 10 | { 11 | public int Id { get; set; } 12 | public int CarId { get; set; } 13 | public string ImagePath { get; set; } 14 | public DateTime Date { get; set; } 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ReCap/ReCap.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Business/Abstract/IRentCarService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.Entities; 5 | using Core.Entities.Abstract; 6 | using Core.Utilities.Results; 7 | using Entities.Concrete; 8 | using Entities.DTOs; 9 | 10 | namespace Business.Abstract 11 | { 12 | public interface IRentCarService:IEntityService 13 | { 14 | IDataResult> GetCarsRentalDetail(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /DataAccess/DataAccess.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Core/CrossCuttingConcerns/Caching/ICacheManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.CrossCuttingConcerns.Caching 6 | { 7 | public interface ICacheManager 8 | { 9 | T Get(string key); 10 | object Get(string key); 11 | void Add(string key, object value, int duration); 12 | bool IsAdd(string key); 13 | void Remove(string key); 14 | void RemoveByPattern(string pattern); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFrameWork/EfBrandDal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Linq.Expressions; 5 | using System.Text; 6 | using Core.DataAccess.EntityFramework; 7 | using DataAccess.Abstract; 8 | using Entities.Concrete; 9 | using Microsoft.EntityFrameworkCore; 10 | 11 | namespace DataAccess.Concrete.EntityFrameWork 12 | { 13 | public class EfBrandDal:EfEntityRepositoryBase,IBrandsDal 14 | { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Entities/Concrete/CarRental.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.Entities; 5 | using Core.Entities.Abstract; 6 | 7 | namespace Entities.Concrete 8 | { 9 | public class CarRental:IEntity 10 | { 11 | public int Id { get; set; } 12 | public int CarId { get; set; } 13 | public int CustomerId { get; set; } 14 | public DateTime RentDate { get; set; } 15 | public DateTime ReturnDate { get; set; } 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/CarImageValidator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Entities.Concrete; 5 | using FluentValidation; 6 | 7 | namespace Business.ValidationRules.FluentValidation 8 | { 9 | public class CarImageValidator:AbstractValidator 10 | { 11 | public CarImageValidator() 12 | { 13 | RuleFor(c => c.CarId).NotNull(); 14 | RuleFor(c => c.Id).NotNull(); 15 | 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Core/DataAccess/IEntityRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Abstract; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq.Expressions; 5 | 6 | namespace Core.DataAccess 7 | { 8 | public interface IEntityRepository where T : class, IEntity, new() 9 | { 10 | List GetAll(Expression> filter = null); 11 | T Get(Expression> filter); 12 | void Add(T entity); 13 | void Update(T entity); 14 | void Delete(T entity); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Core/Utilities/Security/Encryption/SigningCredentialsHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Microsoft.IdentityModel.Tokens; 5 | 6 | namespace Core.Utilities.Security.Encryption 7 | { 8 | public class SigningCredentialsHelper 9 | { 10 | public static SigningCredentials CreateSigningCredentials(SecurityKey securityKey) 11 | { 12 | return new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha512Signature); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Core/Entities/Concrete/User.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using Core.Entities.Abstract; 3 | 4 | namespace Core.Entities.Concrete 5 | { 6 | public class User:IEntity 7 | { 8 | public int Id { get; set; } 9 | public string FirstName { get; set; } 10 | public string LastName { get; set; } 11 | public string Email { get; set; } 12 | public byte[] PasswordHash { get; set; } 13 | public byte[] PasswordSalt { get; set; } 14 | public bool Status { get; set; } 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Core/Utilities/IoC/ServiceTool.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Utilities.IoC 7 | { 8 | public static class ServiceTool 9 | { 10 | public static IServiceProvider ServiceProvider { get; private set; } 11 | 12 | public static IServiceCollection Create(IServiceCollection services) 13 | { 14 | ServiceProvider = services.BuildServiceProvider(); 15 | return services; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Core/Utilities/Results/DataResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results 6 | { 7 | public class DataResult:Result,IDataResult 8 | { 9 | public DataResult(T data, bool success, string message) : base(success, message) 10 | { 11 | Data = data; 12 | } 13 | 14 | public DataResult(T data, bool success) : base(success) 15 | { 16 | Data = data; 17 | } 18 | 19 | public T Data { get; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Core/Utilities/Results/Result.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results 6 | { 7 | public class Result:IResult 8 | { 9 | public Result(bool success, string message) : this(success) 10 | { 11 | Message = message; 12 | } 13 | 14 | public Result(bool success) 15 | { 16 | Success = success; 17 | } 18 | 19 | public bool Success { get; set; } 20 | public string Message { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/BrandValidator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Entities.Concrete; 5 | using FluentValidation; 6 | 7 | namespace Business.ValidationRules.FluentValidation 8 | { 9 | public class BrandValidator:AbstractValidator 10 | { 11 | public BrandValidator() 12 | { 13 | RuleFor(b => b.BrandId).NotEmpty(); 14 | RuleFor(b => b.BrandName).NotEmpty(); 15 | RuleFor(b => b.BrandName).MinimumLength(2); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/ColorValidator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Entities.Concrete; 5 | using FluentValidation; 6 | 7 | namespace Business.ValidationRules.FluentValidation 8 | { 9 | public class ColorValidator:AbstractValidator 10 | { 11 | public ColorValidator() 12 | { 13 | RuleFor(c => c.ColorId).NotEmpty(); 14 | RuleFor(c => c.ColorName).NotEmpty(); 15 | RuleFor(c => c.ColorName).MinimumLength(2); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/RentCarValidator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Entities.Concrete; 5 | using FluentValidation; 6 | 7 | namespace Business.ValidationRules.FluentValidation 8 | { 9 | public class RentCarValidator:AbstractValidator 10 | { 11 | public RentCarValidator() 12 | { 13 | RuleFor(c => c.CarId).NotEmpty(); 14 | RuleFor(c => c.CustomerId).NotEmpty(); 15 | RuleFor(c => c.RentDate).NotEmpty(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Core/Utilities/Business/BusinessRules.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.Utilities.Results; 5 | 6 | namespace Core.Utilities.Business 7 | { 8 | public class BusinessRules 9 | { 10 | public static IResult Run(params IResult[] logics) 11 | { 12 | foreach (var logic in logics) 13 | { 14 | if (!logic.Success) 15 | { 16 | return logic; 17 | } 18 | } 19 | return null; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Entities/Concrete/Car.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.Entities; 5 | using Core.Entities.Abstract; 6 | 7 | namespace Entities.Concrete 8 | { 9 | public class Car:IEntity 10 | { 11 | public int CarId { 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 decimal DailyPrice { get; set; } 17 | public string Description { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Core/Utilities/Interceptors/MethodInterceptionBaseAttribute.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Utilities.Interceptors 7 | { 8 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] 9 | public abstract class MethodInterceptionBaseAttribute : Attribute, IInterceptor 10 | { 11 | public int Priority { get; set; } 12 | 13 | public virtual void Intercept(IInvocation invocation) 14 | { 15 | 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Entities/DTOs/CarDetailDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.Entities; 5 | using Core.Entities.Abstract; 6 | 7 | namespace Entities.DTOs 8 | { 9 | public class CarDetailDto:IDto 10 | { 11 | public int CarId { get; set; } 12 | public string CarName { get; set; } 13 | public string BrandName { get; set; } 14 | public string ColorName { get; set; } 15 | public decimal DailyPrice { get; set; } 16 | public int ModelYear { get; set; } 17 | public string Description { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Core/Utilities/Results/SuccessDataResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results 6 | { 7 | public class SuccessDataResult:DataResult 8 | { 9 | public SuccessDataResult(T data, string message) : base(data, true, message) 10 | { 11 | 12 | } 13 | 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 | } 25 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Business/Abstract/ICarService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.Entities; 5 | using Core.Entities.Abstract; 6 | using Core.Utilities.Results; 7 | using Entities.Concrete; 8 | using Entities.DTOs; 9 | 10 | namespace Business.Abstract 11 | { 12 | public interface ICarService:IEntityService 13 | { 14 | IDataResult> GetAllByBrandId(int brandId); 15 | IDataResult> GetAllByColorId(int colorId); 16 | IDataResult> GetCarDetails(); 17 | IResult AddTransactionalTest(Car car); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Business/Abstract/IAuthService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.Entities.Concrete; 5 | using Core.Utilities.Results; 6 | using Core.Utilities.Security.JWT; 7 | using Entities.DTOs; 8 | 9 | namespace Business.Abstract 10 | { 11 | public interface IAuthService 12 | { 13 | IDataResult Register(UserForRegisterDto userForRegisterDto, string password); 14 | IDataResult Login(UserForLoginDto userForLoginDto); 15 | IResult UserExists(string email); 16 | IDataResult CreateAccessToken(User user); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/CustomerValidator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Entities.Concrete; 5 | using FluentValidation; 6 | 7 | namespace Business.ValidationRules.FluentValidation 8 | { 9 | public class CustomerValidator:AbstractValidator 10 | { 11 | public CustomerValidator() 12 | { 13 | RuleFor(c => c.CustomerId).NotEmpty(); 14 | RuleFor(c => c.CompanyName).NotEmpty(); 15 | RuleFor(c => c.CompanyName).MinimumLength(2); 16 | RuleFor(c => c.UserId).NotEmpty(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Business/Abstract/ICarImageService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.Entities; 5 | using Core.Utilities.Results; 6 | using Entities.Concrete; 7 | using Microsoft.AspNetCore.Http; 8 | 9 | namespace Business.Abstract 10 | { 11 | public interface ICarImageService 12 | { 13 | IDataResult> GetAll(); 14 | IDataResult Get(int id); 15 | IResult Add(IFormFile file, CarImage carImage); 16 | IResult Update(IFormFile file, CarImage carImage); 17 | IResult Delete(CarImage carImage); 18 | IDataResult> GetImagesByCarId(int id); 19 | 20 | 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Core/Extensions/ServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.Utilities.IoC; 5 | using Microsoft.Extensions.DependencyInjection; 6 | 7 | namespace Core.Extensions 8 | { 9 | public static class ServiceCollectionExtensions 10 | { 11 | public static IServiceCollection AddDependencyResolves(this IServiceCollection serviceCollection, 12 | ICoreModule[] modules) 13 | { 14 | foreach (var module in modules) 15 | { 16 | module.Load(serviceCollection); 17 | } 18 | 19 | return ServiceTool.Create(serviceCollection); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Core/Utilities/Results/ErrorDataResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results 6 | { 7 | public class ErrorDataResult : DataResult 8 | { 9 | public ErrorDataResult(T data, string message) : base(data, false, message) 10 | { 11 | } 12 | 13 | public ErrorDataResult(T data) : base(data, false) 14 | { 15 | } 16 | 17 | public ErrorDataResult(string message) : base(default, false, message) 18 | { 19 | 20 | } 21 | 22 | public ErrorDataResult() : base(default, false) 23 | { 24 | 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Core/CrossCuttingConcerns/Validation/ValidationTool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using FluentValidation; 5 | using Microsoft.EntityFrameworkCore.Infrastructure; 6 | 7 | namespace Core.CrossCuttingConcerns.Validation 8 | { 9 | public static class ValidationTool 10 | { 11 | public static void Validate(IValidator validator,object entity) 12 | { 13 | var context = new ValidationContext(entity); 14 | var result = validator.Validate(context); 15 | if (!result.IsValid) 16 | { 17 | throw new ValidationException(result.Errors); 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /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/UserValidator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.Entities.Concrete; 5 | using Entities.Concrete; 6 | using FluentValidation; 7 | 8 | namespace Business.ValidationRules.FluentValidation 9 | { 10 | public class UserValidator:AbstractValidator 11 | { 12 | public UserValidator() 13 | { 14 | RuleFor(u => u.Id).NotEmpty(); 15 | RuleFor(u => u.FirstName).NotEmpty(); 16 | RuleFor(u => u.FirstName).MinimumLength(2); 17 | RuleFor(u => u.LastName).NotEmpty(); 18 | RuleFor(u => u.LastName).MinimumLength(2); 19 | RuleFor(u => u.Email).NotEmpty(); 20 | RuleFor(u => u.Email).EmailAddress(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/CarValidator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Entities.Concrete; 5 | using FluentValidation; 6 | 7 | namespace Business.ValidationRules.FluentValidation 8 | { 9 | public class CarValidator:AbstractValidator 10 | { 11 | public CarValidator() 12 | { 13 | RuleFor(c => c.BrandId).NotEmpty(); 14 | RuleFor(c => c.CarId).NotEmpty(); 15 | RuleFor(c => c.ColorId).NotEmpty(); 16 | RuleFor(c => c.CarName).MinimumLength(1); 17 | RuleFor(c => c.ModelYear).NotEmpty(); 18 | RuleFor(c => c.DailyPrice).NotEmpty(); 19 | RuleFor(c => c.DailyPrice).GreaterThan(50); 20 | RuleFor(c => c.Description).NotEmpty(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Core/DependencyResolves/CoreModule.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Text; 5 | using Core.CrossCuttingConcerns.Caching; 6 | using Core.CrossCuttingConcerns.Caching.Microsoft; 7 | using Core.Utilities.IoC; 8 | using Microsoft.AspNetCore.Http; 9 | using Microsoft.Extensions.DependencyInjection; 10 | 11 | namespace Core.DependencyResolves 12 | { 13 | public class CoreModule:ICoreModule 14 | { 15 | public void Load(IServiceCollection serviceCollection) 16 | { 17 | serviceCollection.AddMemoryCache(); 18 | serviceCollection.AddSingleton(); 19 | serviceCollection.AddSingleton(); 20 | serviceCollection.AddSingleton(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Core/Aspects/Autofac/Caching/CacheRemoveAspect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Castle.DynamicProxy; 5 | using Core.CrossCuttingConcerns.Caching; 6 | using Core.Utilities.Interceptors; 7 | using Core.Utilities.IoC; 8 | using Microsoft.Extensions.DependencyInjection; 9 | 10 | namespace Core.Aspects.Autofac.Caching 11 | { 12 | public class CacheRemoveAspect : MethodInterception 13 | { 14 | private string _pattern; 15 | private ICacheManager _cacheManager; 16 | 17 | public CacheRemoveAspect(string pattern) 18 | { 19 | _pattern = pattern; 20 | _cacheManager = ServiceTool.ServiceProvider.GetService(); 21 | } 22 | 23 | protected override void OnSuccess(IInvocation invocation) 24 | { 25 | _cacheManager.RemoveByPattern(_pattern); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Entities/DTOs/CarsRentalDetailDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.Entities; 5 | using Core.Entities.Abstract; 6 | 7 | namespace Entities.DTOs 8 | { 9 | public class CarsRentalDetailDto:IDto 10 | { 11 | public int Id { get; set; } 12 | public string CarName { get; set; } 13 | public string BrandName { get; set; } 14 | public string UserName { get; set; } 15 | public string CompanyName { get; set; } 16 | public DateTime RentDate { get; set; } 17 | public DateTime ReturnDate { get; set; } 18 | //public int ModelYear { get; set; } 19 | //public decimal DailyPrice { get; set; } 20 | //public string Description { get; set; } 21 | //public int CarId { get; set; } 22 | //public int CustomerId { get; set; } 23 | //public string ColorName { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Core/Aspects/Autofac/Transaction/TransactionScopeAspect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Transactions; 5 | using Castle.DynamicProxy; 6 | using Core.Utilities.Interceptors; 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:62255", 8 | "sslPort": 44375 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/Utilities/Interceptors/AspectInterceptorSelector.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Reflection; 4 | using Castle.DynamicProxy; 5 | using Core.Aspects.Autofac.Performance; 6 | 7 | namespace Core.Utilities.Interceptors 8 | { 9 | public class AspectInterceptorSelector : IInterceptorSelector 10 | { 11 | public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors) 12 | { 13 | var classAttributes = type.GetCustomAttributes 14 | (true).ToList(); 15 | var methodAttributes = type.GetMethod(method.Name) 16 | .GetCustomAttributes(true); 17 | classAttributes.AddRange(methodAttributes); 18 | classAttributes.Add(new PerformanceAspect(10)); 19 | 20 | return classAttributes.OrderBy(x => x.Priority).ToArray(); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Business/Business.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Core/Core.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /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 | } 34 | } 35 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFrameWork/CarsRentalContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.Entities.Concrete; 5 | using Entities.Concrete; 6 | using Microsoft.EntityFrameworkCore; 7 | 8 | namespace DataAccess.Concrete.EntityFrameWork 9 | { 10 | public class CarsRentalContext:DbContext 11 | { 12 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 13 | { 14 | optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=CarsRental;Trusted_Connection=true"); 15 | } 16 | 17 | public DbSet CarRentals { get; set; } 18 | public DbSet Cars { get; set; } 19 | public DbSet Colors { get; set; } 20 | public DbSet Brands { get; set; } 21 | public DbSet Customers { get; set; } 22 | public DbSet Users { get; set; } 23 | public DbSet CarImages { get; set; } 24 | public DbSet OperationClaims { get; set; } 25 | public DbSet UserOperationClaims { get; set; } 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Core/Utilities/Interceptors/MethodInterception.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Castle.DynamicProxy; 3 | 4 | namespace Core.Utilities.Interceptors 5 | { 6 | public abstract class MethodInterception : MethodInterceptionBaseAttribute 7 | { 8 | protected virtual void OnBefore(IInvocation invocation) { } 9 | protected virtual void OnAfter(IInvocation invocation) { } 10 | protected virtual void OnException(IInvocation invocation, System.Exception e) { } 11 | protected virtual void OnSuccess(IInvocation invocation) { } 12 | public override void Intercept(IInvocation invocation) 13 | { 14 | var isSuccess = true; 15 | OnBefore(invocation); 16 | try 17 | { 18 | invocation.Proceed(); 19 | } 20 | catch (Exception e) 21 | { 22 | isSuccess = false; 23 | OnException(invocation, e); 24 | throw; 25 | } 26 | finally 27 | { 28 | if (isSuccess) 29 | { 30 | OnSuccess(invocation); 31 | } 32 | } 33 | OnAfter(invocation); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFrameWork/EfUserDal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Core.DataAccess.EntityFramework; 6 | using Core.Entities.Concrete; 7 | using DataAccess.Abstract; 8 | using Entities.Concrete; 9 | 10 | namespace DataAccess.Concrete.EntityFrameWork 11 | { 12 | public class EfUserDal:EfEntityRepositoryBase,IUserDal 13 | { 14 | public List GetClaims(User user) 15 | { 16 | using (var context = new CarsRentalContext()) 17 | { 18 | var result = 19 | from operationClaim in context.OperationClaims 20 | join userOperationClaim in context.UserOperationClaims on operationClaim.Id equals 21 | userOperationClaim.OperationClaimId 22 | where userOperationClaim.UserId == user.Id 23 | select new OperationClaim 24 | { 25 | Id = operationClaim.Id, 26 | Name = operationClaim.Name 27 | 28 | }; 29 | return result.ToList(); 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /WebAPI/Program.cs: -------------------------------------------------------------------------------- 1 | using Autofac.Extensions.DependencyInjection; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.Extensions.Configuration; 4 | using Microsoft.Extensions.Hosting; 5 | using Microsoft.Extensions.Logging; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Threading.Tasks; 10 | using Autofac; 11 | using Business.DependencyResolves.Autofac; 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 | //.ConfigureContainer 30 | .ConfigureWebHostDefaults(webBuilder => 31 | { 32 | webBuilder.UseStartup(); 33 | }); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Core/Aspects/Autofac/Performance/PerformanceAspect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Text; 5 | using Castle.DynamicProxy; 6 | using Core.Utilities.Interceptors; 7 | using Core.Utilities.IoC; 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 | return true; 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Business/BusinessAspects/Autofac/SecuredOperation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Core.Utilities.Interceptors; 5 | using Core.Utilities.IoC; 6 | using Microsoft.AspNetCore.Http; 7 | using Castle.DynamicProxy; 8 | using Microsoft.Extensions.DependencyInjection; 9 | using Business.Constants; 10 | using Core.Extensions; 11 | 12 | namespace Business.BusinessAspects.Autofac 13 | { 14 | public class SecuredOperation : MethodInterception 15 | { 16 | private string[] _roles; 17 | private IHttpContextAccessor _httpContextAccessor; 18 | 19 | public SecuredOperation(string roles) 20 | { 21 | _roles = roles.Split(','); 22 | _httpContextAccessor = ServiceTool.ServiceProvider.GetService(); 23 | 24 | } 25 | 26 | protected override void OnBefore(IInvocation invocation) 27 | { 28 | var roleClaims = _httpContextAccessor.HttpContext.User.ClaimRoles(); 29 | foreach (var role in _roles) 30 | { 31 | if (roleClaims.Contains(role)) 32 | { 33 | return; 34 | } 35 | } 36 | throw new Exception(Messages.AuthorizationDenied); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /WebAPI/Controllers/WeatherForecastController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.Extensions.Logging; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | namespace WebAPI.Controllers 9 | { 10 | [ApiController] 11 | [Route("[controller]")] 12 | public class WeatherForecastController : ControllerBase 13 | { 14 | private static readonly string[] Summaries = new[] 15 | { 16 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" 17 | }; 18 | 19 | private readonly ILogger _logger; 20 | 21 | public WeatherForecastController(ILogger logger) 22 | { 23 | _logger = logger; 24 | } 25 | 26 | [HttpGet] 27 | public IEnumerable Get() 28 | { 29 | var rng = new Random(); 30 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast 31 | { 32 | Date = DateTime.Now.AddDays(index), 33 | TemperatureC = rng.Next(-20, 55), 34 | Summary = Summaries[rng.Next(Summaries.Length)] 35 | }) 36 | .ToArray(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /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 | //defensive coding 18 | if (!typeof(IValidator).IsAssignableFrom(validatorType)) 19 | { 20 | throw new System.Exception("Bu bir doğrulama sınıf değil."); 21 | } 22 | 23 | _validatorType = validatorType; 24 | } 25 | protected override void OnBefore(IInvocation invocation) 26 | { 27 | var validator = (IValidator)Activator.CreateInstance(_validatorType); 28 | var entityType = _validatorType.BaseType.GetGenericArguments()[0]; 29 | var entities = invocation.Arguments.Where(t => t.GetType() == entityType); 30 | foreach (var entity in entities) 31 | { 32 | ValidationTool.Validate(validator, entity); 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFrameWork/EfCarDal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Core.DataAccess.EntityFramework; 6 | using Core.Utilities.Results; 7 | using DataAccess.Abstract; 8 | using Entities.Concrete; 9 | using Entities.DTOs; 10 | 11 | namespace DataAccess.Concrete.EntityFrameWork 12 | { 13 | public class EfCarDal:EfEntityRepositoryBase,ICarDal 14 | { 15 | public List GetCarDetails() 16 | { 17 | using (CarsRentalContext context = new CarsRentalContext()) 18 | { 19 | var result = from car in context.Cars 20 | join brand in context.Brands on car.BrandId equals brand.BrandId 21 | join color in context.Colors on car.ColorId equals color.ColorId 22 | select new CarDetailDto 23 | { 24 | CarId = car.CarId, 25 | CarName = car.CarName, 26 | BrandName = brand.BrandName, 27 | ColorName = color.ColorName, 28 | DailyPrice = car.DailyPrice, 29 | Description = car.Description, 30 | ModelYear = car.ModelYear 31 | }; 32 | return result.ToList(); 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Core/Aspects/Autofac/Caching/CacheAspect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Castle.DynamicProxy; 6 | using Core.CrossCuttingConcerns.Caching; 7 | using Core.Utilities.Interceptors; 8 | using Core.Utilities.IoC; 9 | using Microsoft.Extensions.DependencyInjection; 10 | 11 | namespace Core.Aspects.Autofac.Caching 12 | { 13 | public class CacheAspect : MethodInterception 14 | { 15 | private int _duration; 16 | private ICacheManager _cacheManager; 17 | 18 | public CacheAspect(int duration = 60) 19 | { 20 | _duration = duration; 21 | _cacheManager = ServiceTool.ServiceProvider.GetService(); 22 | } 23 | 24 | public override void Intercept(IInvocation invocation) 25 | { 26 | var methodName = string.Format($"{invocation.Method.ReflectedType.FullName}.{invocation.Method.Name}"); 27 | var arguments = invocation.Arguments.ToList(); 28 | var key = $"{methodName}({string.Join(",", arguments.Select(x => x?.ToString() ?? ""))})"; 29 | if (_cacheManager.IsAdd(key)) 30 | { 31 | invocation.ReturnValue = _cacheManager.Get(key); 32 | return; 33 | } 34 | invocation.Proceed(); 35 | _cacheManager.Add(key, invocation.ReturnValue, _duration); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Business/Concrete/CustomerManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Business.Abstract; 5 | using Business.Constants; 6 | using Business.ValidationRules.FluentValidation; 7 | using Core.Aspects.Autofac.Validation; 8 | using Core.Utilities.Results; 9 | using DataAccess.Abstract; 10 | using Entities.Concrete; 11 | 12 | namespace Business.Concrete 13 | { 14 | public class CustomerManager:ICustomerService 15 | { 16 | ICustomerDal _customerDal; 17 | 18 | public CustomerManager(ICustomerDal customerDal) 19 | { 20 | _customerDal = customerDal; 21 | } 22 | 23 | public IDataResult> GetAll() 24 | { 25 | return new SuccessDataResult>(_customerDal.GetAll(), Messages.CustomerList); 26 | } 27 | 28 | public IDataResult GetById(int id) 29 | { 30 | return new SuccessDataResult(_customerDal.Get(c => c.CustomerId == id)); 31 | } 32 | 33 | [ValidationAspect(typeof(CustomerValidator))] 34 | public IResult Add(Customer customer) 35 | { 36 | _customerDal.Add(customer); 37 | return new SuccessResult(Messages.CustomerAdded); 38 | } 39 | 40 | public IResult Update(Customer customer) 41 | { 42 | _customerDal.Update(customer); 43 | return new SuccessResult(Messages.CustomerUpdated); 44 | } 45 | 46 | public IResult Delete(Customer customer) 47 | { 48 | _customerDal.Delete(customer); 49 | return new SuccessResult(Messages.CustomerDeleted); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Business/Concrete/ColorManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Business.Abstract; 5 | using Business.BusinessAspects.Autofac; 6 | using Business.Constants; 7 | using Business.ValidationRules.FluentValidation; 8 | using Core.Aspects.Autofac.Validation; 9 | using Core.Utilities.Results; 10 | using DataAccess.Abstract; 11 | using Entities.Concrete; 12 | 13 | namespace Business.Concrete 14 | { 15 | public class ColorManager:IColorService 16 | { 17 | IColorDal _colorDal; 18 | 19 | public ColorManager(IColorDal colorDal) 20 | { 21 | _colorDal = colorDal; 22 | } 23 | 24 | public IDataResult> GetAll() 25 | { 26 | return new SuccessDataResult>(_colorDal.GetAll(), Messages.ColorListed); 27 | } 28 | 29 | public IDataResult GetById(int id) 30 | { 31 | return new SuccessDataResult(_colorDal.Get(c => c.ColorId == id)); 32 | } 33 | 34 | [SecuredOperation("color.add,admin")] 35 | [ValidationAspect(typeof(ColorValidator))] 36 | public IResult Add(Color color) 37 | { 38 | _colorDal.Add(color); 39 | return new SuccessResult(Messages.ColorAdded); 40 | } 41 | 42 | [SecuredOperation("color.update,admin")] 43 | public IResult Update(Color color) 44 | { 45 | _colorDal.Update(color); 46 | return new SuccessResult(Messages.ColorUpdated); 47 | } 48 | 49 | [SecuredOperation("color.delete,admin")] 50 | public IResult Delete(Color color) 51 | { 52 | _colorDal.Delete(color); 53 | return new SuccessResult(Messages.ColorDeleted); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Business/Concrete/BrandManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Business.Abstract; 5 | using Business.BusinessAspects.Autofac; 6 | using Business.Constants; 7 | using Business.ValidationRules.FluentValidation; 8 | using Core.Aspects.Autofac.Validation; 9 | using Core.Utilities.Results; 10 | using DataAccess.Abstract; 11 | using Entities.Concrete; 12 | 13 | namespace Business.Concrete 14 | { 15 | public class BrandManager:IBrandService 16 | { 17 | IBrandsDal _brandsDal; 18 | 19 | public BrandManager(IBrandsDal brandsDal) 20 | { 21 | _brandsDal = brandsDal; 22 | } 23 | 24 | public IDataResult> GetAll() 25 | { 26 | return new SuccessDataResult>(_brandsDal.GetAll(), Messages.BrandList); 27 | } 28 | 29 | public IDataResult GetById(int id) 30 | { 31 | return new SuccessDataResult(_brandsDal.Get(b => b.BrandId == id)); 32 | } 33 | 34 | [SecuredOperation("brand.add,admin")] 35 | [ValidationAspect(typeof(BrandValidator))] 36 | public IResult Add(Brand brand) 37 | { 38 | _brandsDal.Add(brand); 39 | return new SuccessResult(Messages.BrandAdded); 40 | } 41 | 42 | [SecuredOperation("brand.update,admin")] 43 | public IResult Update(Brand brand) 44 | { 45 | _brandsDal.Update(brand); 46 | return new SuccessResult(Messages.BrandUpdated); 47 | } 48 | 49 | [SecuredOperation("brand.delete,admin")] 50 | public IResult Delete(Brand brand) 51 | { 52 | _brandsDal.Delete(brand); 53 | return new SuccessResult(Messages.BrandDeleted); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /WebAPI/Controllers/AuthController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Microsoft.AspNetCore.Mvc; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using Business.Abstract; 8 | using Entities.DTOs; 9 | 10 | namespace WebAPI.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class AuthController : Controller 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, userForRegisterDto.Password); 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 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFrameWork/EfRentCarDal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Linq.Expressions; 5 | using System.Text; 6 | using Core.DataAccess.EntityFramework; 7 | using DataAccess.Abstract; 8 | using Entities.Concrete; 9 | using Entities.DTOs; 10 | using Microsoft.EntityFrameworkCore; 11 | 12 | namespace DataAccess.Concrete.EntityFrameWork 13 | { 14 | public class EfRentCarDal : EfEntityRepositoryBase, IRentCarDal 15 | { 16 | public List GetCarsRentalDetail() 17 | { 18 | using (CarsRentalContext context = new CarsRentalContext()) 19 | { 20 | var result = from carRental in context.CarRentals 21 | join car in context.Cars on carRental.CarId equals car.CarId 22 | join customer in context.Customers on carRental.CustomerId equals customer.CustomerId 23 | join user in context.Users on customer.UserId equals user.Id 24 | join brand in context.Brands on car.BrandId equals brand.BrandId 25 | join color in context.Colors on car.ColorId equals color.ColorId 26 | select new CarsRentalDetailDto 27 | { 28 | 29 | Id = carRental.Id, 30 | CarName = car.CarName, 31 | BrandName = brand.BrandName, 32 | UserName = user.FirstName + " " + user.LastName, 33 | CompanyName = customer.CompanyName, 34 | RentDate = carRental.RentDate, 35 | ReturnDate = carRental.ReturnDate, 36 | 37 | }; 38 | return result.ToList(); 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /ReCap/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Business.Concrete; 3 | using DataAccess.Concrete; 4 | using DataAccess.Concrete.EntityFrameWork; 5 | using Entities.Concrete; 6 | 7 | namespace ReCap 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | //CarRentalList(); 14 | //AddCustomer(); 15 | //AddCar(); 16 | } 17 | 18 | private static void AddCar() 19 | { 20 | CarManager carManager = new CarManager(new EfCarDal()); 21 | carManager.Add(new Car 22 | { 23 | CarId = 1, CarName = "Civic", ColorId = 3, BrandId = 6, ModelYear = 2019, DailyPrice = 150, 24 | Description = "Konfora düşkün insanlar için." 25 | }); 26 | } 27 | 28 | private static void AddCustomer() 29 | { 30 | CustomerManager customerManager = new CustomerManager(new EfCustomerDal()); 31 | customerManager.Add(new Customer {UserId = 1, CompanyName = "Eflatun"}); 32 | foreach (var customer in customerManager.GetAll().Data) 33 | { 34 | Console.WriteLine(customer.CompanyName); 35 | } 36 | } 37 | 38 | //private static void CarRentalList() 39 | //{ 40 | // RentCarManager rentCarManager = new RentCarManager(new EfRentCarDal()); 41 | 42 | // foreach (var car in rentCarManager.GetCarsRentalDetail().Data) 43 | // { 44 | // Console.WriteLine( 45 | // car.CarId + " " + 46 | // @" Brand : {0} / Color : {1} / Model : {2} / Model Year : {3} / Daily Price : {4} TL / Description : {5} ", 47 | // car.BrandName, car.ColorName, car.CarName, car.ModelYear, car.DailyPrice, car.Description); 48 | 49 | // Console.WriteLine("-------------------------------------------------------------------------"); 50 | // } 51 | //} 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /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 | using Core.Utilities.Results; 7 | 8 | namespace Core.Utilities.Helpers 9 | { 10 | public class FileHelper 11 | { 12 | public static string Add(IFormFile file) 13 | { 14 | var sourcePath = Path.GetTempFileName(); 15 | if (file.Length > 0) 16 | { 17 | using (var stream = new FileStream(sourcePath, FileMode.Create)) 18 | { 19 | file.CopyTo(stream); 20 | } 21 | } 22 | var result = newPath(file); 23 | File.Move(sourcePath, result); 24 | return result; 25 | } 26 | 27 | public static IResult Delete(string path) 28 | { 29 | try 30 | { 31 | File.Delete(path); 32 | } 33 | catch (Exception exception) 34 | { 35 | return new ErrorResult(exception.Message); 36 | } 37 | 38 | return new SuccessResult(); 39 | } 40 | 41 | public static string Update(string sourcePath, IFormFile file) 42 | { 43 | var result = newPath(file); 44 | if (sourcePath.Length>0) 45 | { 46 | using (var stream = new FileStream(result, FileMode.Create)) 47 | { 48 | file.CopyTo(stream); 49 | } 50 | } 51 | File.Delete(sourcePath); 52 | return result; 53 | } 54 | 55 | public static string newPath(IFormFile file) 56 | { 57 | FileInfo fileInfo = new FileInfo(file.FileName); 58 | string fileExtension = fileInfo.Extension; 59 | 60 | string path = Environment.CurrentDirectory + @"\Images"; 61 | var newPath = Guid.NewGuid().ToString() + fileExtension; 62 | 63 | string result = $@"{path}\{newPath}"; 64 | return result; 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Core/DataAccess/EntityFramework/EfEntityRepositoryBase.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Abstract; 2 | using Microsoft.EntityFrameworkCore; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Linq.Expressions; 7 | 8 | namespace Core.DataAccess.EntityFramework 9 | { 10 | public class EfEntityRepositoryBase : IEntityRepository 11 | where TEntity:class, IEntity, new() 12 | where TContext:DbContext,new() 13 | { 14 | public List GetAll(Expression> filter = null) 15 | { 16 | using (TContext context = new TContext()) 17 | { 18 | return filter == null 19 | ? context.Set().ToList() 20 | : context.Set().Where(filter).ToList(); 21 | } 22 | } 23 | 24 | public TEntity Get(Expression> filter) 25 | { 26 | using (TContext context = new TContext()) 27 | { 28 | return context.Set().SingleOrDefault(filter); 29 | } 30 | } 31 | 32 | 33 | public void Add(TEntity entity) 34 | { 35 | using (TContext context = new TContext()) 36 | { 37 | var addedEntity = context.Entry(entity); 38 | addedEntity.State = EntityState.Added; 39 | context.SaveChanges(); 40 | } 41 | } 42 | 43 | public void Update(TEntity entity) 44 | { 45 | using (TContext context = new TContext()) 46 | { 47 | var updatedEntity = context.Entry(entity); 48 | updatedEntity.State = EntityState.Modified; 49 | context.SaveChanges(); 50 | } 51 | } 52 | 53 | public void Delete(TEntity entity) 54 | { 55 | using (TContext context = new TContext()) 56 | { 57 | var deletedEntity = context.Entry(entity); 58 | deletedEntity.State = EntityState.Deleted; 59 | context.SaveChanges(); 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Business/Concrete/RentCarManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Business.Abstract; 5 | using Business.Constants; 6 | using Business.ValidationRules.FluentValidation; 7 | using Core.Aspects.Autofac.Validation; 8 | using Core.Utilities.Results; 9 | using DataAccess.Abstract; 10 | using Entities.Concrete; 11 | using Entities.DTOs; 12 | 13 | namespace Business.Concrete 14 | { 15 | public class RentCarManager:IRentCarService 16 | { 17 | IRentCarDal _rentCarDal; 18 | 19 | public RentCarManager(IRentCarDal rentCarDal) 20 | { 21 | _rentCarDal = rentCarDal; 22 | } 23 | 24 | [ValidationAspect(typeof(RentCarValidator))] 25 | public IResult Add(CarRental carRental) 26 | { 27 | _rentCarDal.Add(new CarRental()); 28 | return new Result(true, Messages.CarRentalAdded); 29 | } 30 | 31 | public IResult Update(CarRental carRental) 32 | { 33 | _rentCarDal.Update(carRental); 34 | return new Result(true, Messages.CarRentalUpdated); 35 | } 36 | 37 | public IResult Delete(CarRental carRental) 38 | { 39 | _rentCarDal.Delete(carRental); 40 | return new SuccessResult(Messages.CarRentalDeleted); 41 | } 42 | 43 | public IDataResult> GetAll() 44 | { 45 | if (DateTime.Now.Hour==20) 46 | { 47 | //return new ErrorDataResult>(Messages.MaintenanceTime); 48 | return new ErrorDataResult>(Messages.MaintenanceTime); 49 | } 50 | return new SuccessDataResult>(_rentCarDal.GetAll(),Messages.CarRentalListed); 51 | } 52 | 53 | public IDataResult GetById(int id) 54 | { 55 | return new SuccessDataResult(_rentCarDal.Get(cr => cr.Id == id)); 56 | } 57 | 58 | public IDataResult> GetCarsRentalDetail() 59 | { 60 | return new SuccessDataResult>(_rentCarDal.GetCarsRentalDetail()); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /WebAPI/Controllers/BrandsController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Microsoft.AspNetCore.Mvc; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using Business.Abstract; 8 | using Entities.Concrete; 9 | 10 | namespace WebAPI.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class BrandsController : ControllerBase 15 | { 16 | IBrandService _brandService; 17 | 18 | public BrandsController(IBrandService brandService) 19 | { 20 | _brandService = brandService; 21 | } 22 | 23 | [HttpGet("getall")] 24 | public IActionResult GetAll() 25 | { 26 | var result = _brandService.GetAll(); 27 | if (result.Success) 28 | { 29 | return Ok(result); 30 | } 31 | 32 | return BadRequest(result); 33 | } 34 | 35 | [HttpGet("getbyid")] 36 | public IActionResult GetById(int id) 37 | { 38 | var result = _brandService.GetById(id); 39 | if (result.Success) 40 | { 41 | return Ok(result); 42 | } 43 | 44 | return BadRequest(result); 45 | } 46 | 47 | [HttpPost("add")] 48 | public IActionResult Add(Brand brand) 49 | { 50 | var result = _brandService.Add(brand); 51 | if (result.Success) 52 | { 53 | return Ok(result); 54 | } 55 | 56 | return BadRequest(result); 57 | } 58 | 59 | [HttpPost("update")] 60 | public IActionResult Update(Brand brand) 61 | { 62 | var result = _brandService.Update(brand); 63 | if (result.Success) 64 | { 65 | return Ok(result); 66 | } 67 | 68 | return BadRequest(result); 69 | } 70 | 71 | [HttpPost("delete")] 72 | public IActionResult Delete(Brand brand) 73 | { 74 | var result = _brandService.Delete(brand); 75 | if (result.Success) 76 | { 77 | return Ok(result); 78 | } 79 | 80 | return BadRequest(result); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /WebAPI/Controllers/ColorsController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Microsoft.AspNetCore.Mvc; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using Business.Abstract; 8 | using Entities.Concrete; 9 | 10 | namespace WebAPI.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class ColorsController : ControllerBase 15 | { 16 | IColorService _colorService; 17 | 18 | public ColorsController(IColorService colorService) 19 | { 20 | _colorService = colorService; 21 | } 22 | 23 | [HttpGet("getall")] 24 | public IActionResult GetAll() 25 | { 26 | var result = _colorService.GetAll(); 27 | if (result.Success) 28 | { 29 | return Ok(result); 30 | } 31 | 32 | return BadRequest(result); 33 | } 34 | 35 | [HttpGet("getbyid")] 36 | public IActionResult GetById(int id) 37 | { 38 | var result = _colorService.GetById(id); 39 | if (result.Success) 40 | { 41 | return Ok(result); 42 | } 43 | 44 | return BadRequest(result); 45 | } 46 | 47 | [HttpPost("add")] 48 | public IActionResult Add(Color color) 49 | { 50 | var result = _colorService.Add(color); 51 | if (result.Success) 52 | { 53 | return Ok(result); 54 | } 55 | 56 | return BadRequest(result); 57 | } 58 | 59 | [HttpPost("update")] 60 | public IActionResult Update(Color color) 61 | { 62 | var result = _colorService.Update(color); 63 | if (result.Success) 64 | { 65 | return Ok(result); 66 | } 67 | 68 | return BadRequest(result); 69 | } 70 | 71 | [HttpPost("delete")] 72 | public IActionResult Delete(Color color) 73 | { 74 | var result = _colorService.Delete(color); 75 | if (result.Success) 76 | { 77 | return Ok(result); 78 | } 79 | 80 | return BadRequest(result); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /WebAPI/Controllers/UsersController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Microsoft.AspNetCore.Mvc; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using Business.Abstract; 8 | using Core.Entities.Concrete; 9 | using Entities.Concrete; 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 | [HttpGet("getall")] 25 | public IActionResult GetAll() 26 | { 27 | var result = _userService.GetAll(); 28 | if (result.Success) 29 | { 30 | return Ok(result); 31 | } 32 | 33 | return BadRequest(result); 34 | } 35 | 36 | [HttpGet("getbyid")] 37 | public IActionResult GetById(int id) 38 | { 39 | var result = _userService.GetById(id); 40 | if (result.Success) 41 | { 42 | return Ok(result); 43 | } 44 | 45 | return BadRequest(result); 46 | } 47 | 48 | [HttpPost("add")] 49 | public IActionResult Add(User user) 50 | { 51 | var result = _userService.Add(user); 52 | if (result.Success) 53 | { 54 | return Ok(result); 55 | } 56 | 57 | return BadRequest(result); 58 | } 59 | 60 | [HttpPost("update")] 61 | public IActionResult Update(User user) 62 | { 63 | var result = _userService.Update(user); 64 | if (result.Success) 65 | { 66 | return Ok(result); 67 | } 68 | 69 | return BadRequest(result); 70 | } 71 | 72 | [HttpPost("delete")] 73 | public IActionResult Delete(User user) 74 | { 75 | var result = _userService.Delete(user); 76 | if (result.Success) 77 | { 78 | return Ok(result); 79 | } 80 | 81 | return BadRequest(result); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /WebAPI/Controllers/CustomersController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Microsoft.AspNetCore.Mvc; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using Business.Abstract; 8 | using Entities.Concrete; 9 | 10 | namespace WebAPI.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class CustomersController : ControllerBase 15 | { 16 | ICustomerService _customerService; 17 | 18 | public CustomersController(ICustomerService customerService) 19 | { 20 | _customerService = customerService; 21 | } 22 | 23 | [HttpGet("getall")] 24 | public IActionResult GetAll() 25 | { 26 | var result = _customerService.GetAll(); 27 | if (result.Success) 28 | { 29 | return Ok(result); 30 | } 31 | 32 | return BadRequest(result); 33 | } 34 | 35 | [HttpGet("getbyid")] 36 | public IActionResult GetById(int id) 37 | { 38 | var result = _customerService.GetById(id); 39 | if (result.Success) 40 | { 41 | return Ok(result); 42 | } 43 | 44 | return BadRequest(result); 45 | } 46 | 47 | [HttpPost("add")] 48 | public IActionResult Add(Customer customer) 49 | { 50 | var result = _customerService.Add(customer); 51 | if (result.Success) 52 | { 53 | return Ok(result); 54 | } 55 | 56 | return BadRequest(result); 57 | } 58 | 59 | [HttpPost("update")] 60 | public IActionResult Update(Customer customer) 61 | { 62 | var result = _customerService.Update(customer); 63 | if (result.Success) 64 | { 65 | return Ok(result); 66 | } 67 | 68 | return BadRequest(result); 69 | } 70 | 71 | [HttpPost("delete")] 72 | public IActionResult Delete(Customer customer) 73 | { 74 | var result = _customerService.Delete(customer); 75 | if (result.Success) 76 | { 77 | return Ok(result); 78 | } 79 | 80 | return BadRequest(result); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Business/DependencyResolves/Autofac/AutofacBusinessModule.cs: -------------------------------------------------------------------------------- 1 | using Autofac; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | using Business.Abstract; 6 | using Business.Concrete; 7 | using DataAccess.Abstract; 8 | using DataAccess.Concrete.EntityFrameWork; 9 | using Autofac.Extras.DynamicProxy; 10 | using Business.CCS; 11 | using Core.Utilities.Interceptors; 12 | using Castle.DynamicProxy; 13 | using Core.Utilities.Security.JWT; 14 | 15 | namespace Business.DependencyResolves.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(); 43 | builder.RegisterType().As(); 44 | 45 | var assembly = System.Reflection.Assembly.GetExecutingAssembly(); 46 | 47 | builder.RegisterAssemblyTypes(assembly).AsImplementedInterfaces() 48 | .EnableInterfaceInterceptors(new ProxyGenerationOptions() 49 | { 50 | Selector = new AspectInterceptorSelector() 51 | }).SingleInstance(); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Core/CrossCuttingConcerns/Caching/Microsoft/MemoryCacheManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Text.RegularExpressions; 6 | using Core.Utilities.IoC; 7 | using Microsoft.Extensions.Caching.Memory; 8 | using Microsoft.Extensions.DependencyInjection; 9 | 10 | namespace Core.CrossCuttingConcerns.Caching.Microsoft 11 | { 12 | public class MemoryCacheManager:ICacheManager 13 | { 14 | IMemoryCache _memoryCache; 15 | 16 | public MemoryCacheManager() 17 | { 18 | _memoryCache = ServiceTool.ServiceProvider.GetService(); 19 | } 20 | public T Get(string key) 21 | { 22 | return _memoryCache.Get(key); 23 | } 24 | 25 | public object Get(string key) 26 | { 27 | return _memoryCache.Get(key); 28 | } 29 | 30 | public void Add(string key, object value, int duration) 31 | { 32 | _memoryCache.Set(key, value, TimeSpan.FromMinutes(duration)); 33 | } 34 | 35 | public bool IsAdd(string key) 36 | { 37 | return _memoryCache.TryGetValue(key, out _); 38 | } 39 | 40 | public void Remove(string key) 41 | { 42 | _memoryCache.Remove(key); 43 | } 44 | 45 | public void RemoveByPattern(string pattern) 46 | { 47 | var cacheEntriesCollectionDefinition = typeof(MemoryCache).GetProperty("EntriesCollection", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); 48 | var cacheEntriesCollection = cacheEntriesCollectionDefinition.GetValue(_memoryCache) as dynamic; 49 | List cacheCollectionValues = new List(); 50 | 51 | foreach (var cacheItem in cacheEntriesCollection) 52 | { 53 | ICacheEntry cacheItemValue = cacheItem.GetType().GetProperty("Value").GetValue(cacheItem, null); 54 | cacheCollectionValues.Add(cacheItemValue); 55 | } 56 | 57 | var regex = new Regex(pattern, RegexOptions.Singleline | RegexOptions.Compiled | RegexOptions.IgnoreCase); 58 | var keysToRemove = cacheCollectionValues.Where(d => regex.IsMatch(d.Key.ToString())).Select(d => d.Key).ToList(); 59 | 60 | foreach (var key in keysToRemove) 61 | { 62 | _memoryCache.Remove(key); 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /DataAccess/Concrete/InMemory/InMemoryCarDal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Linq.Expressions; 5 | using System.Text; 6 | using Core.DataAccess; 7 | using Core.Utilities.Results; 8 | using DataAccess.Abstract; 9 | using Entities.Concrete; 10 | using Entities.DTOs; 11 | 12 | namespace DataAccess.Concrete 13 | { 14 | public class InMemoryCarDal:ICarDal 15 | { 16 | List _cars; 17 | 18 | public InMemoryCarDal() 19 | { 20 | _cars = new List 21 | { 22 | new Car{CarId = 1, ColorId = 2, BrandId = 3, ModelYear = 1997, DailyPrice = 125, Description = "Çok uygun fiyattan kiralama."}, 23 | new Car{CarId = 2, ColorId = 4, BrandId = 2, ModelYear = 2008, DailyPrice = 185, Description = "Çok uygun fiyattan kiralama."}, 24 | new Car{CarId = 3, ColorId = 1, BrandId = 2, ModelYear = 2019, DailyPrice = 155, Description = "Çok uygun fiyattan kiralama."}, 25 | new Car{CarId = 4, ColorId = 5, BrandId = 4, ModelYear = 2020, DailyPrice = 130, Description = "Çok uygun fiyattan kiralama."}, 26 | 27 | }; 28 | } 29 | 30 | public List GetById() 31 | { 32 | return _cars; 33 | } 34 | 35 | public List GetAll() 36 | { 37 | return _cars; 38 | } 39 | 40 | public void Add(Car entity) 41 | { 42 | throw new NotImplementedException(); 43 | } 44 | 45 | public void Update(Car car) 46 | { 47 | Car carToUpdate = _cars.SingleOrDefault(p => p.CarId == car.CarId); 48 | carToUpdate.DailyPrice = car.DailyPrice; 49 | carToUpdate.Description = car.Description; 50 | carToUpdate.ColorId = car.ColorId; 51 | } 52 | 53 | public void Delete(Car car) 54 | { 55 | Car carToDelete = _cars.SingleOrDefault(p => p.CarId == car.CarId); 56 | _cars.Remove(carToDelete); 57 | } 58 | 59 | public List GetCarDetails() 60 | { 61 | throw new NotImplementedException(); 62 | } 63 | 64 | List IEntityRepository.GetAll(Expression> filter) 65 | { 66 | throw new NotImplementedException(); 67 | } 68 | 69 | public Car Get(Expression> filter) 70 | { 71 | throw new NotImplementedException(); 72 | } 73 | 74 | public List GetCarsRentalDetail() 75 | { 76 | throw new NotImplementedException(); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /WebAPI/Controllers/RentCarsController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Microsoft.AspNetCore.Mvc; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using Business.Abstract; 8 | using Entities.Concrete; 9 | 10 | namespace WebAPI.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class RentCarsController : ControllerBase 15 | { 16 | IRentCarService _rentCarService; 17 | 18 | public RentCarsController(IRentCarService rentCarService) 19 | { 20 | _rentCarService = rentCarService; 21 | } 22 | 23 | [HttpGet("getall")] 24 | public IActionResult GetAll() 25 | { 26 | var result = _rentCarService.GetAll(); 27 | if (result.Success) 28 | { 29 | return Ok(result); 30 | } 31 | 32 | return BadRequest(result); 33 | } 34 | 35 | [HttpGet("getrentcardetails")] 36 | public IActionResult GetCarsRentalDetail() 37 | { 38 | var result = _rentCarService.GetCarsRentalDetail(); 39 | if (result.Success) 40 | { 41 | return Ok(result); 42 | } 43 | 44 | return BadRequest(result); 45 | } 46 | 47 | [HttpGet("getbyid")] 48 | public IActionResult GetById(int id) 49 | { 50 | var result = _rentCarService.GetById(id); 51 | if (result.Success) 52 | { 53 | return Ok(result); 54 | } 55 | 56 | return BadRequest(result); 57 | } 58 | 59 | [HttpPost("add")] 60 | public IActionResult Add(CarRental carRental) 61 | { 62 | var result = _rentCarService.Add(carRental); 63 | if (result.Success) 64 | { 65 | return Ok(result); 66 | } 67 | 68 | return BadRequest(result); 69 | } 70 | 71 | [HttpPost("update")] 72 | public IActionResult Update(CarRental carRental) 73 | { 74 | var result = _rentCarService.Update(carRental); 75 | if (result.Success) 76 | { 77 | return Ok(result); 78 | } 79 | 80 | return BadRequest(result); 81 | } 82 | 83 | [HttpPost("delete")] 84 | public IActionResult Delete(CarRental carRental) 85 | { 86 | var result = _rentCarService.Delete(carRental); 87 | if (result.Success) 88 | { 89 | return Ok(result); 90 | } 91 | 92 | return BadRequest(result); 93 | } 94 | 95 | 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /Business/Concrete/AuthManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Business.Abstract; 5 | using Business.Constants; 6 | using Core.Entities.Concrete; 7 | using Core.Utilities.Results; 8 | using Core.Utilities.Security.Hashing; 9 | using Core.Utilities.Security.JWT; 10 | using Entities.DTOs; 11 | 12 | namespace Business.Concrete 13 | { 14 | public class AuthManager : IAuthService 15 | { 16 | private IUserService _userService; 17 | private ITokenHelper _tokenHelper; 18 | 19 | public AuthManager(IUserService userService, ITokenHelper tokenHelper) 20 | { 21 | _userService = userService; 22 | _tokenHelper = tokenHelper; 23 | } 24 | 25 | public IDataResult Register(UserForRegisterDto userForRegisterDto, string password) 26 | { 27 | byte[] passwordHash, passwordSalt; 28 | HashingHelper.CreatePasswordHash(password, out passwordHash, out passwordSalt); 29 | var user = new User 30 | { 31 | Email = userForRegisterDto.Email, 32 | FirstName = userForRegisterDto.FirstName, 33 | LastName = userForRegisterDto.LastName, 34 | PasswordHash = passwordHash, 35 | PasswordSalt = passwordSalt, 36 | Status = true 37 | }; 38 | _userService.Add(user); 39 | return new SuccessDataResult(user, Messages.UserRegistered); 40 | } 41 | 42 | public IDataResult Login(UserForLoginDto userForLoginDto) 43 | { 44 | var userToCheck = _userService.GetByMail(userForLoginDto.Email); 45 | if (userToCheck == null) 46 | { 47 | return new ErrorDataResult(Messages.UserNotFound); 48 | } 49 | 50 | if (!HashingHelper.VerifyPasswordHash(userForLoginDto.Password, userToCheck.PasswordHash, userToCheck.PasswordSalt)) 51 | { 52 | return new ErrorDataResult(Messages.PasswordError); 53 | } 54 | 55 | return new SuccessDataResult(userToCheck, Messages.SuccessfulLogin); 56 | } 57 | 58 | public IResult UserExists(string email) 59 | { 60 | if (_userService.GetByMail(email) != null) 61 | { 62 | return new ErrorResult(Messages.UserAlreadyExists); 63 | } 64 | return new SuccessResult(); 65 | } 66 | 67 | public IDataResult CreateAccessToken(User user) 68 | { 69 | var claims = _userService.GetClaims(user); 70 | var accessToken = _tokenHelper.CreateToken(user, claims); 71 | return new SuccessDataResult(accessToken, Messages.AccessTokenCreated); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Core/Utilities/Security/JWT/JwtHelper.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Concrete; 2 | using Microsoft.Extensions.Configuration; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IdentityModel.Tokens.Jwt; 6 | using System.Linq; 7 | using System.Security.Claims; 8 | using System.Text; 9 | using Core.Extensions; 10 | using Core.Utilities.Security.Encryption; 11 | using Microsoft.IdentityModel.Tokens; 12 | 13 | namespace Core.Utilities.Security.JWT 14 | { 15 | public class JwtHelper : ITokenHelper 16 | { 17 | public IConfiguration Configuration { get; } 18 | private TokenOptions _tokenOptions; 19 | private DateTime _accessTokenExpiration; 20 | public JwtHelper(IConfiguration configuration) 21 | { 22 | Configuration = configuration; 23 | _tokenOptions = Configuration.GetSection("TokenOptions").Get(); 24 | 25 | } 26 | public AccessToken CreateToken(User user, List operationClaims) 27 | { 28 | _accessTokenExpiration = DateTime.Now.AddMinutes(_tokenOptions.AccessTokenExpiration); 29 | var securityKey = SecurityKeyHelper.CreateSecurityKey(_tokenOptions.SecurityKey); 30 | var signingCredentials = SigningCredentialsHelper.CreateSigningCredentials(securityKey); 31 | var jwt = CreateJwtSecurityToken(_tokenOptions, user, signingCredentials, operationClaims); 32 | var jwtSecurityTokenHandler = new JwtSecurityTokenHandler(); 33 | var token = jwtSecurityTokenHandler.WriteToken(jwt); 34 | 35 | return new AccessToken 36 | { 37 | Token = token, 38 | Expiration = _accessTokenExpiration 39 | }; 40 | 41 | } 42 | 43 | public JwtSecurityToken CreateJwtSecurityToken(TokenOptions tokenOptions, User user, 44 | SigningCredentials signingCredentials, List operationClaims) 45 | { 46 | var jwt = new JwtSecurityToken( 47 | issuer: tokenOptions.Issuer, 48 | audience: tokenOptions.Audience, 49 | expires: _accessTokenExpiration, 50 | notBefore: DateTime.Now, 51 | claims: SetClaims(user, operationClaims), 52 | signingCredentials: signingCredentials 53 | ); 54 | return jwt; 55 | } 56 | 57 | private IEnumerable SetClaims(User user, List operationClaims) 58 | { 59 | var claims = new List(); 60 | claims.AddNameIdentifier(user.Id.ToString()); 61 | claims.AddEmail(user.Email); 62 | claims.AddName($"{user.FirstName} {user.LastName}"); 63 | claims.AddRoles(operationClaims.Select(c => c.Name).ToArray()); 64 | 65 | return claims; 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Business/Concrete/CarManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Business.Abstract; 5 | using Business.BusinessAspects.Autofac; 6 | using Business.Constants; 7 | using Business.ValidationRules.FluentValidation; 8 | using Core.Aspects.Autofac.Caching; 9 | using Core.Aspects.Autofac.Performance; 10 | using Core.Aspects.Autofac.Transaction; 11 | using Core.Aspects.Autofac.Validation; 12 | using Core.Utilities.Results; 13 | using DataAccess.Abstract; 14 | using Entities.Concrete; 15 | using Entities.DTOs; 16 | 17 | namespace Business.Concrete 18 | { 19 | public class CarManager:ICarService 20 | { 21 | ICarDal _carDal; 22 | 23 | public CarManager(ICarDal carDal) 24 | { 25 | _carDal = carDal; 26 | } 27 | 28 | [CacheAspect] 29 | public IDataResult> GetAll() 30 | { 31 | return new SuccessDataResult>(_carDal.GetAll(), Messages.CarList); 32 | } 33 | 34 | [CacheAspect] 35 | [PerformanceAspect(10)] 36 | public IDataResult GetById(int id) 37 | { 38 | return new SuccessDataResult(_carDal.Get(c => c.CarId == id)); 39 | } 40 | 41 | [SecuredOperation("car.add,admin")] 42 | [ValidationAspect(typeof(CarValidator))] 43 | [CacheRemoveAspect("ICarService.Get")] 44 | public IResult Add(Car car) 45 | { 46 | _carDal.Add(car); 47 | return new SuccessResult(Messages.CarAdded); 48 | } 49 | 50 | [SecuredOperation("car.update,admin")] 51 | [CacheRemoveAspect("ICarService.Get")] 52 | public IResult Update(Car car) 53 | { 54 | _carDal.Update(car); 55 | return new SuccessResult(Messages.CarUpdated); 56 | } 57 | 58 | [SecuredOperation("car.delete,admin")] 59 | public IResult Delete(Car car) 60 | { 61 | _carDal.Delete(car); 62 | return new SuccessResult(Messages.CarDeleted); 63 | } 64 | 65 | public IDataResult> GetAllByBrandId(int brandId) 66 | { 67 | return new SuccessDataResult>(_carDal.GetAll(c=>c.BrandId==brandId)); 68 | } 69 | 70 | public IDataResult> GetAllByColorId(int colorId) 71 | { 72 | return new SuccessDataResult>(_carDal.GetAll(cr => cr.ColorId == colorId)); 73 | } 74 | 75 | public IDataResult> GetCarDetails() 76 | { 77 | return new SuccessDataResult>(_carDal.GetCarDetails(), Messages.CarSuccessDto); 78 | } 79 | 80 | [TransactionScopeAspect] 81 | public IResult AddTransactionalTest(Car car) 82 | { 83 | Add(car); 84 | if (car.DailyPrice<100) 85 | { 86 | throw new Exception(""); 87 | } 88 | Add(car); 89 | return null; 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /WebAPI/Controllers/CarImagesController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Microsoft.AspNetCore.Mvc; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using Business.Abstract; 8 | using Entities.Concrete; 9 | 10 | namespace WebAPI.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class CarImagesController : ControllerBase 15 | { 16 | ICarImageService _carImageService; 17 | 18 | public CarImagesController(ICarImageService carImageService) 19 | { 20 | _carImageService = carImageService; 21 | } 22 | 23 | [HttpGet("getall")] 24 | public IActionResult GetAll() 25 | { 26 | var result = _carImageService.GetAll(); 27 | if (result.Success) 28 | { 29 | return Ok(result); 30 | } 31 | 32 | return BadRequest(result); 33 | } 34 | 35 | [HttpGet("getbyid")] 36 | public IActionResult GetById([FromForm(Name = ("Id"))] int id) 37 | { 38 | var result = _carImageService.Get(id); 39 | if (result.Success) 40 | { 41 | return Ok(result); 42 | } 43 | 44 | return BadRequest(result); 45 | } 46 | 47 | [HttpGet("getimagesbycarid")] 48 | public IActionResult GetImagesByCarId([FromForm(Name = ("CarId"))] int carId) 49 | { 50 | var result = _carImageService.GetImagesByCarId(carId); 51 | if (result.Success) 52 | { 53 | return Ok(result); 54 | } 55 | 56 | return BadRequest(result); 57 | } 58 | 59 | [HttpPost("add")] 60 | public IActionResult Add([FromForm] IFormFile file, [FromForm] CarImage carImage) 61 | { 62 | var result = _carImageService.Add(file, carImage); 63 | if (result.Success) 64 | { 65 | return Ok(result); 66 | } 67 | 68 | return BadRequest(result); 69 | } 70 | 71 | [HttpPost("update")] 72 | public IActionResult Update([FromForm(Name = ("Image"))] IFormFile file, [FromForm(Name = ("Id"))] int id) 73 | { 74 | var carImage = _carImageService.Get(id).Data; 75 | var result = _carImageService.Update(file, carImage); 76 | if (result.Success) 77 | { 78 | return Ok(result); 79 | } 80 | 81 | return BadRequest(result); 82 | } 83 | 84 | [HttpPost("delete")] 85 | public IActionResult Delete([FromForm(Name = ("Id"))] int Id) 86 | { 87 | var carImage = _carImageService.Get(Id).Data; 88 | var result = _carImageService.Delete(carImage); 89 | if (result.Success) 90 | { 91 | return Ok(result); 92 | } 93 | 94 | return BadRequest(result); 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /Business/Constants/Messages.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Concrete; 2 | using Entities.Concrete; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Runtime.Serialization; 6 | using System.Text; 7 | 8 | namespace Business.Constants 9 | { 10 | public class Messages 11 | { 12 | public static string CarNameInvalid = "Ürün ismi geçersiz."; 13 | public static string CarAdded = "Ürün Eklendi"; 14 | public static string MaintenanceTime = "Sistem Bakımda"; 15 | public static string CarRentalListed = " Ürünler Listelendi"; 16 | public static string BrandList = "Markalar Listelendi."; 17 | public static string BrandNameInvalid = "Marka İsmi Geçersiz"; 18 | public static string BrandAdded = "Marka Eklendi."; 19 | public static string BrandUpdated = "Marka Güncellendi."; 20 | public static string BrandDeleted = "Marka Silindi."; 21 | public static string CarList = "Arabalar Listelendi."; 22 | public static string CarRentalAdded = "Araba Kiralama eklendi."; 23 | public static string CarUpdated = "Araba Güncellendi."; 24 | public static string CarDeleted = "Araba Başarıyla Silindi."; 25 | public static string ColorListed = "Renkler Listelendi."; 26 | public static string ColorNameInvalid = "Renk İsmi Geçersiz."; 27 | public static string ColorAdded = "Renk Başarıyla Eklendi."; 28 | public static string ColorUpdated = "Renk Güncellendi."; 29 | public static string ColorDeleted = "Renk Güncelledi."; 30 | public static string CompanyNameInvalid = "Şirket Adı Geçersiz."; 31 | public static string CustomerAdded = "Müşteri Başarıyla Eklendi."; 32 | public static string CustomerUpdated = "Müşteri Güncellendi."; 33 | public static string CustomerDeleted = "Müşteri Silindi."; 34 | public static string CustomerList = "Müşteriler Listelendi."; 35 | public static string UserDeleted = "Kullanıcı Silindi."; 36 | public static string UserUpdated = "Kullanıcı Güncellendi."; 37 | public static string UserAdded = "Kullanıcı Başarıyla Eklendi."; 38 | public static string UserNameInvalid = "Kullanıcı Adı Geçersiz."; 39 | public static string UserList = "Kullanıcılar Listelendi."; 40 | public static string CarRentalUpdated = "Araba kiralama bilgileri güncellendi."; 41 | public static string CarRentalDeleted = "Araba kiralama bilgileri silindi."; 42 | public static string UserCountError = "En fazla 10 kullanıcı eklenebilir."; 43 | public static string UserNameAlreadyExists = "Bu isimde başka bir kullanıcı var."; 44 | public static string CustomerLimiExceded = "Müşteri Limitini Aştınız."; 45 | public static string ExceededAddedImageLimit = "Resim ekleme limiti aşıldı."; 46 | public static string AuthorizationDenied="Yetkiniz Yok."; 47 | public static string UserRegistered="Kullanıcı kayıt oldu."; 48 | public static string UserNotFound="Kullanıcı bulunamadı."; 49 | public static string PasswordError="Parola Hatası."; 50 | public static string SuccessfulLogin="Başarılı giriş."; 51 | public static string UserAlreadyExists="Kullanıcı Mevcut."; 52 | public static string AccessTokenCreated="Token Oluşturuldu."; 53 | public static string CarSuccessDto= "Araba Bilgileri Başarıyla Getirildi."; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /WebAPI/Controllers/CarsController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Microsoft.AspNetCore.Mvc; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using Business.Abstract; 8 | using Entities.Concrete; 9 | 10 | namespace WebAPI.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class CarsController : ControllerBase 15 | { 16 | ICarService _carService; 17 | 18 | public CarsController(ICarService carService) 19 | { 20 | _carService = carService; 21 | } 22 | 23 | [HttpGet("getall")] 24 | public IActionResult GetAll() 25 | { 26 | var result = _carService.GetAll(); 27 | if (result.Success) 28 | { 29 | return Ok(result.Data); 30 | } 31 | 32 | return BadRequest(result.Message); 33 | } 34 | 35 | [HttpGet("getbyid")] 36 | public IActionResult GetById(int id) 37 | { 38 | var result = _carService.GetById(id); 39 | if (result.Success) 40 | { 41 | return Ok(result); 42 | } 43 | 44 | return BadRequest(result); 45 | } 46 | 47 | [HttpGet("getallbybrandid")] 48 | public IActionResult GetByBrandId(int brandId) 49 | { 50 | var result = _carService.GetAllByBrandId(brandId); 51 | if (result.Success) 52 | { 53 | return Ok(result); 54 | } 55 | 56 | return BadRequest(result); 57 | } 58 | 59 | [HttpGet("getallbycolorid")] 60 | public IActionResult GetAllByColorId(int colorId) 61 | { 62 | var result = _carService.GetAllByColorId(colorId); 63 | if (result.Success) 64 | { 65 | return Ok(result); 66 | } 67 | 68 | return BadRequest(result); 69 | } 70 | 71 | [HttpGet("getcardetails")] 72 | public IActionResult Get() 73 | { 74 | var result = _carService.GetCarDetails(); 75 | if (result.Success) 76 | { 77 | return Ok(result); 78 | } 79 | 80 | return BadRequest(result); 81 | } 82 | 83 | [HttpPost("add")] 84 | public IActionResult Add(Car car) 85 | { 86 | var result = _carService.Add(car); 87 | if (result.Success) 88 | { 89 | return Ok(result); 90 | } 91 | 92 | return BadRequest(result); 93 | } 94 | 95 | [HttpPost("update")] 96 | public IActionResult Update(Car car) 97 | { 98 | var result = _carService.Update(car); 99 | if (result.Success) 100 | { 101 | return Ok(result); 102 | } 103 | 104 | return BadRequest(result); 105 | } 106 | 107 | [HttpPost("delete")] 108 | public IActionResult Delete(Car car) 109 | { 110 | var result = _carService.Delete(car); 111 | if (result.Success) 112 | { 113 | return Ok(result); 114 | } 115 | 116 | return BadRequest(result); 117 | } 118 | 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /ReCapProject.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30907.101 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReCap", "ReCap\ReCap.csproj", "{DC97A110-F29B-4139-8E45-A2805A3D1F82}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Entities", "Entities\Entities.csproj", "{6482529F-8AF1-4A82-8EDC-ED7385C36EEC}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataAccess", "DataAccess\DataAccess.csproj", "{BE2D0405-788D-487B-9F06-C4426E7B7352}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Business", "Business\Business.csproj", "{7994099E-D2CF-40FD-8EB3-90CE727DAA65}" 13 | EndProject 14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core", "Core\Core.csproj", "{F20797CA-9D45-455B-AA75-FB277A04DBF7}" 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAPI", "WebAPI\WebAPI.csproj", "{878467D4-38F8-4BD8-A540-E76E532E085D}" 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 | {DC97A110-F29B-4139-8E45-A2805A3D1F82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {DC97A110-F29B-4139-8E45-A2805A3D1F82}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {DC97A110-F29B-4139-8E45-A2805A3D1F82}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {DC97A110-F29B-4139-8E45-A2805A3D1F82}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {6482529F-8AF1-4A82-8EDC-ED7385C36EEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {6482529F-8AF1-4A82-8EDC-ED7385C36EEC}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {6482529F-8AF1-4A82-8EDC-ED7385C36EEC}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {6482529F-8AF1-4A82-8EDC-ED7385C36EEC}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {BE2D0405-788D-487B-9F06-C4426E7B7352}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {BE2D0405-788D-487B-9F06-C4426E7B7352}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {BE2D0405-788D-487B-9F06-C4426E7B7352}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {BE2D0405-788D-487B-9F06-C4426E7B7352}.Release|Any CPU.Build.0 = Release|Any CPU 36 | {7994099E-D2CF-40FD-8EB3-90CE727DAA65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 37 | {7994099E-D2CF-40FD-8EB3-90CE727DAA65}.Debug|Any CPU.Build.0 = Debug|Any CPU 38 | {7994099E-D2CF-40FD-8EB3-90CE727DAA65}.Release|Any CPU.ActiveCfg = Release|Any CPU 39 | {7994099E-D2CF-40FD-8EB3-90CE727DAA65}.Release|Any CPU.Build.0 = Release|Any CPU 40 | {F20797CA-9D45-455B-AA75-FB277A04DBF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 41 | {F20797CA-9D45-455B-AA75-FB277A04DBF7}.Debug|Any CPU.Build.0 = Debug|Any CPU 42 | {F20797CA-9D45-455B-AA75-FB277A04DBF7}.Release|Any CPU.ActiveCfg = Release|Any CPU 43 | {F20797CA-9D45-455B-AA75-FB277A04DBF7}.Release|Any CPU.Build.0 = Release|Any CPU 44 | {878467D4-38F8-4BD8-A540-E76E532E085D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 45 | {878467D4-38F8-4BD8-A540-E76E532E085D}.Debug|Any CPU.Build.0 = Debug|Any CPU 46 | {878467D4-38F8-4BD8-A540-E76E532E085D}.Release|Any CPU.ActiveCfg = Release|Any CPU 47 | {878467D4-38F8-4BD8-A540-E76E532E085D}.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 = {79B54150-7FF6-4FA9-B098-982406095720} 54 | EndGlobalSection 55 | EndGlobal 56 | -------------------------------------------------------------------------------- /Business/Concrete/UserManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Business.Abstract; 6 | using Business.CCS; 7 | using Business.Constants; 8 | using Business.ValidationRules.FluentValidation; 9 | using Core.Aspects.Autofac.Validation; 10 | using Core.CrossCuttingConcerns.Validation; 11 | using Core.Entities.Concrete; 12 | using Core.Utilities.Business; 13 | using Core.Utilities.Results; 14 | using DataAccess.Abstract; 15 | using Entities.Concrete; 16 | using FluentValidation; 17 | 18 | namespace Business.Concrete 19 | { 20 | public class UserManager : IUserService 21 | { 22 | IUserDal _userDal; 23 | ICustomerService _customerService; 24 | 25 | public UserManager(IUserDal userDal, ICustomerService customerService) 26 | { 27 | _userDal = userDal; 28 | _customerService = customerService; 29 | } 30 | 31 | public List GetClaims(User user) 32 | { 33 | return _userDal.GetClaims(user); 34 | } 35 | 36 | public User GetByMail(string email) 37 | { 38 | return _userDal.Get(u => u.Email == email); 39 | } 40 | 41 | 42 | 43 | 44 | //JWT Yetkilendirme işleminden önceki methotlar. 45 | 46 | public IDataResult> GetAll() 47 | { 48 | return new SuccessDataResult>(_userDal.GetAll(), Messages.UserList); 49 | } 50 | 51 | public IDataResult GetById(int id) 52 | { 53 | return new SuccessDataResult(_userDal.Get(u => u.Id == id)); 54 | } 55 | 56 | //[ValidationAspect(typeof(UserValidator))] 57 | public IResult Add(User user) 58 | { 59 | IResult result = BusinessRules.Run(CheckIfUserNameExists(user.FirstName), 60 | CheckIfUserCountCorrect(user.Id), CheckIfCustomerLimitExceded()); 61 | 62 | if (result != null) 63 | { 64 | return result; 65 | } 66 | _userDal.Add(user); 67 | return new SuccessResult(Messages.UserAdded); 68 | 69 | } 70 | 71 | public IResult Update(User user) 72 | { 73 | _userDal.Update(user); 74 | return new SuccessResult(Messages.UserUpdated); 75 | } 76 | 77 | public IResult Delete(User user) 78 | { 79 | _userDal.Delete(user); 80 | return new SuccessResult(Messages.UserDeleted); 81 | } 82 | 83 | private IResult CheckIfUserCountCorrect(int userId) 84 | { 85 | var result = _userDal.GetAll(u => u.Id == userId).Count; 86 | if (result >= 10) 87 | { 88 | return new ErrorResult(Messages.UserCountError); 89 | } 90 | 91 | return new SuccessResult(); 92 | } 93 | 94 | private IResult CheckIfUserNameExists(string firstName) 95 | { 96 | var result = _userDal.GetAll(u => u.FirstName == firstName).Any(); 97 | if (result) 98 | { 99 | return new ErrorResult(Messages.UserNameAlreadyExists); 100 | } 101 | 102 | return new SuccessResult(); 103 | 104 | } 105 | 106 | private IResult CheckIfCustomerLimitExceded() 107 | { 108 | var result = _customerService.GetAll(); 109 | if (result.Data.Count > 15) 110 | { 111 | return new ErrorResult(Messages.CustomerLimiExceded); 112 | } 113 | return new SuccessResult(); 114 | } 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /Business/Concrete/CarImageManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Business.Abstract; 5 | using Business.Constants; 6 | using Business.ValidationRules.FluentValidation; 7 | using Core.Aspects.Autofac.Validation; 8 | using Core.Utilities.Business; 9 | using Core.Utilities.Helpers; 10 | using Core.Utilities.Results; 11 | using DataAccess.Abstract; 12 | using Entities.Concrete; 13 | using Microsoft.AspNetCore.Http; 14 | using Microsoft.EntityFrameworkCore.Internal; 15 | using System.Linq; 16 | using Business.BusinessAspects.Autofac; 17 | 18 | namespace Business.Concrete 19 | { 20 | public class CarImageManager : ICarImageService 21 | { 22 | ICarImageDal _carImageDal; 23 | 24 | public CarImageManager(ICarImageDal carImageDal) 25 | { 26 | _carImageDal = carImageDal; 27 | } 28 | 29 | [SecuredOperation("carImages.add,admin")] 30 | [ValidationAspect(typeof(CarImageValidator))] 31 | public IResult Add(IFormFile file, CarImage carImage) 32 | { 33 | IResult result = BusinessRules.Run(CheckIfImageLimit(carImage.CarId)); 34 | if (result != null) 35 | { 36 | return result; 37 | } 38 | 39 | carImage.ImagePath = FileHelper.Add(file); 40 | carImage.Date = DateTime.Now; 41 | _carImageDal.Add(carImage); 42 | return new SuccessResult(); 43 | } 44 | 45 | [SecuredOperation("carImages.update,admin")] 46 | [ValidationAspect(typeof(CarImageValidator))] 47 | public IResult Update(IFormFile file, CarImage carImage) 48 | { 49 | carImage.ImagePath = FileHelper.Update(_carImageDal.Get(c => c.Id == carImage.Id).ImagePath, file); 50 | carImage.Date = DateTime.Now; 51 | _carImageDal.Update(carImage); 52 | return new SuccessResult(); 53 | } 54 | 55 | [SecuredOperation("carImages.delete,admin")] 56 | [ValidationAspect(typeof(CarImageValidator))] 57 | public IResult Delete(CarImage carImage) 58 | { 59 | FileHelper.Delete(carImage.ImagePath); 60 | _carImageDal.Delete(carImage); 61 | return new SuccessResult(); 62 | } 63 | 64 | public IDataResult> GetAll() 65 | { 66 | return new SuccessDataResult>(_carImageDal.GetAll()); 67 | } 68 | 69 | public IDataResult Get(int id) 70 | { 71 | return new SuccessDataResult(_carImageDal.Get(c => c.Id == id)); 72 | } 73 | 74 | public IDataResult> GetImagesByCarId(int carId) 75 | { 76 | return new SuccessDataResult>(CheckIfCarImageNull(carId)); 77 | } 78 | 79 | private List CheckIfCarImageNull(int carId) 80 | { 81 | string path = @"\Images\null.jpg"; 82 | var result = _carImageDal.GetAll(c => c.CarId == carId).Any(); 83 | if (!result) 84 | { 85 | return new List { new CarImage { CarId = carId, ImagePath = path, Date = DateTime.Now } }; 86 | } 87 | 88 | return _carImageDal.GetAll(c => c.CarId == carId); 89 | } 90 | 91 | private IResult CheckIfImageLimit(int carId) 92 | { 93 | var carImageCount = _carImageDal.GetAll(c => c.CarId == carId).Count; 94 | if (carImageCount >= 5) 95 | { 96 | return new ErrorResult(Messages.ExceededAddedImageLimit); 97 | } 98 | return new SuccessResult(); 99 | } 100 | } 101 | 102 | 103 | } 104 | -------------------------------------------------------------------------------- /WebAPI/Startup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.AspNetCore.HttpsPolicy; 4 | using Microsoft.AspNetCore.Mvc; 5 | using Microsoft.Extensions.Configuration; 6 | using Microsoft.Extensions.DependencyInjection; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | using System; 10 | using System.Collections.Generic; 11 | using System.Linq; 12 | using System.Threading.Tasks; 13 | using Business.Abstract; 14 | using Business.Concrete; 15 | using Core.DependencyResolves; 16 | using Core.Extensions; 17 | using Core.Utilities.IoC; 18 | using Core.Utilities.Security.JWT; 19 | using DataAccess.Abstract; 20 | using DataAccess.Concrete.EntityFrameWork; 21 | using Microsoft.AspNetCore.Authentication.JwtBearer; 22 | using Microsoft.IdentityModel.Tokens; 23 | using Core.Utilities.Security.Encryption; 24 | using Microsoft.AspNetCore.Http; 25 | 26 | namespace WebAPI 27 | { 28 | public class Startup 29 | { 30 | public Startup(IConfiguration configuration) 31 | { 32 | Configuration = configuration; 33 | } 34 | 35 | public IConfiguration Configuration { get; } 36 | 37 | // This method gets called by the runtime. Use this method to add services to the container. 38 | public void ConfigureServices(IServiceCollection services) 39 | { 40 | services.AddControllers(); 41 | 42 | //services.AddSingleton(); 43 | //services.AddSingleton(); 44 | 45 | //services.AddSingleton(); 46 | //services.AddSingleton(); 47 | 48 | //services.AddSingleton(); 49 | //services.AddSingleton(); 50 | 51 | //services.AddSingleton(); 52 | //services.AddSingleton(); 53 | 54 | //services.AddSingleton(); 55 | //services.AddSingleton(); 56 | 57 | //services.AddSingleton(); 58 | //services.AddSingleton(); 59 | 60 | services.AddCors(); 61 | 62 | var tokenOptions = Configuration.GetSection("TokenOptions").Get(); 63 | 64 | services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) 65 | .AddJwtBearer(options => 66 | { 67 | options.TokenValidationParameters = new TokenValidationParameters 68 | { 69 | ValidateIssuer = true, 70 | ValidateAudience = true, 71 | ValidateLifetime = true, 72 | ValidIssuer = tokenOptions.Issuer, 73 | ValidAudience = tokenOptions.Audience, 74 | ValidateIssuerSigningKey = true, 75 | IssuerSigningKey = SecurityKeyHelper.CreateSecurityKey(tokenOptions.SecurityKey) 76 | }; 77 | }); 78 | services.AddDependencyResolves(new ICoreModule[] 79 | { 80 | new CoreModule() 81 | }); 82 | } 83 | 84 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 85 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 86 | { 87 | if (env.IsDevelopment()) 88 | { 89 | app.UseDeveloperExceptionPage(); 90 | } 91 | 92 | app.UseCors(builder => builder.WithOrigins("http://localhost:4200").AllowAnyHeader()); 93 | 94 | app.UseHttpsRedirection(); 95 | 96 | app.UseRouting(); 97 | 98 | app.UseAuthentication(); 99 | 100 | app.UseAuthorization(); 101 | 102 | app.UseEndpoints(endpoints => 103 | { 104 | endpoints.MapControllers(); 105 | }); 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | [Aa][Rr][Mm]/ 24 | [Aa][Rr][Mm]64/ 25 | bld/ 26 | [Bb]in/ 27 | [Oo]bj/ 28 | [Ll]og/ 29 | 30 | # Visual Studio 2015/2017 cache/options directory 31 | .vs/ 32 | # Uncomment if you have tasks that create the project's static files in wwwroot 33 | #wwwroot/ 34 | 35 | # Visual Studio 2017 auto generated files 36 | Generated\ Files/ 37 | 38 | # MSTest test Results 39 | [Tt]est[Rr]esult*/ 40 | [Bb]uild[Ll]og.* 41 | 42 | # NUNIT 43 | *.VisualState.xml 44 | TestResult.xml 45 | 46 | # Build Results of an ATL Project 47 | [Dd]ebugPS/ 48 | [Rr]eleasePS/ 49 | dlldata.c 50 | 51 | # Benchmark Results 52 | BenchmarkDotNet.Artifacts/ 53 | 54 | # .NET Core 55 | project.lock.json 56 | project.fragment.lock.json 57 | artifacts/ 58 | 59 | # StyleCop 60 | StyleCopReport.xml 61 | 62 | # Files built by Visual Studio 63 | *_i.c 64 | *_p.c 65 | *_h.h 66 | *.ilk 67 | *.meta 68 | *.obj 69 | *.iobj 70 | *.pch 71 | *.pdb 72 | *.ipdb 73 | *.pgc 74 | *.pgd 75 | *.rsp 76 | *.sbr 77 | *.tlb 78 | *.tli 79 | *.tlh 80 | *.tmp 81 | *.tmp_proj 82 | *_wpftmp.csproj 83 | *.log 84 | *.vspscc 85 | *.vssscc 86 | .builds 87 | *.pidb 88 | *.svclog 89 | *.scc 90 | 91 | # Chutzpah Test files 92 | _Chutzpah* 93 | 94 | # Visual C++ cache files 95 | ipch/ 96 | *.aps 97 | *.ncb 98 | *.opendb 99 | *.opensdf 100 | *.sdf 101 | *.cachefile 102 | *.VC.db 103 | *.VC.VC.opendb 104 | 105 | # Visual Studio profiler 106 | *.psess 107 | *.vsp 108 | *.vspx 109 | *.sap 110 | 111 | # Visual Studio Trace Files 112 | *.e2e 113 | 114 | # TFS 2012 Local Workspace 115 | $tf/ 116 | 117 | # Guidance Automation Toolkit 118 | *.gpState 119 | 120 | # ReSharper is a .NET coding add-in 121 | _ReSharper*/ 122 | *.[Rr]e[Ss]harper 123 | *.DotSettings.user 124 | 125 | # JustCode is a .NET coding add-in 126 | .JustCode 127 | 128 | # TeamCity is a build add-in 129 | _TeamCity* 130 | 131 | # DotCover is a Code Coverage Tool 132 | *.dotCover 133 | 134 | # AxoCover is a Code Coverage Tool 135 | .axoCover/* 136 | !.axoCover/settings.json 137 | 138 | # Visual Studio code coverage results 139 | *.coverage 140 | *.coveragexml 141 | 142 | # NCrunch 143 | _NCrunch_* 144 | .*crunch*.local.xml 145 | nCrunchTemp_* 146 | 147 | # MightyMoose 148 | *.mm.* 149 | AutoTest.Net/ 150 | 151 | # Web workbench (sass) 152 | .sass-cache/ 153 | 154 | # Installshield output folder 155 | [Ee]xpress/ 156 | 157 | # DocProject is a documentation generator add-in 158 | DocProject/buildhelp/ 159 | DocProject/Help/*.HxT 160 | DocProject/Help/*.HxC 161 | DocProject/Help/*.hhc 162 | DocProject/Help/*.hhk 163 | DocProject/Help/*.hhp 164 | DocProject/Help/Html2 165 | DocProject/Help/html 166 | 167 | # Click-Once directory 168 | publish/ 169 | 170 | # Publish Web Output 171 | *.[Pp]ublish.xml 172 | *.azurePubxml 173 | # Note: Comment the next line if you want to checkin your web deploy settings, 174 | # but database connection strings (with potential passwords) will be unencrypted 175 | *.pubxml 176 | *.publishproj 177 | 178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 179 | # checkin your Azure Web App publish settings, but sensitive information contained 180 | # in these scripts will be unencrypted 181 | PublishScripts/ 182 | 183 | # NuGet Packages 184 | *.nupkg 185 | # The packages folder can be ignored because of Package Restore 186 | **/[Pp]ackages/* 187 | # except build/, which is used as an MSBuild target. 188 | !**/[Pp]ackages/build/ 189 | # Uncomment if necessary however generally it will be regenerated when needed 190 | #!**/[Pp]ackages/repositories.config 191 | # NuGet v3's project.json files produces more ignorable files 192 | *.nuget.props 193 | *.nuget.targets 194 | 195 | # Microsoft Azure Build Output 196 | csx/ 197 | *.build.csdef 198 | 199 | # Microsoft Azure Emulator 200 | ecf/ 201 | rcf/ 202 | 203 | # Windows Store app package directories and files 204 | AppPackages/ 205 | BundleArtifacts/ 206 | Package.StoreAssociation.xml 207 | _pkginfo.txt 208 | *.appx 209 | 210 | # Visual Studio cache files 211 | # files ending in .cache can be ignored 212 | *.[Cc]ache 213 | # but keep track of directories ending in .cache 214 | !?*.[Cc]ache/ 215 | 216 | # Others 217 | ClientBin/ 218 | ~$* 219 | *~ 220 | *.dbmdl 221 | *.dbproj.schemaview 222 | *.jfm 223 | *.pfx 224 | *.publishsettings 225 | orleans.codegen.cs 226 | 227 | # Including strong name files can present a security risk 228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 229 | #*.snk 230 | 231 | # Since there are multiple workflows, uncomment next line to ignore bower_components 232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 233 | #bower_components/ 234 | 235 | # RIA/Silverlight projects 236 | Generated_Code/ 237 | 238 | # Backup & report files from converting an old project file 239 | # to a newer Visual Studio version. Backup files are not needed, 240 | # because we have git ;-) 241 | _UpgradeReport_Files/ 242 | Backup*/ 243 | UpgradeLog*.XML 244 | UpgradeLog*.htm 245 | ServiceFabricBackup/ 246 | *.rptproj.bak 247 | 248 | # SQL Server files 249 | *.mdf 250 | *.ldf 251 | *.ndf 252 | 253 | # Business Intelligence projects 254 | *.rdl.data 255 | *.bim.layout 256 | *.bim_*.settings 257 | *.rptproj.rsuser 258 | *- Backup*.rdl 259 | 260 | # Microsoft Fakes 261 | FakesAssemblies/ 262 | 263 | # GhostDoc plugin setting file 264 | *.GhostDoc.xml 265 | 266 | # Node.js Tools for Visual Studio 267 | .ntvs_analysis.dat 268 | node_modules/ 269 | 270 | # Visual Studio 6 build log 271 | *.plg 272 | 273 | # Visual Studio 6 workspace options file 274 | *.opt 275 | 276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 277 | *.vbw 278 | 279 | # Visual Studio LightSwitch build output 280 | **/*.HTMLClient/GeneratedArtifacts 281 | **/*.DesktopClient/GeneratedArtifacts 282 | **/*.DesktopClient/ModelManifest.xml 283 | **/*.Server/GeneratedArtifacts 284 | **/*.Server/ModelManifest.xml 285 | _Pvt_Extensions 286 | 287 | # Paket dependency manager 288 | .paket/paket.exe 289 | paket-files/ 290 | 291 | # FAKE - F# Make 292 | .fake/ 293 | 294 | # JetBrains Rider 295 | .idea/ 296 | *.sln.iml 297 | 298 | # CodeRush personal settings 299 | .cr/personal 300 | 301 | # Python Tools for Visual Studio (PTVS) 302 | __pycache__/ 303 | *.pyc 304 | 305 | # Cake - Uncomment if you are using it 306 | # tools/** 307 | # !tools/packages.config 308 | 309 | # Tabs Studio 310 | *.tss 311 | 312 | # Telerik's JustMock configuration file 313 | *.jmconfig 314 | 315 | # BizTalk build output 316 | *.btp.cs 317 | *.btm.cs 318 | *.odx.cs 319 | *.xsd.cs 320 | 321 | # OpenCover UI analysis results 322 | OpenCover/ 323 | 324 | # Azure Stream Analytics local run output 325 | ASALocalRun/ 326 | 327 | # MSBuild Binary and Structured Log 328 | *.binlog 329 | 330 | # NVidia Nsight GPU debugger configuration file 331 | *.nvuser 332 | 333 | # MFractors (Xamarin productivity tool) working folder 334 | .mfractor/ 335 | 336 | # Local History for Visual Studio 337 | .localhistory/ 338 | 339 | # BeatPulse healthcheck temp database 340 | healthchecksdb --------------------------------------------------------------------------------