├── WebAPI ├── Program.cs ├── wwwroot │ └── Images │ │ ├── Default.jpg │ │ ├── 1d4a7035-856b-4e35-ac62-af0d74b0074d.png │ │ ├── 22e80672-2825-4d89-89bd-03d88e4fcad6.jpg │ │ ├── 3d516c2d-4f01-4075-9605-925e3c7349a7.jpg │ │ ├── 4200369c-f62d-4bea-86a5-eae29ab812a3.png │ │ ├── 977a5aad-abe4-4051-91b3-64ffc33a5573.png │ │ ├── 97b6fd80-7cd0-41c5-a850-d6827f0c460a.png │ │ ├── 9d192e4c-34fa-4c41-902e-8add6e56fb9d.jpg │ │ ├── df750928-3e73-4908-b4b7-eb62981636b8.png │ │ ├── f11d8bf8-396d-465d-954a-856ff2479617.png │ │ └── fb497d62-ecdb-4de9-a3ba-d33eceb23f5d.jpg ├── appsettings.Development.json ├── WeatherForecast.cs ├── appsettings.json ├── WebAPI.csproj ├── Properties │ └── launchSettings.json ├── Controllers │ ├── WeatherForecastController.cs │ ├── AuthController.cs │ ├── OperationsController.cs │ ├── UserOperationsController.cs │ ├── ColorsController.cs │ ├── BrandsController.cs │ ├── CustomersController.cs │ ├── OrdersController.cs │ ├── RentalsController.cs │ ├── UsersController.cs │ ├── CardsController.cs │ ├── CarImagesController.cs │ └── CarsController.cs └── Startup.cs ├── Core ├── Entities │ ├── IDto.cs │ ├── IEntity.cs │ └── Concrete │ │ ├── OperationClaim.cs │ │ ├── UserOperationClaim.cs │ │ └── User.cs ├── Utilities │ ├── Results │ │ ├── IDataResult.cs │ │ ├── IResult.cs │ │ ├── SuccessResult.cs │ │ ├── ErrorResult.cs │ │ ├── Result.cs │ │ ├── DataResult.cs │ │ ├── SuccessDataResult.cs │ │ └── ErrorDataResult.cs │ ├── FileUploads │ │ ├── FileTools.cs │ │ └── FileHelper.cs │ ├── IoC │ │ ├── ICoreModule.cs │ │ └── ServiceTool.cs │ ├── Security │ │ ├── JWT │ │ │ ├── AccessToken.cs │ │ │ ├── ITokenHelper.cs │ │ │ ├── TokenOptions.cs │ │ │ └── JwtHelper.cs │ │ ├── Encryption │ │ │ ├── SecurityKeyHelper.cs │ │ │ └── SigningCredentialsHelper.cs │ │ └── Hashing │ │ │ └── HashingHelper.cs │ ├── Interceptors │ │ ├── MethodInterceptionBaseAttribute.cs │ │ ├── AspectInterceptorSelector.cs │ │ └── MethodInterception.cs │ └── Business │ │ └── BusinessRules.cs ├── Extensions │ ├── ExceptionMiddlewareExtensions.cs │ ├── ErrorDetails.cs │ ├── CollectionExtensions.cs │ ├── ServiceCollectionExtensions.cs │ ├── ClaimsPrincipalExtensions.cs │ ├── ClaimExtensions.cs │ └── ExceptionMiddleware.cs ├── CrossCuttingConcerns │ ├── Caching │ │ ├── ICacheManager.cs │ │ └── Microsoft │ │ │ └── MemoryCacheManager.cs │ └── Validation │ │ └── ValidationTool.cs ├── DataAccess │ ├── IEntityRepository.cs │ └── EntityFramework │ │ └── EfEntityRepositoryBase.cs ├── DependencyResolvers │ └── CoreModule.cs ├── Aspects │ └── Autofac │ │ ├── Caching │ │ ├── CacheRemoveAspect.cs │ │ └── CacheAspect.cs │ │ ├── Transaction │ │ └── TransactionScopeAspect.cs │ │ ├── Performance │ │ └── PerformanceAspect.cs │ │ └── Validation │ │ └── ValidationAspect.cs └── Core.csproj ├── DataAccess ├── Abstract │ ├── ICardDal.cs │ ├── IUserOperationDal.cs │ ├── IBrandDal.cs │ ├── IColorDal.cs │ ├── IOrderDal.cs │ ├── ICarImageDal.cs │ ├── ICustomerDal.cs │ ├── IUserDal.cs │ ├── ICarDal.cs │ ├── IOperationDal.cs │ └── IRentalDal.cs ├── Concrete │ └── EntityFramework │ │ ├── EfCardDal.cs │ │ ├── EfUserOperationDal.cs │ │ ├── EfBrandDal.cs │ │ ├── EfColorDal.cs │ │ ├── EfOrderDal.cs │ │ ├── EfCarImageDal.cs │ │ ├── EfCustomerDal.cs │ │ ├── EfOperationDal.cs │ │ ├── EfUserDal.cs │ │ ├── RentalContext.cs │ │ ├── EfCarDal.cs │ │ └── EfRentalDal.cs └── DataAccess.csproj ├── Entities ├── Entities.csproj ├── Concrete │ ├── Brand.cs │ ├── Color.cs │ ├── Order.cs │ ├── Customer.cs │ ├── CarImage.cs │ ├── Card.cs │ ├── Rental.cs │ └── Car.cs └── DTOs │ ├── UserForLoginDto.cs │ ├── UserForRegisterDto.cs │ ├── RentalDetailDto.cs │ └── CarDetailDto.cs ├── ConsoleUI ├── ConsoleUI.csproj └── Program.cs ├── Business ├── ValidationRules │ └── FluentValidation │ │ ├── BrandValidator.cs │ │ ├── ColorValidator.cs │ │ ├── UserValidator.cs │ │ ├── CustomerValidator.cs │ │ ├── CarValidator.cs │ │ └── RentalValidator.cs ├── Abstract │ ├── IOrderService.cs │ ├── IBrandService.cs │ ├── IColorService.cs │ ├── IOperationService.cs │ ├── IUserOperationService.cs │ ├── ICardService.cs │ ├── IAuthService.cs │ ├── ICustomerService.cs │ ├── IRentalService.cs │ ├── ICarImageService.cs │ ├── IUserService.cs │ └── ICarService.cs ├── Business.csproj ├── Concrete │ ├── OrderManager.cs │ ├── OperationManager.cs │ ├── UserOperationManager.cs │ ├── BrandManager.cs │ ├── ColorManager.cs │ ├── CardManager.cs │ ├── CustomerManager.cs │ ├── UserManager.cs │ ├── AuthManager.cs │ ├── CarManager.cs │ ├── RentalManager.cs │ └── CarImageManager.cs ├── BusinessAspects │ └── Autofac │ │ └── SecuredOperation.cs ├── Constants │ └── Messages.cs └── DependencyResolvers │ └── Autofac │ └── AutofacBusinessModule.cs ├── README.md ├── .gitattributes ├── CarRentalProject.sln └── .gitignore /WebAPI/Program.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElSenpai/CarRentalProject/HEAD/WebAPI/Program.cs -------------------------------------------------------------------------------- /WebAPI/wwwroot/Images/Default.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElSenpai/CarRentalProject/HEAD/WebAPI/wwwroot/Images/Default.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/Images/1d4a7035-856b-4e35-ac62-af0d74b0074d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElSenpai/CarRentalProject/HEAD/WebAPI/wwwroot/Images/1d4a7035-856b-4e35-ac62-af0d74b0074d.png -------------------------------------------------------------------------------- /WebAPI/wwwroot/Images/22e80672-2825-4d89-89bd-03d88e4fcad6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElSenpai/CarRentalProject/HEAD/WebAPI/wwwroot/Images/22e80672-2825-4d89-89bd-03d88e4fcad6.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/Images/3d516c2d-4f01-4075-9605-925e3c7349a7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElSenpai/CarRentalProject/HEAD/WebAPI/wwwroot/Images/3d516c2d-4f01-4075-9605-925e3c7349a7.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/Images/4200369c-f62d-4bea-86a5-eae29ab812a3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElSenpai/CarRentalProject/HEAD/WebAPI/wwwroot/Images/4200369c-f62d-4bea-86a5-eae29ab812a3.png -------------------------------------------------------------------------------- /WebAPI/wwwroot/Images/977a5aad-abe4-4051-91b3-64ffc33a5573.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElSenpai/CarRentalProject/HEAD/WebAPI/wwwroot/Images/977a5aad-abe4-4051-91b3-64ffc33a5573.png -------------------------------------------------------------------------------- /WebAPI/wwwroot/Images/97b6fd80-7cd0-41c5-a850-d6827f0c460a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElSenpai/CarRentalProject/HEAD/WebAPI/wwwroot/Images/97b6fd80-7cd0-41c5-a850-d6827f0c460a.png -------------------------------------------------------------------------------- /WebAPI/wwwroot/Images/9d192e4c-34fa-4c41-902e-8add6e56fb9d.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElSenpai/CarRentalProject/HEAD/WebAPI/wwwroot/Images/9d192e4c-34fa-4c41-902e-8add6e56fb9d.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/Images/df750928-3e73-4908-b4b7-eb62981636b8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElSenpai/CarRentalProject/HEAD/WebAPI/wwwroot/Images/df750928-3e73-4908-b4b7-eb62981636b8.png -------------------------------------------------------------------------------- /WebAPI/wwwroot/Images/f11d8bf8-396d-465d-954a-856ff2479617.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElSenpai/CarRentalProject/HEAD/WebAPI/wwwroot/Images/f11d8bf8-396d-465d-954a-856ff2479617.png -------------------------------------------------------------------------------- /WebAPI/wwwroot/Images/fb497d62-ecdb-4de9-a3ba-d33eceb23f5d.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ElSenpai/CarRentalProject/HEAD/WebAPI/wwwroot/Images/fb497d62-ecdb-4de9-a3ba-d33eceb23f5d.jpg -------------------------------------------------------------------------------- /Core/Entities/IDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Entities 6 | { 7 | public interface IDto 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Core/Entities/IEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Entities 6 | { 7 | public interface IEntity 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /DataAccess/Abstract/ICardDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Entities.Concrete; 3 | 4 | namespace DataAccess.Abstract 5 | { 6 | public interface ICardDal : IEntityRepository 7 | { 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /WebAPI/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /DataAccess/Abstract/IUserOperationDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Core.Entities.Concrete; 3 | 4 | namespace DataAccess.Abstract 5 | { 6 | public interface IUserOperationDal : IEntityRepository 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Core/Utilities/Results/IDataResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results 6 | { 7 | public interface IDataResult:IResult 8 | { 9 | T Data { get; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Core/Utilities/Results/IResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results 6 | { 7 | public interface IResult 8 | { 9 | bool Success { get; } 10 | string Message {get; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Entities/Entities.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /DataAccess/Abstract/IBrandDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Entities.Concrete; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace DataAccess.Abstract 8 | { 9 | public interface IBrandDal :IEntityRepository 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /DataAccess/Abstract/IColorDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Entities.Concrete; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace DataAccess.Abstract 8 | { 9 | public interface IColorDal : IEntityRepository 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /DataAccess/Abstract/IOrderDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Entities.Concrete; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace DataAccess.Abstract 8 | { 9 | public interface IOrderDal : IEntityRepository 10 | { 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DataAccess/Abstract/ICarImageDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Entities.Concrete; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace DataAccess.Abstract 8 | { 9 | public interface ICarImageDal : IEntityRepository 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Core/Utilities/FileUploads/FileTools.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Utilities.FileUploads 7 | { 8 | public class FileTools 9 | { 10 | public IFormFile Files { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Core/Utilities/IoC/ICoreModule.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Utilities.IoC 7 | { 8 | public interface ICoreModule 9 | { 10 | void Load(IServiceCollection collection); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Core/Entities/Concrete/OperationClaim.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Entities.Concrete 6 | { 7 | public class OperationClaim : IEntity 8 | { 9 | public int Id { get; set; } 10 | public string Name { get; set; } 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Entities/Concrete/Brand.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class Brand : IEntity 9 | { 10 | public int Id { get; set; } 11 | public string BrandName { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Entities/Concrete/Color.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class Color : IEntity 9 | { 10 | public int Id { get; set; } 11 | public string ColorName { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /ConsoleUI/ConsoleUI.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Entities/DTOs/UserForLoginDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.DTOs 7 | { 8 | public class UserForLoginDto : IDto 9 | { 10 | public string Email { get; set; } 11 | public string Password { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfCardDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using DataAccess.Abstract; 3 | using Entities.Concrete; 4 | 5 | namespace DataAccess.Concrete.EntityFramework 6 | { 7 | public class EfCardDal : EfEntityRepositoryBase, ICardDal 8 | { 9 | 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Core/Utilities/Security/JWT/ITokenHelper.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Concrete; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Utilities.Security.JWT 7 | { 8 | public interface ITokenHelper 9 | { 10 | AccessToken CreateToken(User user,List operationClaims); 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfUserOperationDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using Core.Entities.Concrete; 3 | using DataAccess.Abstract; 4 | 5 | namespace DataAccess.Concrete.EntityFramework 6 | { 7 | public class EfUserOperationDal : EfEntityRepositoryBase, IUserOperationDal 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Entities/DTOs/UserForRegisterDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | 3 | namespace Entities.DTOs 4 | { 5 | public class UserForRegisterDto : IDto 6 | { 7 | public string Email { get; set; } 8 | public string Password { get; set; } 9 | public string FirstName { get; set; } 10 | public string LastName { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /ConsoleUI/Program.cs: -------------------------------------------------------------------------------- 1 | using Business.Concrete; 2 | using Business.Constants; 3 | using Core.Entities.Concrete; 4 | using DataAccess.Concrete.EntityFramework; 5 | using Entities.Concrete; 6 | using System; 7 | 8 | namespace ConsoleUI 9 | { 10 | class Program 11 | { 12 | static void Main(string[] args) 13 | { 14 | 15 | 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Core/Entities/Concrete/UserOperationClaim.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Entities.Concrete 6 | { 7 | public class UserOperationClaim : IEntity 8 | { 9 | public int Id { get; set; } 10 | public int UserId { get; set; } 11 | public int OperationClaimId { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DataAccess/Abstract/ICustomerDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Entities.Concrete; 3 | using Entities.DTOs; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq.Expressions; 7 | using System.Text; 8 | 9 | namespace DataAccess.Abstract 10 | { 11 | public interface ICustomerDal : IEntityRepository 12 | { 13 | 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /DataAccess/Abstract/IUserDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Core.Entities.Concrete; 3 | using Entities.Concrete; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace DataAccess.Abstract 9 | { 10 | public interface IUserDal : IEntityRepository 11 | { 12 | List GetClaims(User user); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfBrandDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using DataAccess.Abstract; 3 | using Entities.Concrete; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace DataAccess.Concrete.EntityFramework 9 | { 10 | public class EfBrandDal:EfEntityRepositoryBase ,IBrandDal 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfColorDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using DataAccess.Abstract; 3 | using Entities.Concrete; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace DataAccess.Concrete.EntityFramework 9 | { 10 | public class EfColorDal : EfEntityRepositoryBase ,IColorDal 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfOrderDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using DataAccess.Abstract; 3 | using Entities.Concrete; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace DataAccess.Concrete.EntityFramework 9 | { 10 | public class EfOrderDal : EfEntityRepositoryBase, IOrderDal 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfCarImageDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using DataAccess.Abstract; 3 | using Entities.Concrete; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace DataAccess.Concrete.EntityFramework 9 | { 10 | public class EfCarImageDal : EfEntityRepositoryBase,ICarImageDal 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/BrandValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.Concrete; 2 | using FluentValidation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Business.ValidationRules.FluentValidation 8 | { 9 | public class BrandValidator:AbstractValidator 10 | { 11 | public BrandValidator() 12 | { 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Core/Utilities/Results/SuccessResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results 6 | { 7 | public class SuccessResult : Result 8 | { 9 | public SuccessResult(string message):base(true,message) 10 | { 11 | 12 | } 13 | public SuccessResult():base(true) 14 | { 15 | 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Entities/Concrete/Order.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class Order :IEntity 9 | { 10 | public int Id { get; set; } 11 | public int CardId { get; set; } 12 | public int Money { get; set; } 13 | public DateTime OrderDate { get; set; } = DateTime.Now; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Entities/Concrete/Customer.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class Customer :IEntity 9 | { 10 | 11 | public int Id { get; set; } 12 | public int UserId { get; set; } 13 | public string CompanyName { get; set; } 14 | public int Findeks { get; set; } 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /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 | 14 | public ErrorResult():base(false) 15 | { 16 | 17 | } 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Core/Utilities/Security/JWT/TokenOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Security.JWT 6 | { 7 | public class TokenOptions 8 | { 9 | public string Audience { get; set; } 10 | public string Issuer { get; set; } 11 | public int AccessTokenExpiration { get; set; } 12 | public string SecurityKey { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /DataAccess/DataAccess.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /DataAccess/Abstract/ICarDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Entities.Concrete; 3 | using Entities.DTOs; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq.Expressions; 7 | using System.Text; 8 | 9 | namespace DataAccess.Abstract 10 | { 11 | public interface ICarDal : IEntityRepository 12 | { 13 | List GetCarDetails(Expression> filter = null); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /DataAccess/Abstract/IOperationDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Core.Entities.Concrete; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq.Expressions; 6 | using System.Text; 7 | 8 | namespace DataAccess.Abstract 9 | { 10 | public interface IOperationDal : IEntityRepository 11 | { 12 | //List OperationDto(Expression> filter = null); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Business/Abstract/IOrderService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results; 2 | using Entities.Concrete; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Business.Abstract 8 | { 9 | public interface IOrderService 10 | { 11 | IResult Add(Order order); 12 | 13 | IResult Update(Order order); 14 | IResult Delete(Order order); 15 | IDataResult> GetAll(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /DataAccess/Abstract/IRentalDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Entities.Concrete; 3 | using Entities.DTOs; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq.Expressions; 7 | using System.Text; 8 | 9 | namespace DataAccess.Abstract 10 | { 11 | public interface IRentalDal:IEntityRepository 12 | { 13 | List GetRentalDetails(Expression>filter=null); 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Entities/Concrete/CarImage.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class CarImage : IEntity 9 | { 10 | 11 | 12 | public int Id { get; set; } 13 | public int CarId { get; set; } 14 | public string ImagePath { get; set; } 15 | public DateTime Date { get; set; } = DateTime.Now; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Core/Extensions/ExceptionMiddlewareExtensions.cs: -------------------------------------------------------------------------------- 1 | 2 | using Microsoft.AspNetCore.Builder; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | namespace Core.Extensions 7 | { 8 | public static class ExceptionMiddlewareExtensions 9 | { 10 | public static void ConfigureCustomExceptionMiddleware(this IApplicationBuilder app) 11 | { 12 | app.UseMiddleware(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Entities/Concrete/Card.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class Card : IEntity 9 | { 10 | public int Id { get; set; } 11 | public int CustomerId { get; set; } 12 | public string CardNumber { get; set; } 13 | public string CardPassword { get; set; } 14 | public decimal Money { get; set; } 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Core/Utilities/Security/Encryption/SecurityKeyHelper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.IdentityModel.Tokens; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Utilities.Security.Encryption 7 | { 8 | public class SecurityKeyHelper 9 | { 10 | public static SecurityKey CreateSecurityKey(string securityKey) 11 | { 12 | return new SymmetricSecurityKey(Encoding.UTF8.GetBytes(securityKey)); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/ColorValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.Concrete; 2 | using FluentValidation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Business.ValidationRules.FluentValidation 8 | { 9 | public class ColorValidator: AbstractValidator 10 | { 11 | public ColorValidator() 12 | { 13 | // RuleFor(c => c.ColorName).NotEqual(c=>c.ColorName); 14 | 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/UserValidator.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Concrete; 2 | using Entities.Concrete; 3 | using FluentValidation; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace Business.ValidationRules.FluentValidation 9 | { 10 | public class UserValidator: AbstractValidator 11 | { 12 | public UserValidator() 13 | { 14 | RuleFor(u => u.Email).EmailAddress(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Entities/Concrete/Rental.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class Rental :IEntity 9 | { 10 | public int Id { get; set; } 11 | 12 | 13 | public int CarId { get; set; } 14 | public int CustomerId { get; set; } 15 | public DateTime RentDate { get; set; } 16 | public DateTime? ReturnDate { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Entities/DTOs/RentalDetailDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Entities.DTOs 6 | { 7 | public class RentalDetailDto 8 | { 9 | public int RentId { get; set; } 10 | 11 | 12 | public string UserName { get; set; } 13 | public string BrandName { get; set; } 14 | public DateTime RentDate { get; set; } 15 | public DateTime? ReturnDate { get; set; } 16 | 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /WebAPI/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "TokenOptions": { 3 | "Audience": "senpai@senpai.com", 4 | "Issuer": "senpai@senpai.com", 5 | "AccessTokenExpiration": 500, 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 | -------------------------------------------------------------------------------- /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 | } 18 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfCustomerDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using DataAccess.Abstract; 3 | using Entities.Concrete; 4 | using Entities.DTOs; 5 | using System; 6 | using System.Linq; 7 | using System.Collections.Generic; 8 | using System.Linq.Expressions; 9 | using System.Text; 10 | 11 | namespace DataAccess.Concrete.EntityFramework 12 | { 13 | public class EfCustomerDal : EfEntityRepositoryBase, ICustomerDal 14 | { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Business/Abstract/IBrandService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results; 2 | using Entities.Concrete; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Business.Abstract 8 | { 9 | public interface IBrandService 10 | { 11 | IResult Add(Brand brand); 12 | IResult Update(Brand brand); 13 | IResult Delete(Brand brand); 14 | IDataResult GetByBrandId(int brandId); 15 | IDataResult > GetAllBrands(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Business/Abstract/IColorService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results; 2 | using Entities.Concrete; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Business.Abstract 8 | { 9 | public interface IColorService 10 | { 11 | IResult Add(Color color); 12 | IResult Update(Color color); 13 | IResult Delete(Color color); 14 | IDataResult GetByColorId(int colorId); 15 | IDataResult< List> GetAllColors(); 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Business/Abstract/IOperationService.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Concrete; 2 | using Core.Utilities.Results; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Business.Abstract 8 | { 9 | public interface IOperationService 10 | { 11 | IResult Add(OperationClaim operationClaim); 12 | IResult Update(OperationClaim operationClaim); 13 | IResult Delete(OperationClaim operationClaim); 14 | 15 | IDataResult> GetAll(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Core/Utilities/Security/Encryption/SigningCredentialsHelper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.IdentityModel.Tokens; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Utilities.Security.Encryption 7 | { 8 | public class SigningCredentialsHelper 9 | { 10 | public static SigningCredentials CreateSigningCredentials(SecurityKey securityKey) 11 | { 12 | return new SigningCredentials(securityKey,SecurityAlgorithms.HmacSha512Signature); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfOperationDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using Core.Entities.Concrete; 3 | using DataAccess.Abstract; 4 | using Entities.Concrete; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq.Expressions; 8 | using System.Text; 9 | using System.Linq; 10 | 11 | namespace DataAccess.Concrete.EntityFramework 12 | { 13 | public class EfOperationDal : EfEntityRepositoryBase ,IOperationDal 14 | { 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Core/DataAccess/IEntityRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq.Expressions; 5 | using System.Text; 6 | 7 | namespace Core.DataAccess 8 | { 9 | public interface IEntityRepository where T:class,IEntity,new() 10 | { 11 | List GetAll(Expression> filter = null); 12 | T Get(Expression> filter); 13 | void Add(T entity); 14 | void Update(T entity); 15 | void Delete(T entity); 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Core/Utilities/Interceptors/MethodInterceptionBaseAttribute.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using System; 3 | 4 | namespace Core.Utilities.Interceptors 5 | { 6 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] 7 | public abstract class MethodInterceptionBaseAttribute : Attribute, IInterceptor 8 | { 9 | public int Priority { get; set; } 10 | 11 | public virtual void Intercept(IInvocation invocation) 12 | { 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/CustomerValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.Concrete; 2 | using FluentValidation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Business.ValidationRules.FluentValidation 8 | { 9 | public class CustomerValidator: AbstractValidator 10 | { 11 | public CustomerValidator() 12 | { 13 | RuleFor(cu => cu.CompanyName).NotEmpty(); 14 | RuleFor(cu => cu.Findeks).InclusiveBetween(0, 1900); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Business/Abstract/IUserOperationService.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Concrete; 2 | using Core.Utilities.Results; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Business.Abstract 8 | { 9 | public interface IUserOperationService 10 | { 11 | IResult Add(UserOperationClaim uOperationClaim); 12 | 13 | IResult Update(UserOperationClaim uOperationClaim); 14 | IResult Delete(UserOperationClaim uOperationClaim); 15 | 16 | IDataResult> GetAll(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Core/Entities/Concrete/User.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Entities.Concrete 6 | { 7 | public class User : IEntity 8 | { 9 | public int Id { get; set; } 10 | public string FirstName { get; set; } 11 | public string LastName { get; set; } 12 | public string Email { get; set; } 13 | public byte[] PasswordSalt { get; set; } 14 | public byte[] PasswordHash { get; set; } 15 | public bool Status { get; set; } 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Core/Utilities/Results/Result.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results 6 | { 7 | public class Result : IResult 8 | { 9 | 10 | public Result(bool success,string message):this(success) 11 | { 12 | Message = message; 13 | } 14 | public Result(bool success) 15 | { 16 | Success = success; 17 | } 18 | 19 | public bool Success { get; } 20 | 21 | public string Message { get; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Business/Abstract/ICardService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results; 2 | using Entities.Concrete; 3 | using System.Collections.Generic; 4 | 5 | namespace Business.Abstract 6 | { 7 | public interface ICardService 8 | { 9 | IResult Add(Card card); 10 | 11 | IResult Update(Card card); 12 | IResult Delete(Card card); 13 | 14 | IDataResult> GetAllCards(); 15 | IDataResult GetByCustomerId(int id); 16 | IDataResult GetbyCardNumber(string cardNumber); 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /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 | 20 | 21 | public T Data { get; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Entities/Concrete/Car.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.Concrete 7 | { 8 | public class Car : IEntity 9 | { 10 | public int Id { get; set; } 11 | public int BrandId { get; set; } 12 | public int ColorId { get; set; } 13 | public int ModelYear { get; set; } 14 | public decimal DailyPrice { get; set; } 15 | public string CarName { get; set; } 16 | public int MinFindeks { get; set; } 17 | 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/CarValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.Concrete; 2 | using FluentValidation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Business.ValidationRules.FluentValidation 8 | { 9 | public class CarValidator : AbstractValidator 10 | { 11 | public CarValidator() 12 | { 13 | RuleFor(c=>c.CarName).MinimumLength(2); 14 | RuleFor(c => c.DailyPrice).GreaterThan(0); 15 | RuleFor(cu => cu.MinFindeks).InclusiveBetween(0, 1900); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Core/Utilities/Business/BusinessRules.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.Utilities.Business 7 | { 8 | public class BusinessRules 9 | { 10 | public static IResult Run(params IResult[] logics) 11 | { 12 | foreach (var logic in logics) 13 | { 14 | if (!logic.Success) 15 | { 16 | return logic; 17 | } 18 | } 19 | return null; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Core/Extensions/ErrorDetails.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation.Results; 2 | using Newtonsoft.Json; 3 | using System.Collections.Generic; 4 | 5 | namespace Core.Extensions 6 | { 7 | public class ErrorDetails 8 | { 9 | public string Message { get; set; } 10 | public int StatusCode { get; set; } 11 | 12 | 13 | public override string ToString() 14 | { 15 | return JsonConvert.SerializeObject(this); 16 | } 17 | } 18 | public class ValidationErrorDetails : ErrorDetails 19 | { 20 | public IEnumerable Errors { get; set; } 21 | } 22 | } -------------------------------------------------------------------------------- /Core/Extensions/CollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Linq.Expressions; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Core.Extensions 9 | { 10 | public static class CollectionExtensions 11 | { 12 | public static IQueryable WhereIf(this IQueryable source, bool condition, Expression> predicate) 13 | { 14 | if (condition) 15 | return source.Where(predicate); 16 | else return source; 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Business/Abstract/IAuthService.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Concrete; 2 | using Core.Utilities.Results; 3 | using Core.Utilities.Security.JWT; 4 | using Entities.DTOs; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Text; 8 | 9 | namespace Business.Abstract 10 | { 11 | public interface IAuthService 12 | { 13 | IDataResult Register(UserForRegisterDto userForRegisterDto, string password); 14 | IDataResult Login(UserForLoginDto userForLoginDto); 15 | IResult UserExists(string email); 16 | IDataResult CreateAccessToken(User user); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Business/Abstract/ICustomerService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results; 2 | using Entities.Concrete; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Business.Abstract 8 | { 9 | public interface ICustomerService 10 | { 11 | 12 | 13 | 14 | 15 | IResult Add(Customer customer); 16 | IResult Update(Customer customer); 17 | IResult Delete(Customer customer); 18 | 19 | 20 | IDataResult GetByCustomerId(int id); 21 | IDataResult> GetAllCustomers(); 22 | IDataResult Findeks(int cusId); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Business/Abstract/IRentalService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results; 2 | using Entities.Concrete; 3 | using Entities.DTOs; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace Business.Abstract 9 | { 10 | public interface IRentalService 11 | { 12 | IResult Rent(Rental rental); 13 | IResult Update(Rental rental); 14 | IResult Delete(Rental rental); 15 | 16 | 17 | 18 | IDataResult GetByRentId(int id); 19 | IDataResult> GetAllRentals(); 20 | 21 | IDataResult> GetRentalDetailDtos(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Core/CrossCuttingConcerns/Validation/ValidationTool.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Core.CrossCuttingConcerns.Validation 7 | { 8 | public static class ValidationTool 9 | { 10 | public static void Validate(IValidator validator,object entity) 11 | { 12 | var context = new ValidationContext(entity); 13 | var result = validator.Validate(context); 14 | if (!result.IsValid) 15 | { 16 | throw new ValidationException(result.Errors); 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Core/Utilities/Results/SuccessDataResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results 6 | { 7 | public class SuccessDataResult:DataResult 8 | { 9 | public SuccessDataResult(T data,string message):base(data,true,message) 10 | { 11 | 12 | } 13 | public SuccessDataResult(T data):base(data,true) 14 | { 15 | 16 | } 17 | public SuccessDataResult(string message):base(default,true,message) 18 | { 19 | 20 | } 21 | public SuccessDataResult():base(default,true) 22 | { 23 | 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Business/Abstract/ICarImageService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.FileUploads; 2 | using Core.Utilities.Results; 3 | using Entities.Concrete; 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Text; 8 | 9 | namespace Business.Abstract 10 | { 11 | public interface ICarImageService 12 | { 13 | IResult Add(FileTools file, CarImage carImage); 14 | IResult Update(FileTools file, CarImage carImage); 15 | IResult Delete( CarImage carImage); 16 | IDataResult> GetById(int id); 17 | IDataResult> GetByCarId(int id); 18 | IDataResult> GetAll(); 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Core/Utilities/Results/ErrorDataResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Core.Utilities.Results 6 | { 7 | public class ErrorDataResult:DataResult 8 | { 9 | public ErrorDataResult(T data, string message) : base(data, false, message) 10 | { 11 | 12 | } 13 | public ErrorDataResult(T data) : base(data, false) 14 | { 15 | 16 | } 17 | public ErrorDataResult(string message) : base(default, false, message) 18 | { 19 | 20 | } 21 | public ErrorDataResult() : base(default, false) 22 | { 23 | 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Entities/DTOs/CarDetailDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Entities.DTOs 7 | { 8 | public class CarDetailDto :IDto 9 | { 10 | public int CarId { get; set; } 11 | public int BrandId { get; set; } 12 | public int ColorId { get; set; } 13 | public string BrandModel { get; set; } 14 | public string BrandName { get; set; } 15 | public string ColorName { get; set; } 16 | public decimal DailyPrice { get; set; } 17 | public int ModelYear { get; set; } 18 | public int MinFindeks { get; set; } 19 | 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Business/Abstract/IUserService.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Concrete; 2 | using Core.Utilities.Results; 3 | using Entities.Concrete; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace Business.Abstract 9 | { 10 | public interface IUserService 11 | 12 | { 13 | IResult Add(User user); 14 | IResult Update(User user,string password); 15 | IResult Delete(User user); 16 | IDataResult GetByUserId(int id); 17 | IDataResult> GetAllUsers(); 18 | IDataResult> GetClaims(User user); 19 | IDataResult GetByMail(string email); 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Core/Extensions/ServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.IoC; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace Core.Extensions 8 | { 9 | public static class ServiceCollectionExtensions 10 | { 11 | public static IServiceCollection AddDependencyResolvers(this IServiceCollection servicesCollection, 12 | ICoreModule[] modules) 13 | { 14 | foreach (var module in modules) 15 | { 16 | module.Load(servicesCollection); 17 | } 18 | 19 | return ServiceTool.Create(servicesCollection); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Core/DependencyResolvers/CoreModule.cs: -------------------------------------------------------------------------------- 1 | using Core.CrossCuttingConcerns.Caching; 2 | using Core.CrossCuttingConcerns.Caching.Microsoft; 3 | using Core.Utilities.IoC; 4 | using Microsoft.AspNetCore.Http; 5 | using Microsoft.Extensions.DependencyInjection; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Diagnostics; 9 | using System.Text; 10 | 11 | namespace Core.DependencyResolvers 12 | { 13 | public class CoreModule : ICoreModule 14 | { 15 | public void Load(IServiceCollection serviceCollection) 16 | { 17 | serviceCollection.AddMemoryCache(); 18 | serviceCollection.AddSingleton(); 19 | serviceCollection.AddSingleton(); 20 | serviceCollection.AddSingleton(); 21 | 22 | 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Core/Aspects/Autofac/Caching/CacheRemoveAspect.cs: -------------------------------------------------------------------------------- 1 | using Core.CrossCuttingConcerns.Caching; 2 | using Core.Utilities.Interceptors; 3 | using Core.Utilities.IoC; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | using Microsoft.Extensions.DependencyInjection; 8 | using Castle.DynamicProxy; 9 | 10 | namespace Core.Aspects.Autofac.Caching 11 | { 12 | public class CacheRemoveAspect : MethodInterception 13 | { 14 | private string _pattern; 15 | private ICacheManager _cacheManager; 16 | 17 | public CacheRemoveAspect(string pattern) 18 | { 19 | _pattern = pattern; 20 | _cacheManager = ServiceTool.ServiceProvider.GetService(); 21 | } 22 | 23 | protected override void OnSuccess(IInvocation invocation) 24 | { 25 | _cacheManager.RemoveByPattern(_pattern); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Core/Aspects/Autofac/Transaction/TransactionScopeAspect.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using Core.Utilities.Interceptors; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | using System.Transactions; 7 | 8 | namespace Core.Aspects.Autofac.Transaction 9 | { 10 | public class TransactionScopeAspect : MethodInterception 11 | { 12 | public override void Intercept(IInvocation invocation) 13 | { 14 | using (TransactionScope transactionScope = new TransactionScope()) 15 | { 16 | try 17 | { 18 | invocation.Proceed(); 19 | transactionScope.Complete(); 20 | } 21 | catch (System.Exception e) 22 | { 23 | transactionScope.Dispose(); 24 | throw; 25 | } 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /WebAPI/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:52621", 8 | "sslPort": 44310 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": false, 15 | "launchUrl": "weatherforecast", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "WebAPI": { 21 | "commandName": "Project", 22 | "launchBrowser": false, 23 | "launchUrl": "weatherforecast", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Business/Abstract/ICarService.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results; 2 | using Entities.Concrete; 3 | using Entities.DTOs; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace Business.Abstract 9 | { 10 | public interface ICarService 11 | { 12 | IResult Add(Car car); 13 | IResult Update(Car car); 14 | IResult Delete(Car car); 15 | 16 | IDataResult GetByCarId(int id); 17 | IDataResult> GetAllCars(); 18 | IDataResult> GetCarDtoById(int carId); 19 | IDataResult> GetByBrandId(int id); 20 | IDataResult> GetByColorId(int id); 21 | IDataResult> GetColorBrandId(int? brandId, int? colorId); 22 | IDataResult Findeks(int carId); 23 | IDataResult < List> GetCarDetailDtos(); 24 | IResult AddTransactionalTest(Car car); 25 | 26 | 27 | 28 | 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /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/Utilities/Interceptors/AspectInterceptorSelector.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using Core.Aspects.Autofac.Performance; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Reflection; 7 | using System.Text; 8 | 9 | namespace Core.Utilities.Interceptors 10 | { 11 | public class AspectInterceptorSelector : IInterceptorSelector 12 | { 13 | public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors) 14 | { 15 | var classAttributes = type.GetCustomAttributes 16 | (true).ToList(); 17 | var methodAttributes = type.GetMethod(method.Name) 18 | .GetCustomAttributes(true); 19 | classAttributes.AddRange(methodAttributes); 20 | classAttributes.Add(new PerformanceAspect(1)); 21 | 22 | 23 | return classAttributes.OrderBy(x => x.Priority).ToArray(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Extensions/ClaimExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IdentityModel.Tokens.Jwt; 4 | using System.Linq; 5 | using System.Security.Claims; 6 | using System.Text; 7 | 8 | namespace Core.Extensions 9 | { 10 | public static class ClaimExtensions 11 | { 12 | public static void AddEmail(this ICollection claims, string email) 13 | { 14 | claims.Add(new Claim(JwtRegisteredClaimNames.Email, email)); 15 | } 16 | 17 | public static void AddName(this ICollection claims, string name) 18 | { 19 | claims.Add(new Claim(ClaimTypes.Name, name)); 20 | } 21 | 22 | public static void AddNameIdentifier(this ICollection claims, string nameIdentifier) 23 | { 24 | claims.Add(new Claim(ClaimTypes.NameIdentifier, nameIdentifier)); 25 | } 26 | 27 | public static void AddRoles(this ICollection claims, string[] roles) 28 | { 29 | roles.ToList().ForEach(role => claims.Add(new Claim(ClaimTypes.Role, role))); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfUserDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using Core.Entities.Concrete; 3 | using DataAccess.Abstract; 4 | using Entities.Concrete; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Text; 8 | using System.Linq; 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 RentalContext()) 17 | { 18 | var result = from operationClaim in context.OperationClaims 19 | join userOperationClaim in context.UserOperationClaims 20 | on operationClaim.Id equals userOperationClaim.OperationClaimId 21 | where userOperationClaim.UserId == user.Id 22 | select new OperationClaim { Id = operationClaim.Id, Name = operationClaim.Name }; 23 | return result.ToList(); 24 | 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CarRental Project - Backend 2 | 3 | 4 | ## Technologies and Techniques Used in the Project 5 | 6 | * .NET 7 | * ASP.NET 8 | * EntityFramework Core 9 | * Autofac 10 | * FluentValidation 11 | * JWT 12 | * IOC 13 | * Autofac Dependency Resolver 14 | * FileUpload 15 | * Aspects 16 | 17 | ### Aspects 18 | * Caching 19 | * Performance 20 | * Transaction 21 | * Validation / FluentValidation 22 | 23 | 24 | 25 | 26 | 27 | ### Nuget Packages and Their Versions 28 | 29 | * Autofac - Version = v6.1.0 30 | * Autofac.Extensions.DependencyInjection - Version = v7.1.0 31 | * Autofac.Extras.DynamicProxy - Version = v6.0.0 32 | * FluentValidation - Version = v9.5.1 33 | * Microsoft.AspNetCore.Authentication.JwtBearer - Version = v3.1.12 34 | * Microsoft.AspNetCore.Http - Version = v2.2.2 35 | * Microsoft.AspNetCore.Http.Abstractions - Version = v2.2.0 36 | * Microsoft.AspNetCore.Http.Features - Version = v5.0.3 37 | * Microsoft.EntityFrameworkCore.SqlServer - Version = v3.1.12 38 | * Microsoft.IdentityModel.Tokens - Version = v6.8.0 39 | * Newtonsoft.Json - Version = v13.0.1 40 | * System.IdentityModel.Tokens.Jwt - Version = v6.8.0 41 | 42 | [El Senpai](https://github.com/ElSenpai/) 43 | 44 | -------------------------------------------------------------------------------- /Business/Concrete/OrderManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Constants; 3 | using Core.Utilities.Results; 4 | using DataAccess.Abstract; 5 | using Entities.Concrete; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Text; 9 | 10 | namespace Business.Concrete 11 | { 12 | public class OrderManager : IOrderService 13 | { 14 | IOrderDal _orderdal; 15 | public OrderManager(IOrderDal orderdal) 16 | { 17 | _orderdal = orderdal; 18 | } 19 | public IResult Add(Order order) 20 | { 21 | _orderdal.Add(order); 22 | return new SuccessResult(Messages.OrderAdd); 23 | } 24 | 25 | public IResult Delete(Order order) 26 | { 27 | _orderdal.Delete(order); 28 | return new SuccessResult(Messages.OrderDelete); 29 | } 30 | 31 | public IDataResult> GetAll() 32 | { 33 | return new SuccessDataResult>(_orderdal.GetAll()); 34 | } 35 | 36 | public IResult Update(Order order) 37 | { 38 | _orderdal.Update(order); 39 | return new SuccessResult(Messages.OrderUpdate); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/RentalValidator.cs: -------------------------------------------------------------------------------- 1 | 2 | using Business.Constants; 3 | using DataAccess.Abstract; 4 | using DataAccess.Concrete.EntityFramework; 5 | using Entities.Concrete; 6 | using FluentValidation; 7 | using System; 8 | using System.Collections.Generic; 9 | using System.Linq; 10 | using System.Text; 11 | 12 | namespace Business.ValidationRules.FluentValidation 13 | { 14 | public class RentalValidator : AbstractValidator 15 | { 16 | public RentalValidator() 17 | { 18 | 19 | 20 | RuleFor(r => r.CarId).NotNull(); 21 | //RuleFor(r => r.ReturnDate).LessThan(r => r.RentDate); 22 | //RuleFor(r => r.ReturnDate).Null(); 23 | //RuleFor(r => r.CarId).Must(ReturnDateForCarId).WithMessage(Messages.ReturnDateNull); 24 | 25 | } 26 | 27 | private bool ReturnDateForCarId(int arg) 28 | { 29 | IRentalDal rentaldal = new EfRentalDal(); 30 | var result = rentaldal.GetAll(r => r.CarId == arg); 31 | if (result.Count>0) 32 | { 33 | return false; 34 | } 35 | 36 | return true; 37 | 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Core/Utilities/Interceptors/MethodInterception.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using System; 3 | 4 | namespace Core.Utilities.Interceptors 5 | { 6 | public abstract class MethodInterception : MethodInterceptionBaseAttribute 7 | { 8 | protected virtual void OnBefore(IInvocation invocation) { } 9 | protected virtual void OnAfter(IInvocation invocation) { } 10 | protected virtual void OnException(IInvocation invocation, System.Exception e) { } 11 | protected virtual void OnSuccess(IInvocation invocation) { } 12 | public override void Intercept(IInvocation invocation) 13 | { 14 | var isSuccess = true; 15 | OnBefore(invocation); 16 | try 17 | { 18 | invocation.Proceed(); 19 | } 20 | catch (Exception e) 21 | { 22 | isSuccess = false; 23 | OnException(invocation, e); 24 | throw; 25 | } 26 | finally 27 | { 28 | if (isSuccess) 29 | { 30 | OnSuccess(invocation); 31 | } 32 | } 33 | OnAfter(invocation); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Core/Aspects/Autofac/Performance/PerformanceAspect.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using Core.Utilities.Interceptors; 3 | using Core.Utilities.IoC; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Diagnostics; 7 | using System.Text; 8 | using Microsoft.Extensions.DependencyInjection; 9 | 10 | namespace Core.Aspects.Autofac.Performance 11 | { 12 | public class PerformanceAspect : MethodInterception 13 | { 14 | private int _interval; 15 | private Stopwatch _stopwatch; 16 | 17 | public PerformanceAspect(int interval) 18 | { 19 | _interval = interval; 20 | _stopwatch = ServiceTool.ServiceProvider.GetService(); 21 | } 22 | 23 | 24 | protected override void OnBefore(IInvocation invocation) 25 | { 26 | _stopwatch.Start(); 27 | } 28 | 29 | protected override void OnAfter(IInvocation invocation) 30 | { 31 | if (_stopwatch.Elapsed.TotalSeconds > _interval) 32 | { 33 | Debug.WriteLine($"Performance : {invocation.Method.DeclaringType.FullName}.{invocation.Method.Name}-->{_stopwatch.Elapsed.TotalSeconds}"); 34 | } 35 | _stopwatch.Reset(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/RentalContext.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Concrete; 2 | using Entities.Concrete; 3 | using Microsoft.EntityFrameworkCore; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | 8 | namespace DataAccess.Concrete.EntityFramework 9 | { 10 | public class RentalContext :DbContext 11 | { 12 | 13 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 14 | { 15 | optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Rental;Trusted_Connection=true"); 16 | } 17 | 18 | public DbSet Cars { get; set; } 19 | public DbSet Cards { get; set; } 20 | public DbSet Colors { get; set; } 21 | public DbSet Brands { get; set; } 22 | public DbSet Users { get; set; } 23 | public DbSet Customers { get; set; } 24 | public DbSet Rentals { get; set; } 25 | public DbSet CarImages { get; set; } 26 | public DbSet OperationClaims { get; set; } 27 | public DbSet UserOperationClaims { get; set; } 28 | 29 | public DbSet Orders { get; set; } 30 | 31 | 32 | 33 | 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Business/BusinessAspects/Autofac/SecuredOperation.cs: -------------------------------------------------------------------------------- 1 | using Business.Constants; 2 | using Castle.DynamicProxy; 3 | using Core.Extensions; 4 | using Core.Utilities.Interceptors; 5 | using Core.Utilities.IoC; 6 | using Microsoft.AspNetCore.Http; 7 | using System; 8 | using System.Collections.Generic; 9 | using System.Text; 10 | using Microsoft.Extensions.DependencyInjection; 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 | -------------------------------------------------------------------------------- /Core/Aspects/Autofac/Validation/ValidationAspect.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using Core.CrossCuttingConcerns.Validation; 3 | using Core.Utilities.Interceptors; 4 | using FluentValidation; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | 10 | namespace Core.Aspects.Autofac.Validation 11 | { 12 | public class ValidationAspect : MethodInterception 13 | { 14 | private Type _validatorType; 15 | public ValidationAspect(Type validatorType) 16 | { 17 | if (!typeof(IValidator).IsAssignableFrom(validatorType)) 18 | { 19 | throw new System.Exception("Bu bir Validaiton değil"); 20 | } 21 | 22 | _validatorType = validatorType; 23 | } 24 | protected override void OnBefore(IInvocation invocation) 25 | { 26 | var validator = (IValidator)Activator.CreateInstance(_validatorType); 27 | var entityType = _validatorType.BaseType.GetGenericArguments()[0]; //[0] 28 | var entities = invocation.Arguments.Where(t => t.GetType() == entityType); 29 | foreach (var entity in entities) 30 | { 31 | ValidationTool.Validate(validator, entity); 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Core/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 | public static bool VerifyPasswordHash(string password, byte[] passwordHash, byte[] passwordSalt) 18 | { 19 | using (var hmac = new System.Security.Cryptography.HMACSHA512(passwordSalt)) 20 | { 21 | var computedHash = hmac.ComputeHash(Encoding.UTF8.GetBytes(password)); 22 | for (int i = 0; i < computedHash.Length; i++) 23 | { 24 | if (computedHash[i]!=passwordHash[i]) 25 | { 26 | return false; 27 | } 28 | 29 | } 30 | 31 | } 32 | return true; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Business/Concrete/OperationManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Constants; 3 | using Core.Entities.Concrete; 4 | using Core.Utilities.Results; 5 | using DataAccess.Abstract; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Text; 9 | 10 | namespace Business.Concrete 11 | { 12 | public class OperationManager : IOperationService 13 | { 14 | IOperationDal _operationDal; 15 | public OperationManager(IOperationDal operationDal) 16 | { 17 | _operationDal = operationDal; 18 | } 19 | public IResult Add(OperationClaim operationClaim) 20 | { 21 | _operationDal.Add(operationClaim); 22 | return new SuccessResult(Messages.Added); 23 | } 24 | 25 | public IResult Delete(OperationClaim operationClaim) 26 | { 27 | _operationDal.Delete(operationClaim); 28 | return new SuccessResult(Messages.Deleted); 29 | } 30 | 31 | public IDataResult> GetAll() 32 | { 33 | return new SuccessDataResult>(_operationDal.GetAll()); 34 | } 35 | 36 | public IResult Update(OperationClaim operationClaim) 37 | { 38 | _operationDal.Update(operationClaim); 39 | return new SuccessResult(Messages.Updated); 40 | } 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Business/Concrete/UserOperationManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Constants; 3 | using Core.Entities.Concrete; 4 | using Core.Utilities.Results; 5 | using DataAccess.Abstract; 6 | using System.Collections.Generic; 7 | 8 | namespace Business.Concrete 9 | { 10 | public class UserOperationManager : IUserOperationService 11 | { 12 | IUserOperationDal _uOperationDal; 13 | public UserOperationManager(IUserOperationDal uOperationDal) 14 | { 15 | _uOperationDal = uOperationDal; 16 | } 17 | 18 | public IResult Add(UserOperationClaim uOperationClaim) 19 | { 20 | _uOperationDal.Add(uOperationClaim); 21 | return new SuccessResult(Messages.Added); 22 | } 23 | 24 | public IResult Delete(UserOperationClaim uOperationClaim) 25 | { 26 | _uOperationDal.Delete(uOperationClaim); 27 | return new SuccessResult(Messages.Deleted); 28 | } 29 | 30 | public IDataResult> GetAll() 31 | { 32 | return new SuccessDataResult>(_uOperationDal.GetAll()); 33 | } 34 | 35 | public IResult Update(UserOperationClaim uOperationClaim) 36 | { 37 | _uOperationDal.Update(uOperationClaim); 38 | return new SuccessResult(Messages.Updated); 39 | } 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /Business/Concrete/BrandManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Constants; 3 | using Core.Utilities.Results; 4 | using DataAccess.Abstract; 5 | using Entities.Concrete; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Text; 9 | 10 | namespace Business.Concrete 11 | { 12 | public class BrandManager : IBrandService 13 | { 14 | IBrandDal _brandDal; 15 | public BrandManager(IBrandDal brandDal) 16 | { 17 | _brandDal = brandDal; 18 | } 19 | public IResult Add(Brand brand) 20 | { 21 | 22 | _brandDal.Add(brand); 23 | return new SuccessResult(Messages.Added); 24 | 25 | } 26 | 27 | public IResult Delete(Brand brand) 28 | { 29 | _brandDal.Delete(brand); 30 | return new SuccessResult(Messages.Deleted); 31 | } 32 | 33 | public IDataResult > GetAllBrands() 34 | { 35 | return new SuccessDataResult> (_brandDal.GetAll()); 36 | } 37 | 38 | public IDataResult GetByBrandId(int brandId) 39 | { 40 | return new SuccessDataResult( _brandDal.Get(b => b.Id == brandId)); 41 | } 42 | 43 | public IResult Update(Brand brand) 44 | { 45 | _brandDal.Update(brand); 46 | return new SuccessResult(Messages.Updated); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Core/Aspects/Autofac/Caching/CacheAspect.cs: -------------------------------------------------------------------------------- 1 | using Core.CrossCuttingConcerns.Caching; 2 | using Core.Utilities.Interceptors; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | using Microsoft.Extensions.DependencyInjection; 7 | using Core.Utilities.IoC; 8 | using Castle.DynamicProxy; 9 | using System.Linq; 10 | 11 | namespace Core.Aspects.Autofac.Caching 12 | { 13 | public class CacheAspect : MethodInterception 14 | { 15 | private int _duration; 16 | private ICacheManager _cacheManager; 17 | 18 | public CacheAspect(int duration = 60) 19 | { 20 | _duration = duration; 21 | _cacheManager = ServiceTool.ServiceProvider.GetService(); 22 | } 23 | 24 | public override void Intercept(IInvocation invocation) 25 | { 26 | var methodName = string.Format($"{invocation.Method.ReflectedType.FullName}.{invocation.Method.Name}"); 27 | var arguments = invocation.Arguments.ToList(); 28 | var key = $"{methodName}({string.Join(",", arguments.Select(x => x?.ToString() ?? ""))})"; 29 | if (_cacheManager.IsAdd(key)) 30 | { 31 | invocation.ReturnValue = _cacheManager.Get(key); 32 | return; 33 | } 34 | invocation.Proceed(); 35 | _cacheManager.Add(key, invocation.ReturnValue, _duration); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Business/Concrete/ColorManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Constants; 3 | using Business.ValidationRules.FluentValidation; 4 | using Core.Aspects.Autofac.Validation; 5 | using Core.Utilities.Results; 6 | using DataAccess.Abstract; 7 | using Entities.Concrete; 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Text; 11 | 12 | namespace Business.Concrete 13 | { 14 | public class ColorManager : IColorService 15 | { 16 | IColorDal _colorDal; 17 | public ColorManager(IColorDal colorDal) 18 | { 19 | _colorDal = colorDal; 20 | } 21 | [ValidationAspect(typeof(ColorValidator))] 22 | public IResult Add(Color color) 23 | { 24 | 25 | 26 | 27 | _colorDal.Add(color); 28 | 29 | 30 | return new SuccessResult(Messages.Added); 31 | 32 | 33 | 34 | 35 | } 36 | 37 | public IResult Delete(Color color) 38 | { 39 | _colorDal.Delete(color); 40 | return new SuccessResult(Messages.Deleted); 41 | } 42 | 43 | public IDataResult< List> GetAllColors() 44 | { 45 | return new SuccessDataResult >(_colorDal.GetAll(),Messages.ColorsListed); 46 | } 47 | 48 | public IDataResult GetByColorId(int colorId) 49 | { 50 | return new SuccessDataResult (_colorDal.Get(o=>o.Id==colorId)); 51 | } 52 | 53 | public IResult Update(Color color) 54 | { 55 | _colorDal.Update(color); 56 | return new SuccessResult(Messages.Updated); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Business/Concrete/CardManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Constants; 3 | using Core.Utilities.Results; 4 | using DataAccess.Abstract; 5 | using Entities.Concrete; 6 | using System.Collections.Generic; 7 | 8 | namespace Business.Concrete 9 | { 10 | public class CardManager : ICardService 11 | { 12 | ICardDal _cardDal; 13 | public CardManager(ICardDal cardDal) 14 | { 15 | _cardDal = cardDal; 16 | } 17 | public IResult Add(Card card) 18 | { 19 | _cardDal.Add(card); 20 | return new SuccessResult(Messages.Added); 21 | } 22 | 23 | 24 | 25 | public IResult Delete(Card card) 26 | { 27 | _cardDal.Delete(card); 28 | return new SuccessResult(Messages.Deleted); 29 | } 30 | 31 | public IDataResult> GetAllCards() 32 | { 33 | return new SuccessDataResult>(_cardDal.GetAll(), Messages.CarsListed); 34 | } 35 | 36 | public IDataResult GetByCustomerId(int id) 37 | { 38 | return new SuccessDataResult(_cardDal.Get(c => c.CustomerId == id)); 39 | } 40 | 41 | 42 | 43 | public IResult Update(Card card) 44 | { 45 | _cardDal.Update(card); 46 | return new SuccessResult(Messages.Updated); 47 | } 48 | public IDataResult GetbyCardNumber(string cardNumber) 49 | { 50 | var result = _cardDal.Get(c => c.CardNumber == cardNumber); 51 | if (result.CardNumber == cardNumber) 52 | { 53 | return new SuccessDataResult("işlem gerçekleşti"); 54 | } 55 | 56 | return new ErrorDataResult("Eşleşmeyen CardNumber"); 57 | 58 | } 59 | 60 | 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfCarDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using DataAccess.Abstract; 3 | using Entities.Concrete; 4 | using Entities.DTOs; 5 | using System; 6 | 7 | using System.Linq; 8 | 9 | using System.Collections.Generic; 10 | using System.Text; 11 | using System.Linq.Expressions; 12 | 13 | namespace DataAccess.Concrete.EntityFramework 14 | { 15 | public class EfCarDal : EfEntityRepositoryBase, ICarDal 16 | { 17 | public List GetCarDetails(Expression> filter = null) 18 | { 19 | using (RentalContext context =new RentalContext()) 20 | { 21 | var result = from c in filter == null ? context.Cars : context.Cars.Where(filter) 22 | join b in context.Brands 23 | on c.BrandId equals b.Id 24 | join o in context.Colors 25 | on c.ColorId equals o.Id 26 | 27 | 28 | 29 | select new CarDetailDto 30 | { 31 | CarId = c.Id, 32 | BrandId=c.BrandId, 33 | ColorId=c.ColorId, 34 | BrandModel =c.CarName, 35 | BrandName =b.BrandName, 36 | ColorName = o.ColorName, 37 | DailyPrice = c.DailyPrice, 38 | ModelYear=c.ModelYear, 39 | MinFindeks=c.MinFindeks 40 | 41 | }; 42 | return result.ToList(); 43 | 44 | 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Core/Utilities/FileUploads/FileHelper.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using Core.Utilities.Results; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Text; 8 | 9 | namespace Core.Utilities.FileUploads 10 | { 11 | public class FileHelper 12 | 13 | { 14 | private static string currentDirectory = Environment.CurrentDirectory + @"\wwwroot"; 15 | private static string path = @"\images\"; 16 | 17 | 18 | public static IResult Add(FileTools file) 19 | { 20 | if (file.Files.Length > 0) 21 | { 22 | 23 | var guidName = Guid.NewGuid().ToString(); 24 | var type = Path.GetExtension(file.Files.FileName); 25 | 26 | using (FileStream filestream = File.Create(currentDirectory + path + guidName + type)) 27 | { 28 | 29 | file.Files.CopyTo(filestream); 30 | filestream.Flush(); 31 | 32 | } 33 | return new SuccessResult((guidName + type)); 34 | } 35 | return new ErrorResult(); 36 | 37 | } 38 | public static IResult Delete(string file) 39 | { 40 | 41 | File.Delete((currentDirectory + path + file)); 42 | 43 | return new SuccessResult(); 44 | 45 | 46 | } 47 | public static IResult Update(FileTools file, string imagePath) 48 | { 49 | 50 | if (file.Files.Length > 0) 51 | { 52 | var guidName = Guid.NewGuid().ToString(); 53 | var type = Path.GetExtension(file.Files.FileName); 54 | FileHelper.Delete(imagePath); 55 | FileHelper.Add(file); 56 | 57 | return new SuccessResult((guidName + type)); 58 | } 59 | return new ErrorResult(); 60 | } 61 | 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfRentalDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using DataAccess.Abstract; 3 | using Entities.Concrete; 4 | using Entities.DTOs; 5 | using System; 6 | using System.Linq; 7 | using System.Collections.Generic; 8 | using System.Text; 9 | using System.Linq.Expressions; 10 | 11 | namespace DataAccess.Concrete.EntityFramework 12 | { 13 | public class EfRentalDal : EfEntityRepositoryBase ,IRentalDal 14 | { public List GetRentalDetails(Expression> filter = null) 15 | { 16 | using (RentalContext context = new RentalContext()) 17 | { 18 | var result = from r in context.Rentals 19 | join c in context.Cars 20 | on r.CarId equals c.Id 21 | join br in context.Brands 22 | on c.BrandId equals br.Id 23 | join u in context.Users 24 | on r.CustomerId equals u.Id 25 | join co in context.Customers 26 | on r.CustomerId equals co.UserId 27 | select new RentalDetailDto 28 | { 29 | RentId=r.Id, 30 | 31 | BrandName=br.BrandName+" "+c.CarName, 32 | 33 | 34 | 35 | UserName=u.FirstName+" "+u.LastName, 36 | 37 | RentDate=r.RentDate, 38 | ReturnDate= (DateTime)r.ReturnDate 39 | 40 | }; 41 | return result.ToList(); 42 | } 43 | 44 | } 45 | 46 | 47 | 48 | 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /WebAPI/Controllers/AuthController.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Entities.DTOs; 3 | using Microsoft.AspNetCore.Http; 4 | using Microsoft.AspNetCore.Mvc; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace WebAPI.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class AuthController : ControllerBase 15 | { 16 | private IAuthService _authService; 17 | 18 | 19 | public AuthController(IAuthService authService) 20 | { 21 | _authService = authService; 22 | 23 | } 24 | 25 | [HttpPost("login")] 26 | public ActionResult Login(UserForLoginDto userForLoginDto) 27 | { 28 | var userToLogin = _authService.Login(userForLoginDto); 29 | if (!userToLogin.Success) 30 | { 31 | return BadRequest(userToLogin); 32 | } 33 | 34 | var result = _authService.CreateAccessToken(userToLogin.Data); 35 | if (result.Success) 36 | { 37 | return Ok(result); 38 | } 39 | 40 | return BadRequest(result); 41 | } 42 | 43 | [HttpPost("register")] 44 | public ActionResult Register(UserForRegisterDto userForRegisterDto) 45 | { 46 | var userExists = _authService.UserExists(userForRegisterDto.Email); 47 | if (!userExists.Success) 48 | { 49 | return BadRequest(userExists); 50 | } 51 | 52 | var registerResult = _authService.Register(userForRegisterDto, userForRegisterDto.Password); 53 | var result = _authService.CreateAccessToken(registerResult.Data); 54 | if (result.Success) 55 | { 56 | return Ok(result); 57 | } 58 | 59 | return BadRequest(result); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Business/Concrete/CustomerManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Constants; 3 | using Business.ValidationRules.FluentValidation; 4 | using Core.Aspects.Autofac.Validation; 5 | using Core.Utilities.Results; 6 | using DataAccess.Abstract; 7 | using Entities.Concrete; 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Linq; 11 | using System.Text; 12 | 13 | namespace Business.Concrete 14 | { 15 | public class CustomerManager : ICustomerService 16 | { 17 | 18 | ICustomerDal _customerDal; 19 | public CustomerManager(ICustomerDal customerDal) 20 | { 21 | _customerDal = customerDal; 22 | } 23 | 24 | [ValidationAspect(typeof(CustomerValidator))] 25 | public IResult Add(Customer customer) 26 | { 27 | 28 | _customerDal.Add(customer); 29 | return new SuccessResult(Messages.Added); 30 | } 31 | 32 | public IResult Delete(Customer customer) 33 | { 34 | 35 | _customerDal.Delete(customer); 36 | 37 | return new SuccessResult(Messages.Deleted); 38 | 39 | 40 | } 41 | 42 | public IDataResult> GetAllCustomers() 43 | { 44 | return new SuccessDataResult>(_customerDal.GetAll(), Messages.CustomersListed); 45 | } 46 | 47 | public IDataResult GetByCustomerId(int id) 48 | { 49 | return new SuccessDataResult(_customerDal.Get(c => c.UserId == id)); 50 | } 51 | 52 | public IResult Update(Customer customer) 53 | { 54 | _customerDal.Update(customer); 55 | return new SuccessResult(Messages.Updated); 56 | } 57 | 58 | public IDataResult Findeks(int cusId) 59 | { 60 | var result = _customerDal.Get(c => c.Id == cusId); 61 | return new SuccessDataResult(result.Findeks); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Core/Extensions/ExceptionMiddleware.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | using FluentValidation.Results; 3 | using Microsoft.AspNetCore.Http; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Net; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace Core.Extensions 11 | { 12 | public class ExceptionMiddleware 13 | { 14 | private RequestDelegate _next; 15 | 16 | public ExceptionMiddleware(RequestDelegate next) 17 | { 18 | _next = next; 19 | } 20 | 21 | public async Task InvokeAsync(HttpContext httpContext) 22 | { 23 | try 24 | { 25 | await _next(httpContext); 26 | } 27 | catch (Exception e) 28 | { 29 | await HandleExceptionAsync(httpContext, e); 30 | } 31 | } 32 | 33 | private Task HandleExceptionAsync(HttpContext httpContext, Exception e) 34 | { 35 | httpContext.Response.ContentType = "application/json"; 36 | httpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError; 37 | 38 | string message = "Internal Server Error"; 39 | IEnumerable errors; 40 | if (e.GetType() == typeof(ValidationException)) 41 | { 42 | message = e.Message; 43 | errors = ((ValidationException)e).Errors; 44 | httpContext.Response.StatusCode = 400; 45 | 46 | return httpContext.Response.WriteAsync(new ValidationErrorDetails 47 | { 48 | StatusCode = 400, 49 | Message = message, 50 | Errors = errors, 51 | }.ToString()); 52 | } 53 | 54 | return httpContext.Response.WriteAsync(new ErrorDetails 55 | { 56 | StatusCode = httpContext.Response.StatusCode, 57 | Message = message 58 | }.ToString()); 59 | } 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /WebAPI/Controllers/OperationsController.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Core.Entities.Concrete; 3 | using Microsoft.AspNetCore.Http; 4 | using Microsoft.AspNetCore.Mvc; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace WebAPI.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class OperationsController : ControllerBase 15 | { IOperationService _operationService; 16 | public OperationsController(IOperationService operationService) 17 | { 18 | _operationService = operationService; 19 | } 20 | 21 | [HttpPost("add")] 22 | public IActionResult Add(OperationClaim operation) 23 | { 24 | var result = _operationService.Add(operation); 25 | if (result.Success) 26 | { 27 | return Ok(result); 28 | } 29 | 30 | return BadRequest(result); 31 | } 32 | 33 | [HttpPost("delete")] 34 | public IActionResult Delete(OperationClaim operation) 35 | { 36 | var result = _operationService.Delete(operation); 37 | if (result.Success) 38 | { 39 | return Ok(result); 40 | } 41 | return BadRequest(result); 42 | 43 | } 44 | [HttpPut("update")] 45 | public IActionResult Update(OperationClaim operation) 46 | { 47 | var result = _operationService.Update(operation); 48 | if (result.Success) 49 | { 50 | return Ok(result); 51 | } 52 | return BadRequest(result); 53 | } 54 | [HttpGet("getall")] 55 | public IActionResult GetAll() 56 | { 57 | var result = _operationService.GetAll(); 58 | if (result.Success) 59 | { 60 | return Ok(result); 61 | } 62 | return BadRequest(result); 63 | } 64 | 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /WebAPI/Controllers/UserOperationsController.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Core.Entities.Concrete; 3 | using Microsoft.AspNetCore.Http; 4 | using Microsoft.AspNetCore.Mvc; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace WebAPI.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class UserOperationsController : ControllerBase 15 | { 16 | IUserOperationService _uOperationService; 17 | public UserOperationsController(IUserOperationService uOperationService) 18 | { 19 | _uOperationService = uOperationService; 20 | } 21 | 22 | [HttpPost("add")] 23 | public IActionResult Add(UserOperationClaim operation) 24 | { 25 | var result = _uOperationService.Add(operation); 26 | if (result.Success) 27 | { 28 | return Ok(result); 29 | } 30 | 31 | return BadRequest(result); 32 | } 33 | 34 | [HttpPost("delete")] 35 | public IActionResult Delete(UserOperationClaim operation) 36 | { 37 | var result = _uOperationService.Delete(operation); 38 | if (result.Success) 39 | { 40 | return Ok(result); 41 | } 42 | return BadRequest(result); 43 | 44 | } 45 | [HttpPut("update")] 46 | public IActionResult Update(UserOperationClaim operation) 47 | { 48 | var result = _uOperationService.Update(operation); 49 | if (result.Success) 50 | { 51 | return Ok(result); 52 | } 53 | return BadRequest(result); 54 | } 55 | [HttpGet("getall")] 56 | public IActionResult GetAll() 57 | { 58 | var result = _uOperationService.GetAll(); 59 | if (result.Success) 60 | { 61 | return Ok(result); 62 | } 63 | return BadRequest(result); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Core/DataAccess/EntityFramework/EfEntityRepositoryBase.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using Microsoft.EntityFrameworkCore; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Linq.Expressions; 7 | using System.Text; 8 | 9 | namespace Core.DataAccess.EntityFramework 10 | { 11 | public class EfEntityRepositoryBase : IEntityRepository 12 | where TEntity : class, IEntity, new() 13 | where TContext : DbContext, new() 14 | { 15 | public void Add(TEntity entity) 16 | { 17 | using (TContext context=new TContext()) 18 | { 19 | var addedEntity = context.Entry(entity); 20 | addedEntity.State = EntityState.Added; 21 | context.SaveChanges(); 22 | } 23 | } 24 | 25 | public void Delete(TEntity entity) 26 | { 27 | using (TContext context = new TContext()) 28 | { 29 | var deletedEntity = context.Entry(entity); 30 | deletedEntity.State = EntityState.Deleted; 31 | context.SaveChanges(); 32 | } 33 | } 34 | 35 | public TEntity Get(Expression> filter) 36 | { 37 | using (TContext context = new TContext()) 38 | { 39 | return context.Set().SingleOrDefault(filter); 40 | } 41 | } 42 | 43 | public List GetAll(Expression> filter = null) 44 | { 45 | using (TContext context = new TContext()) 46 | { 47 | return filter == null 48 | ? context.Set().ToList() 49 | : context.Set().Where(filter).ToList(); 50 | } 51 | } 52 | 53 | public void Update(TEntity entity) 54 | { 55 | using (TContext context = new TContext()) 56 | { 57 | var updatedEntity = context.Entry(entity); 58 | updatedEntity.State = EntityState.Modified; 59 | context.SaveChanges(); 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /WebAPI/Controllers/ColorsController.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Entities.Concrete; 3 | using Microsoft.AspNetCore.Http; 4 | using Microsoft.AspNetCore.Mvc; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace WebAPI.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class ColorsController : ControllerBase 15 | { 16 | IColorService _colorService; 17 | public ColorsController(IColorService colorService) 18 | { 19 | _colorService = colorService; 20 | } 21 | [HttpPost("add")] 22 | public IActionResult Add(Color color) 23 | { 24 | var result = _colorService.Add(color); 25 | if (result.Success) 26 | { 27 | return Ok(result); 28 | } 29 | 30 | return BadRequest(result); 31 | } 32 | [HttpPost("delete")] 33 | public IActionResult Delete(Color color) 34 | { 35 | var result = _colorService.Delete(color); 36 | if (result.Success) 37 | { 38 | return Ok(result); 39 | } 40 | return BadRequest(result); 41 | 42 | } 43 | [HttpPost("update")] 44 | public IActionResult Update(Color color) 45 | { 46 | var result = _colorService.Update(color); 47 | if (result.Success) 48 | { 49 | return Ok(result); 50 | } 51 | return BadRequest(result); 52 | } 53 | [HttpGet("getall")] 54 | public IActionResult GetAll() 55 | { 56 | var result = _colorService.GetAllColors(); 57 | if (result.Success) 58 | { 59 | return Ok(result); 60 | } 61 | return BadRequest(result); 62 | } 63 | [HttpGet("getbyid")] 64 | public IActionResult GetById(int id) 65 | { 66 | var result = _colorService.GetByColorId(id); 67 | if (result.Success) 68 | { 69 | return Ok(result); 70 | } 71 | return BadRequest(result); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /WebAPI/Controllers/BrandsController.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Entities.Concrete; 3 | using Microsoft.AspNetCore.Http; 4 | using Microsoft.AspNetCore.Mvc; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace WebAPI.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class BrandsController : ControllerBase 15 | { 16 | IBrandService _brandService; 17 | 18 | public BrandsController(IBrandService brandService) 19 | { 20 | _brandService = brandService; 21 | } 22 | 23 | [HttpPost("add")] 24 | public IActionResult Add(Brand brand) 25 | { 26 | var result = _brandService.Add(brand); 27 | if (result.Success) 28 | { 29 | return Ok(result); 30 | } 31 | 32 | return BadRequest(result); 33 | } 34 | [HttpPost("delete")] 35 | public IActionResult Delete(Brand brand) 36 | { 37 | var result = _brandService.Delete(brand); 38 | if (result.Success) 39 | { 40 | return Ok(result); 41 | } 42 | return BadRequest(result); 43 | 44 | } 45 | [HttpPost("update")] 46 | public IActionResult Update(Brand brand) 47 | { 48 | var result = _brandService.Update(brand); 49 | if (result.Success) 50 | { 51 | return Ok(result); 52 | } 53 | return BadRequest(result); 54 | } 55 | [HttpGet("getall")] 56 | public IActionResult GetAll() 57 | { 58 | var result = _brandService.GetAllBrands(); 59 | if (result.Success) 60 | { 61 | return Ok(result); 62 | } 63 | return BadRequest(result); 64 | } 65 | [HttpGet("getbyid")] 66 | public IActionResult GetById(int id) 67 | { 68 | var result = _brandService.GetByBrandId(id); 69 | if (result.Success) 70 | { 71 | return Ok(result); 72 | } 73 | return BadRequest(result); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /WebAPI/Controllers/CustomersController.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Entities.Concrete; 3 | using Microsoft.AspNetCore.Http; 4 | using Microsoft.AspNetCore.Mvc; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace WebAPI.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class CustomersController : ControllerBase 15 | { 16 | ICustomerService _customerService; 17 | public CustomersController(ICustomerService customerService) 18 | { 19 | _customerService = customerService; 20 | } 21 | [HttpPost("add")] 22 | public IActionResult Add(Customer customer) 23 | { 24 | var result = _customerService.Add(customer); 25 | if (result.Success) 26 | { 27 | return Ok(result); 28 | } 29 | 30 | return BadRequest(result); 31 | } 32 | [HttpPost("delete")] 33 | public IActionResult Delete(Customer customer) 34 | { 35 | var result = _customerService.Delete(customer); 36 | if (result.Success) 37 | { 38 | return Ok(result); 39 | } 40 | return BadRequest(result); 41 | 42 | } 43 | [HttpPut("update")] 44 | public IActionResult Update(Customer Customer) 45 | { 46 | var result = _customerService.Update(Customer); 47 | if (result.Success) 48 | { 49 | return Ok(result); 50 | } 51 | return BadRequest(result); 52 | } 53 | [HttpGet("getall")] 54 | public IActionResult GetAll() 55 | { 56 | var result = _customerService.GetAllCustomers(); 57 | if (result.Success) 58 | { 59 | return Ok(result); 60 | } 61 | return BadRequest(result); 62 | } 63 | [HttpGet("getbyid")] 64 | public IActionResult GetById(int id) 65 | { 66 | var result = _customerService.GetByCustomerId(id); 67 | if (result.Success) 68 | { 69 | return Ok(result); 70 | } 71 | return BadRequest(result); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Core/CrossCuttingConcerns/Caching/Microsoft/MemoryCacheManager.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.IoC; 2 | using Microsoft.Extensions.Caching.Memory; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | using System.Text.RegularExpressions; 7 | using Microsoft.Extensions.DependencyInjection; 8 | using System.Linq; 9 | 10 | namespace Core.CrossCuttingConcerns.Caching.Microsoft 11 | { 12 | public class MemoryCacheManager : ICacheManager 13 | { 14 | IMemoryCache _memoryCache; 15 | public MemoryCacheManager() 16 | { 17 | _memoryCache = ServiceTool.ServiceProvider.GetService(); 18 | } 19 | public void Add(string key, object value, int duration) 20 | { 21 | _memoryCache.Set(key, value, TimeSpan.FromMinutes(duration)); 22 | } 23 | 24 | public T Get(string key) 25 | { 26 | return _memoryCache.Get(key); 27 | } 28 | 29 | public object Get(string key) 30 | { 31 | return _memoryCache.Get(key); 32 | } 33 | 34 | public bool IsAdd(string key) 35 | { 36 | return _memoryCache.TryGetValue(key, out _); 37 | } 38 | 39 | public void Remove(string key) 40 | { 41 | _memoryCache.Remove(key); 42 | } 43 | 44 | public void RemoveByPattern(string pattern) 45 | { // çalışma anında bellekten siliyor with reflection ... 46 | var cacheEntriesCollectionDefinition = typeof(MemoryCache).GetProperty("EntriesCollection", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); 47 | var cacheEntriesCollection = cacheEntriesCollectionDefinition.GetValue(_memoryCache) as dynamic; 48 | List cacheCollectionValues = new List(); 49 | 50 | foreach (var cacheItem in cacheEntriesCollection) 51 | { 52 | ICacheEntry cacheItemValue = cacheItem.GetType().GetProperty("Value").GetValue(cacheItem, null); 53 | cacheCollectionValues.Add(cacheItemValue); 54 | } 55 | 56 | var regex = new Regex(pattern, RegexOptions.Singleline | RegexOptions.Compiled | RegexOptions.IgnoreCase); 57 | var keysToRemove = cacheCollectionValues.Where(d => regex.IsMatch(d.Key.ToString())).Select(d => d.Key).ToList(); 58 | 59 | foreach (var key in keysToRemove) 60 | { 61 | _memoryCache.Remove(key); 62 | } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /WebAPI/Controllers/OrdersController.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Entities.Concrete; 3 | using Microsoft.AspNetCore.Http; 4 | using Microsoft.AspNetCore.Mvc; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace WebAPI.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class OrdersController : ControllerBase 15 | { 16 | public class BrandsController : ControllerBase 17 | { 18 | IOrderService _orderService; 19 | 20 | public BrandsController(IOrderService orderService) 21 | { 22 | _orderService = orderService; 23 | } 24 | 25 | [HttpPost("add")] 26 | public IActionResult Add(Order order) 27 | { 28 | var result = _orderService.Add(order); 29 | if (result.Success) 30 | { 31 | return Ok(result); 32 | } 33 | 34 | return BadRequest(result); 35 | } 36 | [HttpPost("delete")] 37 | public IActionResult Delete(Order order) 38 | { 39 | var result = _orderService.Delete(order); 40 | if (result.Success) 41 | { 42 | return Ok(result); 43 | } 44 | return BadRequest(result); 45 | 46 | } 47 | [HttpPost("update")] 48 | public IActionResult Update(Order order) 49 | { 50 | var result = _orderService.Update(order); 51 | if (result.Success) 52 | { 53 | return Ok(result); 54 | } 55 | return BadRequest(result); 56 | } 57 | [HttpGet("getall")] 58 | public IActionResult GetAll() 59 | { 60 | var result = _orderService.GetAll(); 61 | if (result.Success) 62 | { 63 | return Ok(result); 64 | } 65 | return BadRequest(result); 66 | } 67 | //[HttpGet("getbyid")] 68 | //public IActionResult GetByCardId(int id) 69 | //{ 70 | // var result = _orderService.GetByCarddId(id); 71 | // if (result.Success) 72 | // { 73 | // return Ok(result); 74 | // } 75 | // return BadRequest(result); 76 | //} 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /WebAPI/Controllers/RentalsController.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Entities.Concrete; 3 | using Microsoft.AspNetCore.Http; 4 | using Microsoft.AspNetCore.Mvc; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace WebAPI.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class RentalsController : ControllerBase 15 | { 16 | IRentalService _rentalService; 17 | public RentalsController(IRentalService rentalService) 18 | { 19 | _rentalService = rentalService; 20 | } 21 | [HttpPost("add")] 22 | public IActionResult Add(Rental rental) 23 | { 24 | var result = _rentalService.Rent(rental); 25 | if (result.Success) 26 | { 27 | return Ok(result); 28 | } 29 | 30 | return BadRequest(result); 31 | } 32 | [HttpPost("delete")] 33 | public IActionResult Delete(Rental rental) 34 | { 35 | var result = _rentalService.Delete(rental); 36 | if (result.Success) 37 | { 38 | return Ok(result); 39 | } 40 | return BadRequest(result); 41 | 42 | } 43 | [HttpPut("update")] 44 | public IActionResult Update(Rental rental) 45 | { 46 | var result = _rentalService.Update(rental); 47 | if (result.Success) 48 | { 49 | return Ok(result); 50 | } 51 | return BadRequest(result); 52 | } 53 | [HttpGet("getall")] 54 | public IActionResult GetAll() 55 | { 56 | var result = _rentalService.GetAllRentals(); 57 | if (result.Success) 58 | { 59 | return Ok(result); 60 | } 61 | return BadRequest(result); 62 | } 63 | [HttpGet("getbyid")] 64 | public IActionResult GetById(int id) 65 | { 66 | var result = _rentalService.GetByRentId(id); 67 | if (result.Success) 68 | { 69 | return Ok(result); 70 | } 71 | return BadRequest(result); 72 | } 73 | [HttpGet("getdetail")] 74 | public IActionResult GetDetail() 75 | { 76 | var result = _rentalService.GetRentalDetailDtos(); 77 | if (result.Success) 78 | { 79 | return Ok(result); 80 | } 81 | return BadRequest(result); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /WebAPI/Controllers/UsersController.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Core.Entities.Concrete; 3 | using Entities.Concrete; 4 | using Microsoft.AspNetCore.Http; 5 | using Microsoft.AspNetCore.Mvc; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Threading.Tasks; 10 | 11 | namespace WebAPI.Controllers 12 | { 13 | [Route("api/[controller]")] 14 | [ApiController] 15 | public class UsersController : ControllerBase 16 | { 17 | IUserService _userService; 18 | public UsersController(IUserService userService) 19 | { 20 | _userService = userService; 21 | } 22 | [HttpPost("add")] 23 | public IActionResult Add(User user) 24 | { 25 | var result = _userService.Add(user); 26 | if (result.Success) 27 | { 28 | return Ok(result); 29 | } 30 | 31 | return BadRequest(result); 32 | } 33 | [HttpPost("delete")] 34 | public IActionResult Delete(User user) 35 | { 36 | var result = _userService.Delete(user); 37 | if (result.Success) 38 | { 39 | return Ok(result); 40 | } 41 | return BadRequest(result); 42 | 43 | } 44 | [HttpPost("update")] 45 | public IActionResult Update(User user,string password) 46 | { 47 | var result = _userService.Update(user,password); 48 | if (result.Success) 49 | { 50 | return Ok(result); 51 | } 52 | return BadRequest(result); 53 | } 54 | [HttpGet("getall")] 55 | public IActionResult GetAll() 56 | { 57 | var result = _userService.GetAllUsers(); 58 | if (result.Success) 59 | { 60 | return Ok(result); 61 | } 62 | return BadRequest(result); 63 | } 64 | [HttpGet("getbyid")] 65 | public IActionResult GetById(int id) 66 | { 67 | var result = _userService.GetByUserId(id); 68 | if (result.Success) 69 | { 70 | return Ok(result); 71 | } 72 | return BadRequest(result); 73 | } 74 | [HttpGet("getclaims")] 75 | public IActionResult GetClaims(User user) 76 | { 77 | var result = _userService.GetClaims(user); 78 | if (result.Success) 79 | { 80 | return Ok(result); 81 | } 82 | return BadRequest(result); 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /WebAPI/Controllers/CardsController.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Entities.Concrete; 3 | using Microsoft.AspNetCore.Http; 4 | using Microsoft.AspNetCore.Mvc; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace WebAPI.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class CardsController : ControllerBase 15 | { 16 | ICardService _cardService; 17 | public CardsController(ICardService cardService) 18 | { 19 | _cardService = cardService; 20 | } 21 | 22 | [HttpPost("add")] 23 | public IActionResult Add(Card card) 24 | { 25 | var result = _cardService.Add(card); 26 | if (result.Success) 27 | { 28 | return Ok(result); 29 | } 30 | 31 | return BadRequest(result); 32 | } 33 | 34 | 35 | [HttpPost("delete")] 36 | public IActionResult Delete(Card card) 37 | { 38 | var result = _cardService.Delete(card); 39 | if (result.Success) 40 | { 41 | return Ok(result); 42 | } 43 | return BadRequest(result); 44 | 45 | } 46 | [HttpPut("update")] 47 | public IActionResult Update(Card card) 48 | { 49 | var result = _cardService.Update(card); 50 | if (result.Success) 51 | { 52 | return Ok(result); 53 | } 54 | return BadRequest(result); 55 | } 56 | [HttpGet("getall")] 57 | public IActionResult GetAll() 58 | { 59 | var result = _cardService.GetAllCards(); 60 | if (result.Success) 61 | { 62 | return Ok(result); 63 | } 64 | return BadRequest(result); 65 | } 66 | [HttpGet("getbyCustomerid")] 67 | public IActionResult GetByCustomerId(int id) 68 | { 69 | var result = _cardService.GetByCustomerId(id); 70 | if (result.Success) 71 | { 72 | return Ok(result); 73 | } 74 | return BadRequest(result); 75 | } 76 | 77 | 78 | [HttpGet("getcardnumber")] 79 | public IActionResult GetbyColorId(string cardNumber) 80 | { 81 | var result = _cardService.GetbyCardNumber(cardNumber); 82 | if (result.Success) 83 | { 84 | return Ok(result); 85 | } 86 | return BadRequest(result); 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Business/Constants/Messages.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Business.Constants 6 | { 7 | public static class Messages 8 | { 9 | public static string Added = "Ekleme işlemi gerçekleşti"; 10 | public static string Deleted = "Silme işlemi gerçekleşti"; 11 | public static string Updated = "Güncelleme işlemi gerçekleşti"; 12 | public static string Rented = "Kiralama gerçekleşti"; 13 | public static string RentOff = "Sözleşme iptal edildi"; 14 | public static string RentUpdate = "Sözleşme güncellendi"; 15 | public static string RentList = "Sözleşmeler Listelendi"; 16 | public static string RentGet = "Sözleşme Getirildi"; 17 | public static string UsersListed = "Kullanıcılar Listelendi"; 18 | public static string UserListed = "Kullanıcı Listelendi"; 19 | public static string CustomersListed = "Müşteriler Listelendi"; 20 | public static string CustomerListed = "Müşteri Listelendi"; 21 | public static string ReturnDateNull = "Araba mevcut değil"; 22 | 23 | 24 | public static string CantDeleted = "Silme başarısız"; 25 | public static string UserNotFound = "Kullanıcı bulunamadı"; 26 | public static string PasswordError = "Şifre hatalı"; 27 | public static string SuccessfulLogin = "Sisteme giriş başarılı"; 28 | public static string UserAlreadyExists = "Bu kullanıcı zaten mevcut"; 29 | public static string UserRegistered = "Kullanıcı başarıyla kaydedildi"; 30 | public static string AccessTokenCreated = "Access token başarıyla oluşturuldu"; 31 | 32 | public static string AuthorizationDenied = "Yetkiniz yok"; 33 | public static string ProductNameAlreadyExists = "Ürün ismi zaten mevcut"; 34 | 35 | public static string ColorsListed = "Renkler listelendi"; 36 | public static string CantAdded = "Ekleme başarısız"; 37 | public static string CarsListed = "Arabalar listelendi"; 38 | public static string ColorAddInvalid = "Var olan Renk eklenemez"; 39 | public static string BrandAddInvalid = "Var olan Marka eklenemez"; 40 | public static string ImagesAdded = "Görüntü Eklendi"; 41 | public static string ImagesCantAdded = "Ekleme başarısız"; 42 | public static string TransactionTested = "Transaction test edildi"; 43 | public static string FindeksSuccess = "Findeks Puanı yeterli"; 44 | public static string FindeksFail = "Yetersiz Findeks"; 45 | public static string OrderAdd = "Ödeme Alındı"; 46 | public static string OrderUpdate = "Ödeme Güncellendi"; 47 | public static string OrderDelete = "Ödeme İptal Edildi"; 48 | } 49 | } 50 | 51 | 52 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /WebAPI/Controllers/CarImagesController.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Core.Utilities.FileUploads; 3 | using Entities.Concrete; 4 | using Microsoft.AspNetCore.Http; 5 | using Microsoft.AspNetCore.Mvc; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Threading.Tasks; 10 | 11 | namespace WebAPI.Controllers 12 | { 13 | [Route("api/[controller]")] 14 | [ApiController] 15 | public class CarImagesController : ControllerBase 16 | { 17 | ICarImageService _carImageService; 18 | public CarImagesController(ICarImageService carImageService) 19 | { 20 | _carImageService = carImageService; 21 | } 22 | 23 | 24 | [HttpPost("add")] 25 | public IActionResult Add([FromForm] FileTools file, [FromForm] CarImage carImage) 26 | { 27 | 28 | var result = _carImageService.Add(file,carImage); 29 | if (result.Success) 30 | { 31 | return Ok(result); 32 | } 33 | return BadRequest(result); 34 | } 35 | [HttpPost("delete")] 36 | public IActionResult Delete([FromForm] CarImage carImage) 37 | { 38 | var result = _carImageService.Delete(carImage); 39 | if (result.Success) 40 | { 41 | return Ok(result); 42 | } 43 | return BadRequest(result); 44 | } 45 | [HttpPost("update")] 46 | public IActionResult Update([FromForm] FileTools file, [FromForm] CarImage carImage) 47 | { 48 | var result = _carImageService.Update(file, carImage); 49 | if (result.Success) 50 | { 51 | return Ok(result); 52 | } 53 | return BadRequest(result); 54 | } 55 | [HttpGet("getbyid")] 56 | public IActionResult GetAllById(int id) 57 | { 58 | var result = _carImageService.GetById(id); 59 | if (result.Success) 60 | { 61 | return Ok(result); 62 | } 63 | 64 | return BadRequest(result); 65 | } 66 | [HttpGet("getbycarid")] 67 | public IActionResult GetAllByCarId(int carId) 68 | { 69 | var result = _carImageService.GetByCarId(carId); 70 | if (result.Success) 71 | { 72 | return Ok(result); 73 | } 74 | 75 | return BadRequest(result); 76 | } 77 | [HttpGet("getall")] 78 | public IActionResult GetAll() 79 | { 80 | var result = _carImageService.GetAll(); 81 | if (result.Success) 82 | { 83 | return Ok(result); 84 | } 85 | 86 | return BadRequest(result); 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Core/Utilities/Security/JWT/JwtHelper.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Concrete; 2 | using Core.Extensions; 3 | using Core.Utilities.Security.Encryption; 4 | using Microsoft.Extensions.Configuration; 5 | using Microsoft.IdentityModel.Tokens; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.IdentityModel.Tokens.Jwt; 9 | using System.Linq; 10 | using System.Security.Claims; 11 | using System.Text; 12 | 13 | namespace Core.Utilities.Security.JWT 14 | { 15 | public class JwtHelper : ITokenHelper 16 | { 17 | public IConfiguration Configuration { get; } 18 | private TokenOptions _tokenOptions; 19 | private DateTime _accessTokenExpiration; 20 | public JwtHelper(IConfiguration configuration) 21 | { 22 | Configuration = configuration; 23 | _tokenOptions = Configuration.GetSection("TokenOptions").Get(); 24 | 25 | } 26 | public AccessToken CreateToken(User user, List operationClaims) 27 | { 28 | _accessTokenExpiration = DateTime.Now.AddMinutes(_tokenOptions.AccessTokenExpiration); 29 | var securityKey = SecurityKeyHelper.CreateSecurityKey(_tokenOptions.SecurityKey); 30 | var signingCredentials = SigningCredentialsHelper.CreateSigningCredentials(securityKey); 31 | var jwt = CreateJwtSecurityToken(_tokenOptions, user, signingCredentials, operationClaims); 32 | var jwtSecurityTokenHandler = new JwtSecurityTokenHandler(); 33 | var token = jwtSecurityTokenHandler.WriteToken(jwt); 34 | 35 | return new AccessToken 36 | { 37 | Token = token, 38 | Expiration = _accessTokenExpiration 39 | }; 40 | 41 | } 42 | 43 | public JwtSecurityToken CreateJwtSecurityToken(TokenOptions tokenOptions, User user, 44 | SigningCredentials signingCredentials, List operationClaims) 45 | { 46 | var jwt = new JwtSecurityToken( 47 | issuer: tokenOptions.Issuer, 48 | audience: tokenOptions.Audience, 49 | expires: _accessTokenExpiration, 50 | notBefore: DateTime.Now, 51 | claims: SetClaims(user, operationClaims), 52 | signingCredentials: signingCredentials 53 | ); 54 | return jwt; 55 | } 56 | 57 | private IEnumerable SetClaims(User user, List operationClaims) 58 | { 59 | var claims = new List(); 60 | claims.AddNameIdentifier(user.Id.ToString()); 61 | claims.AddEmail(user.Email); 62 | claims.AddName($"{user.FirstName} {user.LastName}"); 63 | claims.AddRoles(operationClaims.Select(c => c.Name).ToArray()); 64 | 65 | return claims; 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Business/Concrete/UserManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Constants; 3 | using Business.ValidationRules.FluentValidation; 4 | using Core.Aspects.Autofac.Validation; 5 | using Core.Entities.Concrete; 6 | using Core.Utilities.Results; 7 | using Core.Utilities.Security.Hashing; 8 | using DataAccess.Abstract; 9 | using Entities.Concrete; 10 | using Entities.DTOs; 11 | using System; 12 | using System.Collections.Generic; 13 | using System.Text; 14 | 15 | namespace Business.Concrete 16 | { 17 | public class UserManager :IUserService 18 | { 19 | IUserDal _userDal; 20 | public UserManager(IUserDal userDal) 21 | { 22 | _userDal = userDal; 23 | } 24 | [ValidationAspect(typeof(UserValidator))] 25 | public IResult Add(User user) 26 | { 27 | _userDal.Add(user); 28 | return new SuccessResult(Messages.Added); 29 | } 30 | 31 | public IResult Delete(User user) 32 | { 33 | _userDal.Delete(user); 34 | return new SuccessResult(Messages.Deleted); 35 | } 36 | 37 | public IDataResult> GetAllUsers() 38 | { 39 | return new SuccessDataResult>(_userDal.GetAll(),Messages.UsersListed); 40 | } 41 | 42 | public IDataResult GetByUserId(int id) 43 | { 44 | return new SuccessDataResult(_userDal.Get(u=>u.Id==id), Messages.UserListed); 45 | } 46 | 47 | public IResult Update(User user,string password) 48 | { 49 | 50 | var result = _userDal.Get(c=>c.Id==user.Id); 51 | 52 | user.PasswordHash = result.PasswordHash; 53 | user.PasswordSalt = result.PasswordSalt; 54 | user.Status = result.Status; 55 | if (user.FirstName == null) 56 | { user.FirstName = result.FirstName; } 57 | if(user.LastName == null ) 58 | { user.LastName = result.LastName; } 59 | if (user.Email == null ) 60 | {user.Email = result.Email; } 61 | if(password != "null") 62 | { 63 | byte[] passwordHash, passwordSalt; 64 | HashingHelper.CreatePasswordHash(password, out passwordHash, out passwordSalt); 65 | user.PasswordHash = passwordHash; 66 | user.PasswordSalt = passwordSalt; 67 | } 68 | 69 | _userDal.Update(user); 70 | return new SuccessResult(Messages.Updated); 71 | } 72 | public IDataResult> GetClaims(User user) 73 | { 74 | var getClaims = _userDal.GetClaims(user); 75 | return new SuccessDataResult>(getClaims); 76 | } 77 | 78 | 79 | public IDataResult GetByMail(string email) 80 | { 81 | var getByMail = _userDal.Get(u => u.Email == email); 82 | return new SuccessDataResult(getByMail); 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Business/DependencyResolvers/Autofac/AutofacBusinessModule.cs: -------------------------------------------------------------------------------- 1 | using Autofac; 2 | using Autofac.Extras.DynamicProxy; 3 | using Business.Abstract; 4 | using Business.Concrete; 5 | using Castle.DynamicProxy; 6 | using Core.Utilities.Interceptors; 7 | using Core.Utilities.Security.JWT; 8 | using DataAccess.Abstract; 9 | using DataAccess.Concrete.EntityFramework; 10 | using System; 11 | using System.Collections.Generic; 12 | using System.Text; 13 | 14 | namespace Business.DependencyResolvers.Autofac 15 | { 16 | public class AutofacBusinessModule :Module 17 | { 18 | protected override void Load(ContainerBuilder builder) 19 | { 20 | builder.RegisterType().As().SingleInstance(); 21 | builder.RegisterType().As().SingleInstance(); 22 | 23 | builder.RegisterType().As().SingleInstance(); 24 | builder.RegisterType().As().SingleInstance(); 25 | 26 | builder.RegisterType().As().SingleInstance(); 27 | builder.RegisterType().As().SingleInstance(); 28 | 29 | builder.RegisterType().As().SingleInstance(); 30 | builder.RegisterType().As().SingleInstance(); 31 | 32 | builder.RegisterType().As().SingleInstance(); 33 | builder.RegisterType().As().SingleInstance(); 34 | 35 | builder.RegisterType().As().SingleInstance(); 36 | builder.RegisterType().As().SingleInstance(); 37 | 38 | builder.RegisterType().As().SingleInstance(); 39 | builder.RegisterType().As().SingleInstance(); 40 | 41 | builder.RegisterType().As().SingleInstance(); 42 | builder.RegisterType().As().SingleInstance(); 43 | 44 | builder.RegisterType().As().SingleInstance(); 45 | builder.RegisterType().As().SingleInstance(); 46 | 47 | builder.RegisterType().As().SingleInstance(); 48 | builder.RegisterType().As().SingleInstance(); 49 | 50 | builder.RegisterType().As().SingleInstance(); 51 | builder.RegisterType().As().SingleInstance(); 52 | 53 | builder.RegisterType().As(); 54 | builder.RegisterType().As(); 55 | 56 | var assembly = System.Reflection.Assembly.GetExecutingAssembly(); 57 | 58 | builder.RegisterAssemblyTypes(assembly).AsImplementedInterfaces() 59 | .EnableInterfaceInterceptors(new ProxyGenerationOptions() 60 | { 61 | Selector = new AspectInterceptorSelector() 62 | }).SingleInstance(); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Business/Concrete/AuthManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Constants; 3 | using Core.Entities.Concrete; 4 | using Core.Utilities.Results; 5 | using Core.Utilities.Security.Hashing; 6 | using Core.Utilities.Security.JWT; 7 | using Entities.Concrete; 8 | using Entities.DTOs; 9 | using System; 10 | using System.Collections.Generic; 11 | using System.Text; 12 | 13 | namespace Business.Concrete 14 | { 15 | public class AuthManager : IAuthService 16 | { 17 | private IUserService _userService; 18 | private ITokenHelper _tokenHelper; 19 | private ICustomerService _customerService; 20 | private IUserOperationService _userOperationService; 21 | 22 | public AuthManager(IUserService userService, ITokenHelper tokenHelper, IUserOperationService userOperationService, ICustomerService customerService) 23 | { 24 | _customerService = customerService; 25 | _userService = userService; 26 | _tokenHelper = tokenHelper; 27 | _userOperationService = userOperationService; 28 | } 29 | 30 | public IDataResult Register(UserForRegisterDto userForRegisterDto, string password) 31 | { 32 | byte[] passwordHash, passwordSalt; 33 | HashingHelper.CreatePasswordHash(password, out passwordHash, out passwordSalt); 34 | var user = new User 35 | { 36 | Email = userForRegisterDto.Email, 37 | FirstName = userForRegisterDto.FirstName, 38 | LastName = userForRegisterDto.LastName, 39 | PasswordHash = passwordHash, 40 | PasswordSalt = passwordSalt, 41 | Status = true 42 | }; 43 | _userService.Add(user); 44 | _userOperationService.Add(new UserOperationClaim { OperationClaimId = 2, UserId = user.Id }); 45 | _customerService.Add(new Customer { UserId = user.Id, Findeks = 500, CompanyName = user.LastName + " Company" }); 46 | 47 | return new SuccessDataResult(user, Messages.UserRegistered); 48 | } 49 | 50 | public IDataResult Login(UserForLoginDto userForLoginDto) 51 | { 52 | var userToCheck = _userService.GetByMail(userForLoginDto.Email); 53 | if (userToCheck == null) 54 | { 55 | return new ErrorDataResult(Messages.UserNotFound); 56 | } 57 | 58 | if (!HashingHelper.VerifyPasswordHash(userForLoginDto.Password, userToCheck.Data.PasswordHash, userToCheck.Data.PasswordSalt)) 59 | { 60 | return new ErrorDataResult(Messages.PasswordError); 61 | } 62 | 63 | return new SuccessDataResult(userToCheck.Data, Messages.SuccessfulLogin); 64 | } 65 | 66 | public IResult UserExists(string email) 67 | { 68 | if (_userService.GetByMail(email).Data != null) 69 | { 70 | return new ErrorResult(Messages.UserAlreadyExists); 71 | } 72 | return new SuccessResult(); 73 | } 74 | 75 | public IDataResult CreateAccessToken(User user) 76 | { 77 | var claims = _userService.GetClaims(user); 78 | var accessToken = _tokenHelper.CreateToken(user, claims.Data); 79 | return new SuccessDataResult(accessToken, Messages.AccessTokenCreated); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Business/Concrete/CarManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.BusinessAspects.Autofac; 3 | using Business.Constants; 4 | using Business.ValidationRules.FluentValidation; 5 | using Core.Aspects.Autofac.Caching; 6 | using Core.Aspects.Autofac.Transaction; 7 | using Core.Aspects.Autofac.Validation; 8 | using Core.Utilities.Results; 9 | using DataAccess.Abstract; 10 | using Entities.Concrete; 11 | using Entities.DTOs; 12 | using System; 13 | using System.Collections.Generic; 14 | using System.Text; 15 | using System.Threading; 16 | 17 | namespace Business.Concrete 18 | { 19 | public class CarManager : ICarService 20 | { 21 | 22 | ICarDal _carDal; 23 | public CarManager(ICarDal carDal) 24 | { 25 | _carDal = carDal; 26 | } 27 | [SecuredOperation("admin")] 28 | [ValidationAspect(typeof(CarValidator))] 29 | [CacheRemoveAspect("ICarService.Get")] 30 | public IResult Add(Car car) 31 | { 32 | 33 | _carDal.Add(car); 34 | return new SuccessResult(Messages.Added); 35 | 36 | 37 | } 38 | [TransactionScopeAspect] 39 | public IResult AddTransactionalTest(Car car) 40 | { 41 | _carDal.Add(car); 42 | 43 | 44 | _carDal.Delete(car); 45 | return new SuccessResult(Messages.TransactionTested); 46 | } 47 | 48 | public IResult Delete(Car car) 49 | { 50 | _carDal.Delete(car); 51 | return new SuccessResult(Messages.Deleted); 52 | 53 | } 54 | [CacheAspect] 55 | public IDataResult > GetAllCars() 56 | { 57 | return new SuccessDataResult> (_carDal.GetAll(),Messages.CarsListed); 58 | } 59 | [CacheAspect] 60 | public IDataResult GetByCarId(int carId) 61 | { 62 | return new SuccessDataResult( _carDal.Get(c => c.Id == carId)); 63 | } 64 | public IDataResult> GetByBrandId(int id) 65 | { 66 | return new SuccessDataResult>(_carDal.GetCarDetails(c => c.BrandId == id)); 67 | } 68 | public IDataResult> GetByColorId(int id) 69 | { 70 | return new SuccessDataResult>(_carDal.GetCarDetails(c => c.ColorId == id)); 71 | } 72 | 73 | public IDataResult< List> GetCarDetailDtos() 74 | { 75 | return new SuccessDataResult>(_carDal.GetCarDetails()); 76 | } 77 | [CacheRemoveAspect("ICarService.Get")] 78 | public IResult Update(Car car) 79 | { 80 | _carDal.Update(car); 81 | return new SuccessResult(Messages.Updated); 82 | } 83 | 84 | public IDataResult> GetColorBrandId(int? brandId, int? colorId) 85 | { 86 | return new SuccessDataResult>(_carDal.GetCarDetails(c => c.BrandId == brandId && c.ColorId==colorId)); 87 | } 88 | 89 | public IDataResult> GetCarDtoById(int carId) 90 | { 91 | return new SuccessDataResult>(_carDal.GetCarDetails(c=>c.Id==carId)); 92 | } 93 | 94 | public IDataResult Findeks(int carId) 95 | { 96 | var result = _carDal.Get(c => c.Id == carId); 97 | return new SuccessDataResult(result.MinFindeks); 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /CarRentalProject.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}") = "Entities", "Entities\Entities.csproj", "{D76DF394-542F-4A31-89C9-4375DC43B132}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Business", "Business\Business.csproj", "{25F2F973-B92B-462D-BA8C-BBE6449EA423}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataAccess", "DataAccess\DataAccess.csproj", "{17565F90-010D-4D0C-8A1A-7F0380F59126}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleUI", "ConsoleUI\ConsoleUI.csproj", "{AC8F1700-ADA5-475F-AC65-2FCB227DB3A1}" 13 | EndProject 14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core", "Core\Core.csproj", "{291EBBA1-F207-4312-B1AF-E5C65A25BE26}" 15 | EndProject 16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebAPI", "WebAPI\WebAPI.csproj", "{049A2FFF-086D-434F-9D31-59B47E10C6A5}" 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 | {D76DF394-542F-4A31-89C9-4375DC43B132}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {D76DF394-542F-4A31-89C9-4375DC43B132}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {D76DF394-542F-4A31-89C9-4375DC43B132}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {D76DF394-542F-4A31-89C9-4375DC43B132}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {25F2F973-B92B-462D-BA8C-BBE6449EA423}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {25F2F973-B92B-462D-BA8C-BBE6449EA423}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {25F2F973-B92B-462D-BA8C-BBE6449EA423}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {25F2F973-B92B-462D-BA8C-BBE6449EA423}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {17565F90-010D-4D0C-8A1A-7F0380F59126}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {17565F90-010D-4D0C-8A1A-7F0380F59126}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {17565F90-010D-4D0C-8A1A-7F0380F59126}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {17565F90-010D-4D0C-8A1A-7F0380F59126}.Release|Any CPU.Build.0 = Release|Any CPU 36 | {AC8F1700-ADA5-475F-AC65-2FCB227DB3A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 37 | {AC8F1700-ADA5-475F-AC65-2FCB227DB3A1}.Debug|Any CPU.Build.0 = Debug|Any CPU 38 | {AC8F1700-ADA5-475F-AC65-2FCB227DB3A1}.Release|Any CPU.ActiveCfg = Release|Any CPU 39 | {AC8F1700-ADA5-475F-AC65-2FCB227DB3A1}.Release|Any CPU.Build.0 = Release|Any CPU 40 | {291EBBA1-F207-4312-B1AF-E5C65A25BE26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 41 | {291EBBA1-F207-4312-B1AF-E5C65A25BE26}.Debug|Any CPU.Build.0 = Debug|Any CPU 42 | {291EBBA1-F207-4312-B1AF-E5C65A25BE26}.Release|Any CPU.ActiveCfg = Release|Any CPU 43 | {291EBBA1-F207-4312-B1AF-E5C65A25BE26}.Release|Any CPU.Build.0 = Release|Any CPU 44 | {049A2FFF-086D-434F-9D31-59B47E10C6A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 45 | {049A2FFF-086D-434F-9D31-59B47E10C6A5}.Debug|Any CPU.Build.0 = Debug|Any CPU 46 | {049A2FFF-086D-434F-9D31-59B47E10C6A5}.Release|Any CPU.ActiveCfg = Release|Any CPU 47 | {049A2FFF-086D-434F-9D31-59B47E10C6A5}.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 = {D4B0437B-FB29-4426-8277-622A55996703} 54 | EndGlobalSection 55 | EndGlobal 56 | -------------------------------------------------------------------------------- /WebAPI/Startup.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Concrete; 3 | using Core.DependencyResolvers; 4 | using Core.Extensions; 5 | using Core.Utilities.IoC; 6 | using Core.Utilities.Security.Encryption; 7 | using Core.Utilities.Security.JWT; 8 | using DataAccess.Abstract; 9 | using DataAccess.Concrete.EntityFramework; 10 | using Microsoft.AspNetCore.Authentication.JwtBearer; 11 | using Microsoft.AspNetCore.Builder; 12 | using Microsoft.AspNetCore.Hosting; 13 | using Microsoft.AspNetCore.Http; 14 | using Microsoft.AspNetCore.HttpsPolicy; 15 | using Microsoft.AspNetCore.Mvc; 16 | using Microsoft.Extensions.Configuration; 17 | using Microsoft.Extensions.DependencyInjection; 18 | using Microsoft.Extensions.Hosting; 19 | using Microsoft.Extensions.Logging; 20 | using Microsoft.IdentityModel.Tokens; 21 | using System; 22 | using System.Collections.Generic; 23 | using System.Linq; 24 | using System.Threading.Tasks; 25 | 26 | namespace WebAPI 27 | { 28 | public class Startup 29 | { 30 | public Startup(IConfiguration configuration) 31 | { 32 | Configuration = configuration; 33 | } 34 | 35 | public IConfiguration Configuration { get; } 36 | 37 | // This method gets called by the runtime. Use this method to add services to the container. 38 | public void ConfigureServices(IServiceCollection services) 39 | { 40 | services.AddControllers().AddNewtonsoftJson(); 41 | 42 | 43 | 44 | //services.AddSingleton(); 45 | //services.AddSingleton(); 46 | // services.AddSingleton(); 47 | services.AddCors(); 48 | var tokenOptions = Configuration.GetSection("TokenOptions").Get(); 49 | 50 | services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) 51 | .AddJwtBearer(options => 52 | { 53 | options.TokenValidationParameters = new TokenValidationParameters 54 | { 55 | ValidateIssuer = true, 56 | ValidateAudience = true, 57 | ValidateLifetime = true, 58 | ValidIssuer = tokenOptions.Issuer, 59 | ValidAudience = tokenOptions.Audience, 60 | ValidateIssuerSigningKey = true, 61 | IssuerSigningKey = SecurityKeyHelper.CreateSecurityKey(tokenOptions.SecurityKey) 62 | }; 63 | }); 64 | 65 | services.AddDependencyResolvers(new ICoreModule[] { 66 | new CoreModule() 67 | }); 68 | } 69 | 70 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 71 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 72 | { 73 | if (env.IsDevelopment()) 74 | { 75 | app.UseDeveloperExceptionPage(); 76 | } 77 | app.UseCors(builder => builder.WithOrigins("http://localhost:4200").AllowAnyHeader().AllowAnyOrigin()); 78 | app.ConfigureCustomExceptionMiddleware(); 79 | app.UseHttpsRedirection(); 80 | 81 | app.UseRouting(); 82 | app.UseStaticFiles(); 83 | 84 | 85 | app.UseAuthentication(); 86 | app.UseAuthorization(); 87 | 88 | app.UseEndpoints(endpoints => 89 | { 90 | endpoints.MapControllers(); 91 | }); 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /Business/Concrete/RentalManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Constants; 3 | using Business.ValidationRules.FluentValidation; 4 | using Core.Aspects.Autofac.Validation; 5 | using Core.CrossCuttingConcerns.Validation; 6 | using Core.Utilities.Business; 7 | using Core.Utilities.Results; 8 | using DataAccess.Abstract; 9 | using Entities.Concrete; 10 | using Entities.DTOs; 11 | using System; 12 | using System.Collections.Generic; 13 | using System.Linq; 14 | using System.Text; 15 | 16 | namespace Business.Concrete 17 | { 18 | public class RentalManager : IRentalService 19 | { 20 | IRentalDal _rentalDal; 21 | ICustomerService _customerService; 22 | ICarService _carService; 23 | 24 | public RentalManager(IRentalDal rentalDal ,ICustomerService customerService,ICarService carService) 25 | { 26 | _rentalDal = rentalDal; 27 | _customerService = customerService; 28 | _carService = carService; 29 | 30 | } 31 | [ValidationAspect(typeof(RentalValidator))] 32 | public IResult Rent(Rental rental) 33 | { 34 | IResult result = BusinessRules.Run(CheckCarReturnDate(rental), CheckFindeks(rental.CarId,rental.CustomerId)); 35 | 36 | if (result !=null) 37 | { 38 | return result; 39 | } 40 | 41 | 42 | _rentalDal.Add(rental); 43 | return new SuccessResult(Messages.Rented); 44 | 45 | 46 | 47 | } 48 | 49 | public IResult Delete(Rental rental) 50 | { 51 | _rentalDal.Delete(rental); 52 | return new SuccessResult(Messages.RentOff); 53 | } 54 | 55 | public IDataResult> GetAllRentals() 56 | { 57 | 58 | return new SuccessDataResult>(_rentalDal.GetAll(), Messages.RentList); 59 | 60 | } 61 | 62 | public IDataResult GetByRentId(int id) 63 | { 64 | return new SuccessDataResult(_rentalDal.Get(r => r.Id == id), Messages.RentGet); 65 | } 66 | 67 | public IDataResult> GetRentalDetailDtos() 68 | { 69 | return new SuccessDataResult>(_rentalDal.GetRentalDetails(), Messages.RentList); 70 | } 71 | 72 | public IResult Update(Rental rental) 73 | { 74 | _rentalDal.Update(rental); 75 | return new SuccessResult(Messages.RentUpdate); 76 | } 77 | private IResult CheckCarReturnDate(Rental rental) 78 | { 79 | var results = _rentalDal.GetAll(r => r.CarId == rental.CarId); 80 | foreach (var result in results) 81 | { 82 | if (result.ReturnDate==null||rental.RentDatecustomerFin.Data) 96 | { 97 | return new ErrorResult(Messages.FindeksFail); 98 | } 99 | return new SuccessResult(Messages.FindeksSuccess); 100 | 101 | } 102 | 103 | 104 | 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /Business/Concrete/CarImageManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Constants; 3 | using Core.Utilities.Business; 4 | using Core.Utilities.FileUploads; 5 | using Core.Utilities.Results; 6 | using DataAccess.Abstract; 7 | using Entities.Concrete; 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Text; 11 | using System.IO; 12 | using System.Linq; 13 | 14 | namespace Business.Concrete 15 | { 16 | public class CarImageManager : ICarImageService 17 | { 18 | private ICarImageDal _carImageDal; 19 | 20 | public CarImageManager(ICarImageDal carImageDal) 21 | { 22 | _carImageDal = carImageDal; 23 | } 24 | 25 | public IResult Add(FileTools file, CarImage carImage) 26 | { 27 | IResult result = BusinessRules.Run(CheckCarIMageAmount(carImage.CarId)); 28 | 29 | if (result != null) 30 | { 31 | return result; 32 | } 33 | 34 | var pathResult = FileHelper.Add(file); 35 | 36 | carImage.ImagePath = pathResult.Message; 37 | 38 | _carImageDal.Add(carImage); 39 | return new SuccessResult(Messages.ImagesAdded); 40 | 41 | 42 | } 43 | 44 | public IResult Delete(CarImage carImage) 45 | { 46 | var result = _carImageDal.Get(c => c.Id == carImage.Id); 47 | FileHelper.Delete(result.ImagePath); 48 | _carImageDal.Delete(carImage); 49 | return new SuccessResult(Messages.Deleted); 50 | 51 | } 52 | public IResult Update(FileTools file, CarImage carImage) 53 | { 54 | var result = _carImageDal.Get(c => c.Id == carImage.Id); 55 | var result1 = FileHelper.Update(file, result.ImagePath); 56 | carImage.ImagePath = result1.Message; 57 | _carImageDal.Update(carImage); 58 | return new SuccessResult(); 59 | } 60 | 61 | 62 | 63 | 64 | public IDataResult> GetAll() 65 | { 66 | return new SuccessDataResult>(_carImageDal.GetAll()); 67 | } 68 | 69 | public IDataResult> GetById(int id) 70 | { 71 | var result = _carImageDal.Get(c => c.Id == id); 72 | if (result.ImagePath == null) 73 | { 74 | List Cimage = new List(); 75 | Cimage.Add(new CarImage { CarId = id, ImagePath = @"\Default.jpg" }); 76 | return new SuccessDataResult>(Cimage); 77 | 78 | } 79 | return new SuccessDataResult>(_carImageDal.GetAll(b => b.Id == id)); 80 | } 81 | public IDataResult> GetByCarId(int id) 82 | { 83 | var result = _carImageDal.GetAll(c => c.CarId == id); 84 | 85 | 86 | if (!result.Any()) 87 | { 88 | 89 | return new SuccessDataResult> 90 | (new List { new CarImage { CarId = id, ImagePath = "Default.jpg" } }); 91 | 92 | } 93 | 94 | return new SuccessDataResult>(result); 95 | } 96 | 97 | 98 | 99 | 100 | 101 | 102 | private IResult CheckCarIMageAmount(int CarId) 103 | { 104 | var result = _carImageDal.GetAll(c => c.CarId == CarId); 105 | 106 | if (result.Count > 5) 107 | { 108 | return new ErrorResult(); 109 | } 110 | 111 | return new SuccessResult(); 112 | 113 | } 114 | 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /WebAPI/Controllers/CarsController.cs: -------------------------------------------------------------------------------- 1 | 2 | using Business.Abstract; 3 | using Entities.Concrete; 4 | using Microsoft.AspNetCore.Http; 5 | using Microsoft.AspNetCore.Mvc; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Threading.Tasks; 10 | 11 | namespace WebAPI.Controllers 12 | { 13 | [Route("api/[controller]")] 14 | [ApiController] 15 | public class CarsController : ControllerBase 16 | { 17 | ICarService _carService; 18 | public CarsController(ICarService carService) 19 | { 20 | _carService = carService; 21 | } 22 | 23 | [HttpPost("add")] 24 | public IActionResult Add(Car car) 25 | { 26 | var result = _carService.Add(car); 27 | if (result.Success) 28 | { 29 | return Ok(result); 30 | } 31 | 32 | return BadRequest(result); 33 | } 34 | [HttpPost("trantest")] 35 | public IActionResult TranTest(Car car) 36 | { 37 | var result = _carService.AddTransactionalTest(car); 38 | if (result.Success) 39 | { 40 | return Ok(result); 41 | } 42 | 43 | return BadRequest(result); 44 | } 45 | [HttpPost("delete")] 46 | public IActionResult Delete(Car car) 47 | { 48 | var result = _carService.Delete(car); 49 | if (result.Success) 50 | { 51 | return Ok(result); 52 | } 53 | return BadRequest(result); 54 | 55 | } 56 | [HttpPost("update")] 57 | public IActionResult Update(Car car) 58 | { 59 | var result = _carService.Update(car); 60 | if (result.Success) 61 | { 62 | return Ok(result); 63 | } 64 | return BadRequest(result); 65 | } 66 | [HttpGet("getall")] 67 | public IActionResult GetAll() 68 | { 69 | var result = _carService.GetAllCars(); 70 | if (result.Success) 71 | { 72 | return Ok(result); 73 | } 74 | return BadRequest(result); 75 | } 76 | [HttpGet("getbyid")] 77 | public IActionResult GetById(int id) 78 | { 79 | var result = _carService.GetByCarId(id); 80 | if (result.Success) 81 | { 82 | return Ok(result); 83 | } 84 | return BadRequest(result); 85 | } 86 | [HttpGet("getdetail")] 87 | public IActionResult GetDetail() 88 | { 89 | var result = _carService.GetCarDetailDtos(); 90 | if (result.Success) 91 | { 92 | return Ok(result); 93 | } 94 | return BadRequest(result); 95 | } 96 | [HttpGet("getdetailbrandid")] 97 | public IActionResult GetbyBrandId(int brandId) 98 | { 99 | var result = _carService.GetByBrandId(brandId); 100 | if (result.Success) 101 | { 102 | return Ok(result); 103 | } 104 | return BadRequest(result); 105 | } 106 | [HttpGet("getdetailcolorid")] 107 | public IActionResult GetbyColorId(int colorId) 108 | { 109 | var result = _carService.GetByColorId(colorId); 110 | if (result.Success) 111 | { 112 | return Ok(result); 113 | } 114 | return BadRequest(result); 115 | } 116 | [HttpGet("getbrandcolorid")] 117 | public IActionResult GetBrandColorId(int? brandId,int? colorId) 118 | { 119 | var result = _carService.GetColorBrandId(brandId, colorId); 120 | if (result.Success) 121 | { 122 | return Ok(result); 123 | } 124 | return BadRequest(result); 125 | } 126 | [HttpGet("getcardtobyid")] 127 | public IActionResult GetCarDtoByCarId(int carId) 128 | { 129 | var result = _carService.GetCarDtoById(carId); 130 | if (result.Success) 131 | { 132 | return Ok(result); 133 | } 134 | return BadRequest(result); 135 | } 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /.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 --------------------------------------------------------------------------------