├── Core ├── Entities │ ├── IDto.cs │ ├── IEntity.cs │ └── Concrete │ │ ├── OperationClaim.cs │ │ ├── UserOperationClaim.cs │ │ └── User.cs ├── Utilities │ ├── Results │ │ ├── IDataResult.cs │ │ ├── IResult.cs │ │ ├── ErrorResult.cs │ │ ├── SuccessResult.cs │ │ ├── Result.cs │ │ ├── DataResult.cs │ │ ├── ErrorDataResult.cs │ │ └── SuccessDataResult.cs │ ├── IoC │ │ ├── ICoreModule.cs │ │ └── ServiceTool.cs │ ├── Security │ │ ├── JWT │ │ │ ├── AccessToken.cs │ │ │ ├── ITokenHelper.cs │ │ │ ├── TokenOptions.cs │ │ │ └── JwtHelper.cs │ │ ├── Encryption │ │ │ ├── SecurityKeyHelper.cs │ │ │ └── SigningCredentialsHelper.cs │ │ └── Hashing │ │ │ └── HashingHelper.cs │ ├── Business │ │ └── BusinessRules.cs │ ├── Interceptors │ │ ├── MethodInterceptionBaseAttribute.cs │ │ ├── AspectInterceptorSelector.cs │ │ └── MethodInterception.cs │ └── Helpers │ │ └── FileHelper.cs ├── CrossCuttingConcerns │ ├── Caching │ │ ├── ICacheManager.cs │ │ └── Microsoft │ │ │ └── MemoryCacheManager.cs │ └── Validation │ │ └── ValidationTool.cs ├── DataAccess │ ├── IEntityRepository.cs │ └── EntityFramework │ │ └── EfEntityRepositoryBase.cs ├── Extensions │ ├── ServiceCollectionExtensions.cs │ ├── ClaimsPrincipalExtensions.cs │ └── ClaimExtensions.cs ├── DependencyResolvers │ └── CoreModule.cs ├── Aspects │ └── Autofac │ │ ├── Caching │ │ ├── CacheRemoveAspect.cs │ │ └── CacheAspect.cs │ │ ├── Transaction │ │ └── TransactionScopeAspect.cs │ │ ├── Performance │ │ └── PerformanceAspect.cs │ │ └── Validation │ │ └── ValidationAspect.cs └── Core.csproj ├── Business ├── CCS │ ├── ILogger.cs │ ├── FileLogger.cs │ └── DatabaseLogger.cs ├── ValidationRules │ └── FluentValidation │ │ ├── BrandValidator.cs │ │ ├── ColorValidator.cs │ │ ├── CarImageValidator.cs │ │ ├── CustomerValidator.cs │ │ ├── UserValidator.cs │ │ ├── RentalValidator.cs │ │ └── CarValidator.cs ├── Abstract │ ├── IBrandService.cs │ ├── IColorService.cs │ ├── IUserService.cs │ ├── ICardService.cs │ ├── IAuthService.cs │ ├── ICustomerService.cs │ ├── ICarImageService.cs │ ├── IRentalService.cs │ └── ICarService.cs ├── Business.csproj ├── BusinessAspects │ └── Autofac │ │ └── SecuredOperation.cs ├── Concrete │ ├── ColorManager.cs │ ├── BrandManager.cs │ ├── UserManager.cs │ ├── CardManager.cs │ ├── CustomerManager.cs │ ├── RentalManager.cs │ ├── AuthManager.cs │ ├── CarImageManager.cs │ └── CarManager.cs ├── DependencyResolvers │ └── Autofac │ │ └── AutofacBusinessModule.cs └── Constants │ └── Messages.cs ├── WebAPI ├── wwwroot │ └── CarImages │ │ ├── 0408a2b7-6630-4556-8546-73d83ef87b6f.jpg │ │ ├── 0a935e22-eeff-4cc6-909e-66999843582e.jpg │ │ ├── 0a97de10-c78d-45f2-8dc4-aa248cbad701.jpg │ │ ├── 14dd7ade-9ffe-41c9-8268-22c7280cfd66.jpg │ │ ├── 2b869629-7aff-486b-adc1-f319daa3e78d.jpg │ │ ├── 2ba4b91e-4018-4a0c-949c-723fd310f5dd.jpg │ │ ├── 3764d6c5-be84-47f2-92a2-163770d5a5c5.jpg │ │ ├── 39a331f7-a2c0-44d6-9f27-c9dc7a025eb9.jpg │ │ ├── 3c949a35-31d2-4ef0-984b-dca631c308d7.jpg │ │ ├── 4771b166-843b-436d-93ba-6335198d5879.jpg │ │ ├── 4ecdcc00-0916-424e-8be8-b01dfccfa04a.jpg │ │ ├── 5851eee2-4a15-4a07-a4a1-1b2e0e07d15f.jpg │ │ ├── 5a709075-ee49-4d4b-b885-1090c1d09081.jpg │ │ ├── 5c31d5c1-f59f-413d-b4ac-f1456cbc1d35.jpg │ │ ├── 769119c8-3a92-4ea5-937f-7b6ba1a0ed95.jpg │ │ ├── 7dd06f97-4a7e-4e1c-8ca8-c95aa7f2339d.jpg │ │ ├── 82d7563a-04db-4e9b-b404-2e56cbf40e32.jpg │ │ ├── 8bce141a-05f8-4895-bcf4-83121f728118.jpg │ │ ├── 967906d0-cb92-450f-addb-24ab01e951a1.jpg │ │ ├── 9d00ea0c-6cd9-4415-8f18-6f9110802544.jpg │ │ ├── a8ccdb30-7ffa-4728-aaea-78c78f180e7b.jpg │ │ ├── a9b59d06-2c36-4f70-b97c-0bba4336a159.jpg │ │ ├── b28f4764-4650-4391-a752-23fe8412ee80.jpg │ │ ├── b5cf6d06-a481-4a0d-bbeb-68712163e85f.jpg │ │ ├── c2d9e499-323c-4bba-a853-f438fcf1c6ad.jpg │ │ ├── c498796d-f3b2-4de0-8d01-5b5ce98dfd2d.jpg │ │ ├── cc00a8a6-080f-4720-857f-4bb6f00f176a.jpg │ │ ├── d20a0a71-d001-476f-97d6-3710b4919d22.jpg │ │ └── ea9cc760-4830-46f9-96da-f8f530ac61bb.jpg ├── appsettings.Development.json ├── WeatherForecast.cs ├── appsettings.json ├── WebAPI.csproj ├── Properties │ └── launchSettings.json ├── Program.cs ├── Controllers │ ├── WeatherForecastController.cs │ ├── AuthController.cs │ ├── UsersController.cs │ ├── ColorsController.cs │ ├── BrandsController.cs │ ├── CustomersController.cs │ ├── CarImagesController.cs │ ├── CardsController.cs │ ├── RentalsController.cs │ └── CarsController.cs └── Startup.cs ├── DataAccess ├── Abstract │ ├── IBrandDal.cs │ ├── ICardDal.cs │ ├── IColorDal.cs │ ├── ICarImageDal.cs │ ├── IUserDal.cs │ ├── ICarDal.cs │ ├── IRentalDal.cs │ └── ICustomerDal.cs ├── Concrete │ ├── EntityFramework │ │ ├── EfCardDal.cs │ │ ├── EFColorDal.cs │ │ ├── EfBrandDal.cs │ │ ├── EfCarImageDal.cs │ │ ├── EfUserDal.cs │ │ ├── MyDatabaseContext.cs │ │ ├── EfCustomerDal.cs │ │ ├── EfCarDal.cs │ │ └── EfRentalDal.cs │ └── InMemory │ │ └── InMemoryCarDal.cs └── DataAccess.csproj ├── Entities ├── Concrete │ ├── Brand.cs │ ├── Color.cs │ ├── Customer.cs │ ├── CarImage.cs │ ├── Rental.cs │ ├── Card.cs │ └── Car.cs ├── DTOs │ ├── UserForLoginDto.cs │ ├── UserForRegisterDto.cs │ ├── CustomerDetailDto.cs │ ├── RentalDetailDto.cs │ └── CarDetailDto.cs └── Entities.csproj ├── Untitled Diagram.drawio ├── ConsoleUI ├── ConsoleUI.csproj └── Program.cs ├── .gitattributes ├── RentACarProject.sln └── .gitignore /Core/Entities/IDto.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Entities 2 | { 3 | public interface IDto 4 | { 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /Core/Entities/IEntity.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Entities 2 | { 3 | public interface IEntity 4 | { 5 | 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Business/CCS/ILogger.cs: -------------------------------------------------------------------------------- 1 | namespace Business.CCS 2 | { 3 | public interface ILogger 4 | { 5 | void Log(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Core/Utilities/Results/IDataResult.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Utilities.Results 2 | { 3 | public interface IDataResult : IResult 4 | { 5 | T Data { get; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/0408a2b7-6630-4556-8546-73d83ef87b6f.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/0408a2b7-6630-4556-8546-73d83ef87b6f.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/0a935e22-eeff-4cc6-909e-66999843582e.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/0a935e22-eeff-4cc6-909e-66999843582e.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/0a97de10-c78d-45f2-8dc4-aa248cbad701.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/0a97de10-c78d-45f2-8dc4-aa248cbad701.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/14dd7ade-9ffe-41c9-8268-22c7280cfd66.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/14dd7ade-9ffe-41c9-8268-22c7280cfd66.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/2b869629-7aff-486b-adc1-f319daa3e78d.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/2b869629-7aff-486b-adc1-f319daa3e78d.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/2ba4b91e-4018-4a0c-949c-723fd310f5dd.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/2ba4b91e-4018-4a0c-949c-723fd310f5dd.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/3764d6c5-be84-47f2-92a2-163770d5a5c5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/3764d6c5-be84-47f2-92a2-163770d5a5c5.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/39a331f7-a2c0-44d6-9f27-c9dc7a025eb9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/39a331f7-a2c0-44d6-9f27-c9dc7a025eb9.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/3c949a35-31d2-4ef0-984b-dca631c308d7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/3c949a35-31d2-4ef0-984b-dca631c308d7.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/4771b166-843b-436d-93ba-6335198d5879.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/4771b166-843b-436d-93ba-6335198d5879.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/4ecdcc00-0916-424e-8be8-b01dfccfa04a.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/4ecdcc00-0916-424e-8be8-b01dfccfa04a.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/5851eee2-4a15-4a07-a4a1-1b2e0e07d15f.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/5851eee2-4a15-4a07-a4a1-1b2e0e07d15f.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/5a709075-ee49-4d4b-b885-1090c1d09081.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/5a709075-ee49-4d4b-b885-1090c1d09081.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/5c31d5c1-f59f-413d-b4ac-f1456cbc1d35.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/5c31d5c1-f59f-413d-b4ac-f1456cbc1d35.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/769119c8-3a92-4ea5-937f-7b6ba1a0ed95.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/769119c8-3a92-4ea5-937f-7b6ba1a0ed95.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/7dd06f97-4a7e-4e1c-8ca8-c95aa7f2339d.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/7dd06f97-4a7e-4e1c-8ca8-c95aa7f2339d.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/82d7563a-04db-4e9b-b404-2e56cbf40e32.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/82d7563a-04db-4e9b-b404-2e56cbf40e32.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/8bce141a-05f8-4895-bcf4-83121f728118.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/8bce141a-05f8-4895-bcf4-83121f728118.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/967906d0-cb92-450f-addb-24ab01e951a1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/967906d0-cb92-450f-addb-24ab01e951a1.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/9d00ea0c-6cd9-4415-8f18-6f9110802544.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/9d00ea0c-6cd9-4415-8f18-6f9110802544.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/a8ccdb30-7ffa-4728-aaea-78c78f180e7b.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/a8ccdb30-7ffa-4728-aaea-78c78f180e7b.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/a9b59d06-2c36-4f70-b97c-0bba4336a159.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/a9b59d06-2c36-4f70-b97c-0bba4336a159.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/b28f4764-4650-4391-a752-23fe8412ee80.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/b28f4764-4650-4391-a752-23fe8412ee80.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/b5cf6d06-a481-4a0d-bbeb-68712163e85f.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/b5cf6d06-a481-4a0d-bbeb-68712163e85f.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/c2d9e499-323c-4bba-a853-f438fcf1c6ad.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/c2d9e499-323c-4bba-a853-f438fcf1c6ad.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/c498796d-f3b2-4de0-8d01-5b5ce98dfd2d.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/c498796d-f3b2-4de0-8d01-5b5ce98dfd2d.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/cc00a8a6-080f-4720-857f-4bb6f00f176a.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/cc00a8a6-080f-4720-857f-4bb6f00f176a.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/d20a0a71-d001-476f-97d6-3710b4919d22.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/d20a0a71-d001-476f-97d6-3710b4919d22.jpg -------------------------------------------------------------------------------- /WebAPI/wwwroot/CarImages/ea9cc760-4830-46f9-96da-f8f530ac61bb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muazmemis/RentACar-BackEnd-CSharp/HEAD/WebAPI/wwwroot/CarImages/ea9cc760-4830-46f9-96da-f8f530ac61bb.jpg -------------------------------------------------------------------------------- /Core/Utilities/Results/IResult.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Utilities.Results 2 | { 3 | public interface IResult 4 | { 5 | bool Success { get; } 6 | string Message { get; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /DataAccess/Abstract/IBrandDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Entities.Concrete; 3 | 4 | namespace DataAccess.Abstract 5 | { 6 | public interface IBrandDal : IEntityRepository 7 | { 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 | -------------------------------------------------------------------------------- /DataAccess/Abstract/IColorDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Entities.Concrete; 3 | 4 | namespace DataAccess.Abstract 5 | { 6 | public interface IColorDal : IEntityRepository 7 | { 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Core/Entities/Concrete/OperationClaim.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Entities.Concrete 2 | { 3 | public class OperationClaim : IEntity 4 | { 5 | public int Id { get; set; } 6 | public string Name { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /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/ICarImageDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Entities.Concrete; 3 | 4 | namespace DataAccess.Abstract 5 | { 6 | public interface ICarImageDal:IEntityRepository 7 | { 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Entities/Concrete/Brand.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | 3 | namespace Entities.Concrete 4 | { 5 | public class Brand : IEntity 6 | { 7 | public int BrandId { get; set; } 8 | public string BrandName { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Entities/Concrete/Color.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | 3 | namespace Entities.Concrete 4 | { 5 | public class Color : IEntity 6 | { 7 | public int ColorId { get; set; } 8 | public string ColorName { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Core/Utilities/IoC/ICoreModule.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | 3 | namespace Core.Utilities.IoC 4 | { 5 | public interface ICoreModule 6 | { 7 | void Load(IServiceCollection serviceCollections); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Entities/DTOs/UserForLoginDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | 3 | namespace Entities.DTOs 4 | { 5 | public class UserForLoginDto : IDto 6 | { 7 | public string Email { get; set; } 8 | public string Password { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /Business/CCS/FileLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Business.CCS 4 | { 5 | public class FileLogger : ILogger 6 | { 7 | public void Log() 8 | { 9 | Console.WriteLine("Dosyaya loglandı."); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Core/Utilities/Security/JWT/AccessToken.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Core.Utilities.Security.JWT 4 | { 5 | public class AccessToken 6 | { 7 | public string Token { get; set; } 8 | public DateTime Expiration { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Business/CCS/DatabaseLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Business.CCS 4 | { 5 | public class DatabaseLogger : ILogger 6 | { 7 | public void Log() 8 | { 9 | Console.WriteLine("Veritabanına loglandı."); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Entities/Concrete/Customer.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | 3 | namespace Entities.Concrete 4 | { 5 | public class Customer : IEntity 6 | { 7 | public int Id { get; set; } 8 | public int UserId { get; set; } 9 | public string CompanyName { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /Core/Entities/Concrete/UserOperationClaim.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Entities.Concrete 2 | { 3 | public class UserOperationClaim : IEntity 4 | { 5 | public int Id { get; set; } 6 | public int UserId { get; set; } 7 | public int OperationClaimId { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /DataAccess/Abstract/IUserDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Core.Entities.Concrete; 3 | using System.Collections.Generic; 4 | 5 | namespace DataAccess.Abstract 6 | { 7 | public interface IUserDal : IEntityRepository 8 | { 9 | List GetClaims(User user); 10 | } 11 | } -------------------------------------------------------------------------------- /Core/Utilities/Security/JWT/ITokenHelper.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Concrete; 2 | using System.Collections.Generic; 3 | 4 | namespace Core.Utilities.Security.JWT 5 | { 6 | public interface ITokenHelper 7 | { 8 | AccessToken CreateToken(User user, List operationClaims); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /Core/Utilities/Results/ErrorResult.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Utilities.Results 2 | { 3 | public class ErrorResult:Result 4 | { 5 | public ErrorResult(string message) : base(false, message) 6 | { 7 | 8 | } 9 | 10 | public ErrorResult() : base(false) 11 | { 12 | 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EFColorDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using DataAccess.Abstract; 3 | using Entities.Concrete; 4 | 5 | namespace DataAccess.Concrete.EntityFramework 6 | { 7 | public class EfColorDal : EfEntityRepositoryBase, IColorDal 8 | { 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfBrandDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using DataAccess.Abstract; 3 | using Entities.Concrete; 4 | 5 | namespace DataAccess.Concrete.EntityFramework 6 | { 7 | public class EfBrandDal : EfEntityRepositoryBase, IBrandDal 8 | { 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Core/Utilities/Results/SuccessResult.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Utilities.Results 2 | { 3 | public class SuccessResult:Result 4 | { 5 | public SuccessResult(string message) : base(true, message) 6 | { 7 | 8 | } 9 | 10 | public SuccessResult() : base(true) 11 | { 12 | 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfCarImageDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using DataAccess.Abstract; 3 | using Entities.Concrete; 4 | 5 | namespace DataAccess.Concrete.EntityFramework 6 | { 7 | public class EfCarImageDal:EfEntityRepositoryBase, ICarImageDal 8 | { 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Core/Utilities/Security/JWT/TokenOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Utilities.Security.JWT 2 | { 3 | public class TokenOptions 4 | { 5 | public string Audience { get; set; } 6 | public string Issuer { get; set; } 7 | public int AccessTokenExpiration { get; set; } 8 | public string SecurityKey { get; set; } 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 | } -------------------------------------------------------------------------------- /Entities/Concrete/CarImage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Core.Entities; 3 | 4 | namespace Entities.Concrete 5 | { 6 | public class CarImage : IEntity 7 | { 8 | public int Id { get; set; } 9 | public int CarId { get; set; } 10 | public string ImagePath { get; set; } 11 | public DateTime CreationTime { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Entities/Entities.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /WebAPI/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace WebAPI 4 | { 5 | public class WeatherForecast 6 | { 7 | public DateTime Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | 13 | public string Summary { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/BrandValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.Concrete; 2 | using FluentValidation; 3 | 4 | namespace Business.ValidationRules.FluentValidation 5 | { 6 | public class BrandValidator : AbstractValidator 7 | { 8 | public BrandValidator() 9 | { 10 | RuleFor(b => b.BrandName).NotEmpty(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/ColorValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.Concrete; 2 | using FluentValidation; 3 | 4 | namespace Business.ValidationRules.FluentValidation 5 | { 6 | public class ColorValidator : AbstractValidator 7 | { 8 | public ColorValidator() 9 | { 10 | RuleFor(c => c.ColorName).NotEmpty(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Entities/Concrete/Rental.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Core.Entities; 3 | 4 | namespace Entities.Concrete 5 | { 6 | public class Rental : IEntity 7 | { 8 | public int Id { get; set; } 9 | public int CarId { get; set; } 10 | public int CustomerId { get; set; } 11 | public DateTime RentDate { get; set; } 12 | public DateTime? ReturnDate { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /Untitled Diagram.drawio: -------------------------------------------------------------------------------- 1 | UzV2zq1wL0osyPDNT0nNUTV2VTV2LsrPL4GwciucU3NyVI0MMlNUjV1UjYwMgFjVyA2HrCFY1qAgsSg1rwSLBiADYTaQg2Y1AA== -------------------------------------------------------------------------------- /Core/CrossCuttingConcerns/Caching/ICacheManager.cs: -------------------------------------------------------------------------------- 1 | namespace Core.CrossCuttingConcerns.Caching 2 | { 3 | interface ICacheManager 4 | { 5 | T Get(string key); 6 | object Get(string key); 7 | void Add(string key, object value, int duration); 8 | bool IsAdd(string key); 9 | void Remove(string key); 10 | void RemoveByPattern(string pattern); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /DataAccess/Abstract/ICarDal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq.Expressions; 4 | using Core.DataAccess; 5 | using Entities.Concrete; 6 | using Entities.DTOs; 7 | 8 | namespace DataAccess.Abstract 9 | { 10 | public interface ICarDal : IEntityRepository 11 | { 12 | List GetCarDetails(Expression> filter = null); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Core/Utilities/Security/Encryption/SecurityKeyHelper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.IdentityModel.Tokens; 2 | using System.Text; 3 | 4 | namespace Core.Utilities.Security.Encryption 5 | { 6 | public class SecurityKeyHelper 7 | { 8 | public static SecurityKey CreateSecurityKey(string securityKey) 9 | { 10 | return new SymmetricSecurityKey(Encoding.UTF8.GetBytes(securityKey)); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /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 | 8 | namespace DataAccess.Abstract 9 | { 10 | public interface IRentalDal : IEntityRepository 11 | { 12 | List GetRentalDetails(Expression> filter = null); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Entities/Concrete/Card.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | 3 | namespace Entities.Concrete 4 | { 5 | public class Card : IEntity 6 | { 7 | public int Id { get; set; } 8 | public string CardName { get; set; } 9 | public string CardNumber { get; set; } 10 | public string ExpirationDate { get; set; } 11 | public int CardCvv { get; set; } 12 | public decimal CardMoney { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Entities/DTOs/CustomerDetailDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | 3 | namespace Entities.DTOs 4 | { 5 | public class CustomerDetailDto : IDto 6 | { 7 | public int Id { get; set; } 8 | public int UserId { get; set; } 9 | public string CompanyName { get; set; } 10 | public string FirstName { get; set; } 11 | public string LastName { get; set; } 12 | public string Email { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /WebAPI/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "TokenOptions": { 3 | "Audience": "muaz@muaz.com", 4 | "Issuer": "muaz@muaz.com", 5 | "AccessTokenExpiration": 10, 6 | "SecurityKey": "mysupersecretkeymysupersecretkey" 7 | }, 8 | "Logging": { 9 | "LogLevel": { 10 | "Default": "Information", 11 | "Microsoft": "Warning", 12 | "Microsoft.Hosting.Lifetime": "Information" 13 | } 14 | }, 15 | "AllowedHosts": "*" 16 | } 17 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/CarImageValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.Concrete; 2 | using FluentValidation; 3 | 4 | namespace Business.ValidationRules.FluentValidation 5 | { 6 | public class CarImageValidator:AbstractValidator 7 | { 8 | public CarImageValidator() 9 | { 10 | RuleFor(c => c.CarId).NotEmpty(); 11 | RuleFor(c => c.CarId).GreaterThan(0); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Core/Utilities/Security/Encryption/SigningCredentialsHelper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.IdentityModel.Tokens; 2 | 3 | namespace Core.Utilities.Security.Encryption 4 | { 5 | class SigningCredentialsHelper 6 | { 7 | public static SigningCredentials CreateSigningCredentials(SecurityKey securityKey) 8 | { 9 | return new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha512Signature); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /DataAccess/Abstract/ICustomerDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess; 2 | using Entities.Concrete; 3 | using Entities.DTOs; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq.Expressions; 7 | 8 | namespace DataAccess.Abstract 9 | { 10 | public interface ICustomerDal : IEntityRepository 11 | { 12 | List GetCustomerDetails(Expression> filter = null); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/CustomerValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.Concrete; 2 | using FluentValidation; 3 | 4 | namespace Business.ValidationRules.FluentValidation 5 | { 6 | public class CustomerValidator : AbstractValidator 7 | { 8 | public CustomerValidator() 9 | { 10 | RuleFor(c => c.CompanyName).NotEmpty(); 11 | RuleFor(c => c.UserId).NotEmpty(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Business/Abstract/IBrandService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Core.Utilities.Results; 3 | using Entities.Concrete; 4 | 5 | namespace Business.Abstract 6 | { 7 | public interface IBrandService 8 | { 9 | IDataResult> GetAll(); 10 | IDataResult GetById(int brandId); 11 | IResult Add(Brand brand); 12 | IResult Update(Brand brand); 13 | IResult Delete(Brand brand); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Business/Abstract/IColorService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Core.Utilities.Results; 3 | using Entities.Concrete; 4 | 5 | namespace Business.Abstract 6 | { 7 | public interface IColorService 8 | { 9 | IDataResult> GetAll(); 10 | IDataResult GetById(int colorId); 11 | IResult Add(Color color); 12 | IResult Update(Color color); 13 | IResult Delete(Color color); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Core/Utilities/Results/Result.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Utilities.Results 2 | { 3 | public class Result : IResult 4 | { 5 | public Result(bool success, string message):this(success) 6 | { 7 | Message = message; 8 | } 9 | public Result(bool success) 10 | { 11 | Success = success; 12 | } 13 | 14 | public bool Success { get; } 15 | public string Message { get; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Core/Entities/Concrete/User.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Entities.Concrete 2 | { 3 | public class User : IEntity 4 | { 5 | public int Id { get; set; } 6 | public string FirstName { get; set; } 7 | public string LastName { get; set; } 8 | public string Email { get; set; } 9 | public byte[] PasswordSalt { get; set; } 10 | public byte[] PasswordHash { get; set; } 11 | public bool Status { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ConsoleUI/ConsoleUI.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Core/Utilities/Results/DataResult.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Utilities.Results 2 | { 3 | public class DataResult : Result, IDataResult 4 | { 5 | public DataResult(T data, bool success, string message) : base(success, message) 6 | { 7 | Data = data; 8 | } 9 | 10 | public DataResult(T data, bool success) : base(success) 11 | { 12 | Data = data; 13 | } 14 | 15 | public T Data { get; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Entities/Concrete/Car.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | 3 | namespace Entities.Concrete 4 | { 5 | public class Car : IEntity 6 | { 7 | public int CarId { get; set; } 8 | public int BrandId { get; set; } 9 | public int ColorId { get; set; } 10 | public string CarName { get; set; } 11 | public int ModelYear { get; set; } 12 | public decimal DailyPrice { get; set; } 13 | public string Description { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /DataAccess/DataAccess.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Core/Utilities/IoC/ServiceTool.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using System; 3 | 4 | namespace Core.Utilities.IoC 5 | { 6 | public static class ServiceTool 7 | { 8 | public static IServiceProvider ServiceProvider { get; private set; } 9 | 10 | public static IServiceCollection Create(IServiceCollection services) 11 | { 12 | ServiceProvider = services.BuildServiceProvider(); 13 | return services; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Core/Utilities/Business/BusinessRules.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results; 2 | 3 | namespace Core.Utilities.Business 4 | { 5 | public class BusinessRules 6 | { 7 | public static IResult Run(params IResult[] logics) 8 | { 9 | foreach (var logic in logics) 10 | { 11 | if (!logic.Success) 12 | { 13 | return logic; 14 | } 15 | } 16 | 17 | return null; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Core/Utilities/Interceptors/MethodInterceptionBaseAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Castle.DynamicProxy; 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/Abstract/IUserService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Core.Entities.Concrete; 3 | using Core.Utilities.Results; 4 | 5 | namespace Business.Abstract 6 | { 7 | public interface IUserService 8 | { 9 | IResult Add(User user); 10 | IResult Update(User user); 11 | IResult Delete(User user); 12 | IDataResult> GetAll(); 13 | IDataResult GetById(int userId); 14 | List GetClaims(User user); 15 | User GetByMail(string email); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /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 | IDataResult> GetByCardNumber(string cardNumber); 10 | IDataResult> GetAll(); 11 | IDataResult GetById(int carId); 12 | IResult IsCardExist(Card card); 13 | IResult Add(Card card); 14 | IResult Update(Card card); 15 | IResult Delete(Card card); 16 | } 17 | } -------------------------------------------------------------------------------- /Core/DataAccess/IEntityRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq.Expressions; 4 | using Core.Entities; 5 | 6 | namespace Core.DataAccess 7 | { 8 | public interface IEntityRepository where T : class, IEntity, new() 9 | { 10 | void Add(T entity); 11 | void Update(T entity); 12 | void Delete(T entity); 13 | List GetAll(Expression> filter = null); //Expression kullanabilmek için. 14 | T Get(Expression> filter); 15 | T GetById(int Id); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /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.Text; 7 | 8 | namespace Business.Abstract 9 | { 10 | public interface IAuthService 11 | { 12 | IDataResult Register(UserForRegisterDto userForRegisterDto, string password); 13 | IDataResult Login(UserForLoginDto userForLoginDto); 14 | IResult UserExists(string email); 15 | IDataResult CreateAccessToken(User user); 16 | } 17 | } -------------------------------------------------------------------------------- /Core/CrossCuttingConcerns/Validation/ValidationTool.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Core.CrossCuttingConcerns.Validation 4 | { 5 | public static class ValidationTool 6 | { 7 | public static void Validate(IValidator validator, object entity) 8 | { 9 | var context = new ValidationContext(entity); 10 | var result = validator.Validate(context); 11 | 12 | if(!result.IsValid) 13 | { 14 | throw new ValidationException(result.Errors); 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Business/Abstract/ICustomerService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Core.Utilities.Results; 3 | using Entities.Concrete; 4 | using Entities.DTOs; 5 | 6 | namespace Business.Abstract 7 | { 8 | public interface ICustomerService 9 | { 10 | IResult Add(Customer customer); 11 | IResult Update(Customer customer); 12 | IResult Delete(Customer customer); 13 | IDataResult> GetAll(); 14 | IDataResult GetById(int customerId); 15 | IDataResult> GetCustomerDetails(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Core/Utilities/Results/ErrorDataResult.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Utilities.Results 2 | { 3 | public class ErrorDataResult : DataResult 4 | { 5 | public ErrorDataResult(T data, string message) : base(data, false, message) 6 | { 7 | 8 | } 9 | 10 | public ErrorDataResult(T data) : base(data, false) 11 | { 12 | 13 | } 14 | 15 | public ErrorDataResult(string message) : base(default, false, message) 16 | { 17 | 18 | } 19 | 20 | public ErrorDataResult() : base(default, false) 21 | { 22 | 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Business/Abstract/ICarImageService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Core.Utilities.Results; 3 | using Entities.Concrete; 4 | using Microsoft.AspNetCore.Http; 5 | 6 | namespace Business.Abstract 7 | { 8 | public interface ICarImageService 9 | { 10 | IResult Add(IFormFile file, CarImage carImage); 11 | IResult Update(IFormFile file, CarImage carImage); 12 | IResult Delete(CarImage carImage); 13 | IDataResult> GetAll(); 14 | IDataResult GetById(int carImageId); 15 | IDataResult> GetByCarId(int carId); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Core/Extensions/ServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.IoC; 2 | using Microsoft.Extensions.DependencyInjection; 3 | 4 | namespace Core.Extensions 5 | { 6 | public static class ServiceCollectionExtensions 7 | { 8 | public static IServiceCollection AddDependencyResolvers(this IServiceCollection serviceCollection, 9 | ICoreModule[] modules) 10 | { 11 | foreach (var module in modules) 12 | { 13 | module.Load(serviceCollection); 14 | } 15 | 16 | return ServiceTool.Create(serviceCollection); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Core/Utilities/Results/SuccessDataResult.cs: -------------------------------------------------------------------------------- 1 | namespace Core.Utilities.Results 2 | { 3 | public class SuccessDataResult:DataResult 4 | { 5 | public SuccessDataResult(T data, string message) : base(data, true, message) 6 | { 7 | 8 | } 9 | 10 | public SuccessDataResult(T data) : base(data, true) 11 | { 12 | 13 | } 14 | 15 | public SuccessDataResult(string message):base(default,true,message) 16 | { 17 | 18 | } 19 | 20 | public SuccessDataResult():base(default,true) 21 | { 22 | 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/UserValidator.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities.Concrete; 2 | using FluentValidation; 3 | 4 | namespace Business.ValidationRules.FluentValidation 5 | { 6 | public class UserValidator : AbstractValidator 7 | { 8 | public UserValidator() 9 | { 10 | RuleFor(u => u.FirstName).NotEmpty(); 11 | RuleFor(u => u.LastName).NotEmpty(); 12 | //RuleFor(u => u.Password).NotEmpty(); 13 | //RuleFor(u => u.Password).MinimumLength(8); 14 | RuleFor(u => u.Email).NotEmpty(); 15 | RuleFor(u => u.Email).EmailAddress(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Core/Extensions/ClaimsPrincipalExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Security.Claims; 4 | 5 | namespace Core.Extensions 6 | { 7 | public static class ClaimsPrincipalExtensions 8 | { 9 | public static List Claims(this ClaimsPrincipal claimsPrincipal, string claimType) 10 | { 11 | var result = claimsPrincipal?.FindAll(claimType)?.Select(x => x.Value).ToList(); 12 | return result; 13 | } 14 | 15 | public static List ClaimRoles(this ClaimsPrincipal claimsPrincipal) 16 | { 17 | return claimsPrincipal?.Claims(ClaimTypes.Role); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Entities/DTOs/RentalDetailDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using System; 3 | 4 | namespace Entities.DTOs 5 | { 6 | public class RentalDetailDto : IDto 7 | { 8 | public int Id { get; set; } 9 | public int CarId { get; set; } 10 | public int CustomerId { get; set; } 11 | public string CarName { get; set; } 12 | public string CompanyName { get; set; } 13 | public string CustomerName { get; set; } 14 | public string BrandName { get; set; } 15 | public string ColorName { get; set; } 16 | public DateTime RentDate { get; set; } 17 | public DateTime? ReturnDate { get; set; } 18 | public decimal DailyPrice { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Business/Abstract/IRentalService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Core.Utilities.Results; 3 | using Entities.Concrete; 4 | using Entities.DTOs; 5 | 6 | namespace Business.Abstract 7 | { 8 | public interface IRentalService 9 | { 10 | IResult Add(Rental rental); 11 | IResult Update(Rental rental); 12 | IResult Delete(Rental rental); 13 | IDataResult> GetAll(); 14 | IDataResult GetById(int rentalId); 15 | IDataResult> GetRentalDetails(); 16 | IDataResult> GetRentalDetailsByCarId(int carId); 17 | IDataResult> GetRentalDetailsByCustomerId(int customerId); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Entities/DTOs/CarDetailDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Entities; 2 | using Entities.Concrete; 3 | using System.Collections.Generic; 4 | 5 | namespace Entities.DTOs 6 | { 7 | public class CarDetailDto : IDto 8 | { 9 | public int CarId { get; set; } 10 | public int BrandId { get; set; } 11 | public int ColorId { get; set; } 12 | public int CarImageId { get; set; } 13 | public string CarName { get; set; } 14 | public string BrandName { get; set; } 15 | public string ColorName { get; set; } 16 | public List CarImage { get; set; } 17 | public int ModelYear { get; set; } 18 | public decimal DailyPrice { get; set; } 19 | public string Description { get; set; } 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.Diagnostics; 7 | 8 | namespace Core.DependencyResolvers 9 | { 10 | public class CoreModule : ICoreModule 11 | { 12 | public void Load(IServiceCollection serviceCollections) 13 | { 14 | serviceCollections.AddMemoryCache(); 15 | serviceCollections.AddSingleton(); 16 | serviceCollections.AddSingleton(); 17 | serviceCollections.AddSingleton(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/RentalValidator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Entities.Concrete; 3 | using FluentValidation; 4 | 5 | namespace Business.ValidationRules.FluentValidation 6 | { 7 | public class RentalValidator : AbstractValidator 8 | { 9 | public RentalValidator() 10 | { 11 | RuleFor(r => r.CarId).NotEmpty(); 12 | RuleFor(r => r.CustomerId).NotEmpty(); 13 | RuleFor(r => r.RentDate).NotEmpty(); 14 | RuleFor(r => r.ReturnDate).NotEmpty(); 15 | RuleFor(r => r.RentDate).NotEmpty().GreaterThan(DateTime.Now).WithMessage("Geçmiş tarihte kiralama yapılamaz."); 16 | RuleFor(r => r.ReturnDate).GreaterThanOrEqualTo(r => r.RentDate).WithMessage("Aracın teslim tarihi kiralama tarihinden önce olamaz."); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Core/Aspects/Autofac/Caching/CacheRemoveAspect.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using Core.CrossCuttingConcerns.Caching; 3 | using Core.Utilities.Interceptors; 4 | using Core.Utilities.IoC; 5 | using Microsoft.Extensions.DependencyInjection; 6 | 7 | namespace Core.Aspects.Autofac.Caching 8 | { 9 | public class CacheRemoveAspect : MethodInterception 10 | { 11 | private readonly string _pattern; 12 | private readonly ICacheManager _cacheManager; 13 | 14 | public CacheRemoveAspect(string pattern) 15 | { 16 | _pattern = pattern; 17 | _cacheManager = ServiceTool.ServiceProvider.GetService(); 18 | } 19 | 20 | protected override void OnSuccess(IInvocation invocation) 21 | { 22 | _cacheManager.RemoveByPattern(_pattern); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Core/Utilities/Interceptors/AspectInterceptorSelector.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Reflection; 4 | using Castle.DynamicProxy; 5 | 6 | namespace Core.Utilities.Interceptors 7 | { 8 | public class AspectInterceptorSelector : IInterceptorSelector 9 | { 10 | public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors) 11 | { 12 | var classAttributes = type.GetCustomAttributes 13 | (true).ToList(); 14 | var methodAttributes = type.GetMethod(method.Name) 15 | .GetCustomAttributes(true); 16 | classAttributes.AddRange(methodAttributes); 17 | 18 | return classAttributes.OrderBy(x => x.Priority).ToArray(); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Core/Aspects/Autofac/Transaction/TransactionScopeAspect.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using Core.Utilities.Interceptors; 3 | using System; 4 | using System.Transactions; 5 | 6 | namespace Core.Aspects.Autofac.Transaction 7 | { 8 | public class TransactionScopeAspect : MethodInterception 9 | { 10 | public override void Intercept(IInvocation invocation) 11 | { 12 | using (TransactionScope transactionScope = new TransactionScope()) 13 | { 14 | try 15 | { 16 | invocation.Proceed(); 17 | transactionScope.Complete(); 18 | } 19 | catch (Exception e) 20 | { 21 | transactionScope.Dispose(); 22 | throw; 23 | } 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Business/ValidationRules/FluentValidation/CarValidator.cs: -------------------------------------------------------------------------------- 1 | using Entities.Concrete; 2 | using FluentValidation; 3 | 4 | namespace Business.ValidationRules.FluentValidation 5 | { 6 | public class CarValidator : AbstractValidator 7 | { 8 | public CarValidator() 9 | { 10 | RuleFor(c => c.CarName).NotEmpty(); 11 | RuleFor(c => c.CarName).MinimumLength(2); 12 | RuleFor(c => c.DailyPrice).NotEmpty(); 13 | RuleFor(c => c.DailyPrice).GreaterThan(0); 14 | RuleFor(c => c.DailyPrice).GreaterThanOrEqualTo(10).When(c => c.BrandId == 1); 15 | RuleFor(c => c.CarName).Must(StartWithA).WithMessage("Ürünler A harfi ile başlamalı."); 16 | } 17 | 18 | private bool StartWithA(string arg) 19 | { 20 | return arg.StartsWith("A"); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /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:52886", 8 | "sslPort": 44335 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "weatherforecast", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "WebAPI": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "weatherforecast", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /WebAPI/Program.cs: -------------------------------------------------------------------------------- 1 | using Autofac; 2 | using Autofac.Extensions.DependencyInjection; 3 | using Business.DependencyResolvers.Autofac; 4 | using Microsoft.AspNetCore.Hosting; 5 | using Microsoft.Extensions.Hosting; 6 | 7 | namespace WebAPI 8 | { 9 | public class Program 10 | { 11 | public static void Main(string[] args) 12 | { 13 | CreateHostBuilder(args).Build().Run(); 14 | } 15 | 16 | public static IHostBuilder CreateHostBuilder(string[] args) => 17 | Host.CreateDefaultBuilder(args) 18 | .UseServiceProviderFactory(new AutofacServiceProviderFactory()) 19 | .ConfigureContainer(builder => 20 | { 21 | builder.RegisterModule(new AutofacBusinessModule()); 22 | }) 23 | .ConfigureWebHostDefaults(webBuilder => 24 | { 25 | webBuilder.UseStartup(); 26 | }); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /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 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Core/Extensions/ClaimExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.IdentityModel.Tokens.Jwt; 3 | using System.Linq; 4 | using System.Security.Claims; 5 | 6 | namespace Core.Extensions 7 | { 8 | public static class ClaimExtensions 9 | { 10 | public static void AddEmail(this ICollection claims, string email) 11 | { 12 | claims.Add(new Claim(JwtRegisteredClaimNames.Email, email)); 13 | } 14 | 15 | public static void AddName(this ICollection claims, string name) 16 | { 17 | claims.Add(new Claim(ClaimTypes.Name, name)); 18 | } 19 | 20 | public static void AddNameIdentifier(this ICollection claims, string nameIdentifier) 21 | { 22 | claims.Add(new Claim(ClaimTypes.NameIdentifier, nameIdentifier)); 23 | } 24 | 25 | public static void AddRoles(this ICollection claims, string[] roles) 26 | { 27 | roles.ToList().ForEach(role => claims.Add(new Claim(ClaimTypes.Role, role))); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfUserDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using Core.Entities.Concrete; 3 | using DataAccess.Abstract; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | using System.Linq; 8 | 9 | namespace DataAccess.Concrete.EntityFramework 10 | { 11 | public class EfUserDal : EfEntityRepositoryBase, IUserDal 12 | { 13 | public List GetClaims(User user) 14 | { 15 | using (var context = new MyDatabaseContext()) 16 | { 17 | var result = from operationClaim in context.OperationClaims 18 | join userOperationClaim in context.UserOperationClaims 19 | on operationClaim.Id equals userOperationClaim.OperationClaimId 20 | where userOperationClaim.UserId == user.Id 21 | select new OperationClaim { Id = operationClaim.Id, Name = operationClaim.Name }; 22 | return result.ToList(); 23 | 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Business/Abstract/ICarService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Core.Utilities.Results; 3 | using Entities.Concrete; 4 | using Entities.DTOs; 5 | 6 | namespace Business.Abstract 7 | { 8 | public interface ICarService 9 | { 10 | IDataResult> GetAll(); 11 | IDataResult GetCarsByCarId(int carId); 12 | IDataResult> GetCarsByBrandId(int brandId); 13 | IDataResult> GetCarsByColorId(int colorId); 14 | IDataResult> GetByDailyPrice(decimal min, decimal max); 15 | IResult Add(Car car); 16 | IResult Update(Car car); 17 | IResult Delete(Car car); 18 | IDataResult> GetCarDetails(); 19 | IDataResult> GetCarDetailsByCarId(int carId); 20 | IDataResult> GetCarDetailsByBrandId(int brandId); 21 | IDataResult> GetCarDetailsByColorId(int colorId); 22 | IDataResult> GetCarListBrandIdColorId(int brandId, int colorId); 23 | IResult AddTransactionalTest(Car car); 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/MyDatabaseContext.cs: -------------------------------------------------------------------------------- 1 | using Entities.Concrete; 2 | using Microsoft.EntityFrameworkCore; 3 | using Core.Entities.Concrete; 4 | 5 | namespace DataAccess.Concrete.EntityFramework 6 | { 7 | public class MyDatabaseContext : DbContext 8 | { 9 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 10 | { 11 | optionsBuilder.UseSqlServer(@"Server=(localdb)\MSSQLLocalDB;Database=RentACar;Trusted_Connection=true"); 12 | } 13 | 14 | public DbSet Cars { get; set; } 15 | public DbSet Brands { get; set; } 16 | public DbSet Colors { get; set; } 17 | public DbSet Users { get; set; } 18 | public DbSet Customers { get; set; } 19 | public DbSet Rentals { get; set; } 20 | public DbSet CarImages { get; set; } 21 | public DbSet OperationClaims { get; set; } 22 | public DbSet UserOperationClaims { get; set; } 23 | public DbSet Cards { get; set; } 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Aspects/Autofac/Performance/PerformanceAspect.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using Core.Utilities.Interceptors; 3 | using Core.Utilities.IoC; 4 | using System.Diagnostics; 5 | using Microsoft.Extensions.DependencyInjection; 6 | 7 | namespace Core.Aspects.Autofac.Performance 8 | { 9 | public class PerformanceAspect : MethodInterception 10 | { 11 | private readonly int _interval; 12 | private readonly Stopwatch _stopWatch; 13 | public PerformanceAspect(int interval) 14 | { 15 | _interval = interval; 16 | _stopWatch = ServiceTool.ServiceProvider.GetService(); 17 | } 18 | protected override void OnBefore(IInvocation ınvocation) 19 | { 20 | _stopWatch.Start(); 21 | } 22 | protected override void OnAfter(IInvocation invocation) 23 | { 24 | if (_stopWatch.Elapsed.TotalSeconds > _interval) 25 | { 26 | Debug.WriteLine($"Performance:{invocation.Method.DeclaringType.FullName}.{invocation.Method.Name}-->{_stopWatch.Elapsed.TotalSeconds}"); 27 | _stopWatch.Reset(); 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Core/Utilities/Interceptors/MethodInterception.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Castle.DynamicProxy; 3 | 4 | namespace Core.Utilities.Interceptors 5 | { 6 | public abstract class MethodInterception : MethodInterceptionBaseAttribute 7 | { 8 | protected virtual void OnBefore(IInvocation invocation) { } 9 | protected virtual void OnAfter(IInvocation invocation) { } 10 | protected virtual void OnException(IInvocation invocation, System.Exception e) { } 11 | protected virtual void OnSuccess(IInvocation invocation) { } 12 | public override void Intercept(IInvocation invocation) 13 | { 14 | var isSuccess = true; 15 | OnBefore(invocation); 16 | try 17 | { 18 | invocation.Proceed(); 19 | } 20 | catch(Exception e) 21 | { 22 | isSuccess = false; 23 | OnException(invocation, e); 24 | throw; 25 | } 26 | finally 27 | { 28 | if(isSuccess) 29 | { 30 | OnSuccess(invocation); 31 | } 32 | } 33 | OnAfter(invocation); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Core/Aspects/Autofac/Validation/ValidationAspect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Castle.DynamicProxy; 4 | using Core.CrossCuttingConcerns.Validation; 5 | using Core.Utilities.Interceptors; 6 | using FluentValidation; 7 | 8 | namespace Core.Aspects.Autofac.Validation 9 | { 10 | public class ValidationAspect : MethodInterception 11 | { 12 | private readonly Type _validatorType; 13 | public ValidationAspect(Type validatorType) 14 | { 15 | if(!typeof(IValidator).IsAssignableFrom(validatorType)) 16 | { 17 | throw new System.Exception("Bu bir doğrulama sınıfı değil."); 18 | } 19 | 20 | _validatorType = validatorType; 21 | } 22 | protected override void OnBefore(IInvocation invocation) 23 | { 24 | var validator = (IValidator)Activator.CreateInstance(_validatorType); 25 | var entityType = _validatorType.BaseType.GetGenericArguments()[0]; 26 | var entities = invocation.Arguments.Where(t => t.GetType() == entityType); 27 | foreach(var entity in entities) 28 | { 29 | ValidationTool.Validate(validator, entity); 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Core/Utilities/Security/Hashing/HashingHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | namespace Core.Utilities.Security.Hashing 4 | { 5 | public class HashingHelper 6 | { 7 | public static void CreatePasswordHash 8 | (string password, out byte[] passwordHash, out byte[] passwordSalt) 9 | { 10 | using (var hmac = new System.Security.Cryptography.HMACSHA512()) 11 | { 12 | passwordSalt = hmac.Key; 13 | passwordHash = hmac.ComputeHash(Encoding.UTF8.GetBytes(password)); 14 | } 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 | return true; 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Business/BusinessAspects/Autofac/SecuredOperation.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Interceptors; 2 | using Core.Utilities.IoC; 3 | using Microsoft.AspNetCore.Http; 4 | using System; 5 | using Castle.DynamicProxy; 6 | using Microsoft.Extensions.DependencyInjection; 7 | using Core.Extensions; 8 | using Business.Constants; 9 | 10 | namespace Business.BusinessAspects.Autofac 11 | { 12 | public class SecuredOperation : MethodInterception 13 | { 14 | private readonly string[] _roles; 15 | private readonly IHttpContextAccessor _httpContextAccessor; 16 | 17 | public SecuredOperation(string roles) 18 | { 19 | _roles = roles.Split(','); 20 | _httpContextAccessor = ServiceTool.ServiceProvider.GetService(); 21 | 22 | } 23 | 24 | protected override void OnBefore(IInvocation invocation) 25 | { 26 | var roleClaims = _httpContextAccessor.HttpContext.User.ClaimRoles(); 27 | foreach (var role in _roles) 28 | { 29 | if (roleClaims.Contains(role)) 30 | { 31 | return; 32 | } 33 | } 34 | throw new Exception(Messages.AuthorizationDenied); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /WebAPI/Controllers/WeatherForecastController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.Extensions.Logging; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | namespace WebAPI.Controllers 9 | { 10 | [ApiController] 11 | [Route("[controller]")] 12 | public class WeatherForecastController : ControllerBase 13 | { 14 | private static readonly string[] Summaries = new[] 15 | { 16 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" 17 | }; 18 | 19 | private readonly ILogger _logger; 20 | 21 | public WeatherForecastController(ILogger logger) 22 | { 23 | _logger = logger; 24 | } 25 | 26 | [HttpGet] 27 | public IEnumerable Get() 28 | { 29 | var rng = new Random(); 30 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast 31 | { 32 | Date = DateTime.Now.AddDays(index), 33 | TemperatureC = rng.Next(-20, 55), 34 | Summary = Summaries[rng.Next(Summaries.Length)] 35 | }) 36 | .ToArray(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Core/Aspects/Autofac/Caching/CacheAspect.cs: -------------------------------------------------------------------------------- 1 | using Castle.DynamicProxy; 2 | using Core.Utilities.Interceptors; 3 | using Core.Utilities.IoC; 4 | using System.Linq; 5 | using Microsoft.Extensions.DependencyInjection; 6 | using Core.CrossCuttingConcerns.Caching; 7 | 8 | namespace Core.Aspects.Autofac.Caching 9 | { 10 | public class CacheAspect : MethodInterception 11 | { 12 | private readonly int _duration; 13 | private readonly ICacheManager _cacheManager; 14 | 15 | public CacheAspect(int duration = 60) 16 | { 17 | _duration = duration; 18 | _cacheManager = ServiceTool.ServiceProvider.GetService(); 19 | } 20 | 21 | public override void Intercept(IInvocation invocation) 22 | { 23 | var methodName = string.Format($"{invocation.Method.ReflectedType.FullName}.{invocation.Method.Name}"); 24 | var arguments = invocation.Arguments.ToList(); 25 | var key = $"{methodName}({string.Join(",", arguments.Select(x => x?.ToString() ?? ""))})"; 26 | if (_cacheManager.IsAdd(key)) 27 | { 28 | invocation.ReturnValue = _cacheManager.Get(key); 29 | return; 30 | } 31 | invocation.Proceed(); 32 | _cacheManager.Add(key, invocation.ReturnValue, _duration); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfCustomerDal.cs: -------------------------------------------------------------------------------- 1 | using Core.DataAccess.EntityFramework; 2 | using DataAccess.Abstract; 3 | using Entities.Concrete; 4 | using Entities.DTOs; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Linq.Expressions; 9 | 10 | namespace DataAccess.Concrete.EntityFramework 11 | { 12 | public class EfCustomerDal : EfEntityRepositoryBase, ICustomerDal 13 | { 14 | public List GetCustomerDetails(Expression> filter = null) 15 | { 16 | using (MyDatabaseContext context = new MyDatabaseContext()) 17 | { 18 | var result = from c in context.Customers 19 | join u in context.Users on c.UserId equals u.Id 20 | 21 | select new CustomerDetailDto() 22 | { 23 | Id = c.Id, 24 | UserId = c.UserId, 25 | CompanyName = c.CompanyName, 26 | FirstName = u.FirstName, 27 | LastName = u.LastName, 28 | Email = u.Email, 29 | }; 30 | 31 | return result.ToList(); 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Business/Concrete/ColorManager.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Business.Abstract; 3 | using Business.Constants; 4 | using Business.ValidationRules.FluentValidation; 5 | using Core.Aspects.Autofac.Validation; 6 | using Core.Utilities.Results; 7 | using DataAccess.Abstract; 8 | using Entities.Concrete; 9 | 10 | namespace Business.Concrete 11 | { 12 | public class ColorManager : IColorService 13 | { 14 | private readonly IColorDal _colorDal; 15 | 16 | public ColorManager(IColorDal colorDal) 17 | { 18 | _colorDal = colorDal; 19 | } 20 | 21 | public IDataResult> GetAll() 22 | { 23 | return new SuccessDataResult>(_colorDal.GetAll(),Messages.ColorsListed); 24 | } 25 | 26 | public IDataResult GetById(int colorId) 27 | { 28 | return new SuccessDataResult(_colorDal.Get(c => c.ColorId == colorId) ); 29 | } 30 | 31 | [ValidationAspect(typeof(ColorValidator))] 32 | public IResult Add(Color color) 33 | { 34 | return new SuccessResult(Messages.ColorAdded); 35 | } 36 | 37 | public IResult Update(Color color) 38 | { 39 | return new SuccessResult(Messages.ColorUpdated); 40 | } 41 | 42 | public IResult Delete(Color color) 43 | { 44 | return new SuccessResult(Messages.ColorDeleted); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Business/Concrete/BrandManager.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Business.Abstract; 3 | using Business.Constants; 4 | using Business.ValidationRules.FluentValidation; 5 | using Core.Aspects.Autofac.Validation; 6 | using Core.Utilities.Results; 7 | using DataAccess.Abstract; 8 | using Entities.Concrete; 9 | 10 | namespace Business.Concrete 11 | { 12 | public class BrandManager : IBrandService 13 | { 14 | private readonly IBrandDal _brandDal; 15 | 16 | public BrandManager(IBrandDal brandDal) 17 | { 18 | _brandDal = brandDal; 19 | } 20 | 21 | public IDataResult> GetAll() 22 | { 23 | return new SuccessDataResult>(_brandDal.GetAll(),Messages.BrandsListed); 24 | } 25 | 26 | public IDataResult GetById(int brandId) 27 | { 28 | return new SuccessDataResult(_brandDal.Get(b => b.BrandId == brandId)); 29 | } 30 | 31 | [ValidationAspect(typeof(BrandValidator))] 32 | public IResult Add(Brand brand) 33 | { 34 | _brandDal.Add(brand); 35 | return new SuccessResult(Messages.BrandAdded); 36 | } 37 | 38 | public IResult Update(Brand brand) 39 | { 40 | _brandDal.Update(brand); 41 | return new SuccessResult(Messages.BrandUpdated); 42 | } 43 | 44 | public IResult Delete(Brand brand) 45 | { 46 | _brandDal.Delete(brand); 47 | return new SuccessResult(Messages.BrandDeleted); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /WebAPI/Controllers/AuthController.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Entities.DTOs; 3 | using Microsoft.AspNetCore.Mvc; 4 | 5 | namespace WebAPI.Controllers 6 | { 7 | [Route("api/[controller]")] 8 | [ApiController] 9 | public class AuthController : Controller 10 | { 11 | private readonly IAuthService _authService; 12 | 13 | public AuthController(IAuthService authService) 14 | { 15 | _authService = authService; 16 | } 17 | 18 | [HttpPost("login")] 19 | public ActionResult Login(UserForLoginDto userForLoginDto) 20 | { 21 | var userToLogin = _authService.Login(userForLoginDto); 22 | if (!userToLogin.Success) 23 | { 24 | return BadRequest(userToLogin.Message); 25 | } 26 | 27 | var result = _authService.CreateAccessToken(userToLogin.Data); 28 | if (result.Success) 29 | { 30 | return Ok(result.Data); 31 | } 32 | 33 | return BadRequest(result.Message); 34 | } 35 | 36 | [HttpPost("register")] 37 | public ActionResult Register(UserForRegisterDto userForRegisterDto) 38 | { 39 | var userExists = _authService.UserExists(userForRegisterDto.Email); 40 | if (!userExists.Success) 41 | { 42 | return BadRequest(userExists.Message); 43 | } 44 | 45 | var registerResult = _authService.Register(userForRegisterDto, userForRegisterDto.Password); 46 | var result = _authService.CreateAccessToken(registerResult.Data); 47 | if (result.Success) 48 | { 49 | return Ok(result.Data); 50 | } 51 | 52 | return BadRequest(result.Message); 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /Business/Concrete/UserManager.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Business.Abstract; 3 | using Business.Constants; 4 | using Business.ValidationRules.FluentValidation; 5 | using Core.Aspects.Autofac.Validation; 6 | using Core.Entities.Concrete; 7 | using Core.Utilities.Results; 8 | using DataAccess.Abstract; 9 | 10 | namespace Business.Concrete 11 | { 12 | public class UserManager : IUserService 13 | { 14 | private readonly IUserDal _userDal; 15 | 16 | public UserManager(IUserDal userDal) 17 | { 18 | _userDal = userDal; 19 | } 20 | 21 | [ValidationAspect(typeof(UserValidator))] 22 | public IResult Add(User user) 23 | { 24 | _userDal.Add(user); 25 | return new SuccessResult(Messages.UserAdded); 26 | } 27 | 28 | public IResult Update(User user) 29 | { 30 | _userDal.Update(user); 31 | return new SuccessResult(Messages.UserUpdated); 32 | } 33 | 34 | public IResult Delete(User user) 35 | { 36 | _userDal.Delete(user); 37 | return new SuccessResult(Messages.UserDeleted); 38 | } 39 | 40 | public IDataResult> GetAll() 41 | { 42 | return new SuccessDataResult>(_userDal.GetAll(), Messages.UsersListed); 43 | } 44 | 45 | public IDataResult GetById(int userId) 46 | { 47 | return new SuccessDataResult(_userDal.Get(u => u.Id == userId)); 48 | } 49 | 50 | public List GetClaims(User user) 51 | { 52 | return _userDal.GetClaims(user); 53 | } 54 | 55 | public User GetByMail(string email) 56 | { 57 | return _userDal.Get(u => u.Email == email); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Business/Concrete/CardManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Core.Utilities.Results; 3 | using DataAccess.Abstract; 4 | using Entities.Concrete; 5 | using System.Collections.Generic; 6 | 7 | namespace Business.Concrete 8 | { 9 | public class CardManager : ICardService 10 | { 11 | readonly ICardDal _cardDal; 12 | public CardManager(ICardDal cardDal) 13 | { 14 | _cardDal = cardDal; 15 | } 16 | 17 | public IResult Add(Card card) 18 | { 19 | _cardDal.Add(card); 20 | return new SuccessResult(); 21 | } 22 | 23 | public IResult Delete(Card card) 24 | { 25 | _cardDal.Delete(card); 26 | return new SuccessResult(); 27 | } 28 | 29 | public IDataResult> GetAll() 30 | { 31 | return new SuccessDataResult>(_cardDal.GetAll()); 32 | } 33 | 34 | public IDataResult> GetByCardNumber(string cardNumber) 35 | { 36 | return new SuccessDataResult>(_cardDal.GetAll(c => c.CardNumber == cardNumber)); 37 | } 38 | 39 | public IDataResult GetById(int carId) 40 | { 41 | return new SuccessDataResult(_cardDal.Get(c => c.Id == carId)); 42 | } 43 | 44 | public IResult IsCardExist(Card card) 45 | { 46 | var result = _cardDal.Get(c => c.CardName == card.CardName && c.CardNumber == card.CardNumber && c.CardCvv == card.CardCvv); 47 | if (result == null) 48 | { 49 | return new ErrorResult(); 50 | } 51 | return new SuccessResult(); 52 | } 53 | 54 | public IResult Update(Card card) 55 | { 56 | _cardDal.Update(card); 57 | return new SuccessResult(); 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /Business/Concrete/CustomerManager.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Business.Abstract; 3 | using Business.Constants; 4 | using Business.ValidationRules.FluentValidation; 5 | using Core.Aspects.Autofac.Validation; 6 | using Core.Utilities.Results; 7 | using DataAccess.Abstract; 8 | using Entities.Concrete; 9 | using Entities.DTOs; 10 | 11 | namespace Business.Concrete 12 | { 13 | public class CustomerManager : ICustomerService 14 | { 15 | readonly ICustomerDal _customerDal; 16 | 17 | public CustomerManager(ICustomerDal customerDal) 18 | { 19 | _customerDal = customerDal; 20 | } 21 | 22 | [ValidationAspect(typeof(CustomerValidator))] 23 | public IResult Add(Customer customer) 24 | { 25 | _customerDal.Add(customer); 26 | return new SuccessResult(Messages.CustomerAdded); 27 | } 28 | 29 | public IResult Update(Customer customer) 30 | { 31 | _customerDal.Update(customer); 32 | return new SuccessResult(Messages.CustomerUpdated); 33 | } 34 | 35 | public IResult Delete(Customer customer) 36 | { 37 | _customerDal.Delete(customer); 38 | return new SuccessResult(Messages.CustomerDeleted); 39 | } 40 | 41 | public IDataResult> GetAll() 42 | { 43 | return new SuccessDataResult>(_customerDal.GetAll(), Messages.CustomersListed); 44 | } 45 | 46 | public IDataResult GetById(int customerId) 47 | { 48 | return new SuccessDataResult(_customerDal.Get(c => c.Id == customerId)); 49 | } 50 | 51 | public IDataResult> GetCustomerDetails() 52 | { 53 | return new SuccessDataResult>(_customerDal.GetCustomerDetails()); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /DataAccess/Concrete/EntityFramework/EfCarDal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Linq.Expressions; 5 | using Core.DataAccess.EntityFramework; 6 | using DataAccess.Abstract; 7 | using Entities.Concrete; 8 | using Entities.DTOs; 9 | 10 | namespace DataAccess.Concrete.EntityFramework 11 | { 12 | public class EfCarDal : EfEntityRepositoryBase, ICarDal 13 | { 14 | public List GetCarDetails(Expression> filter = null) 15 | { 16 | using (MyDatabaseContext context = new MyDatabaseContext()) 17 | { 18 | var result = from c in context.Cars 19 | join b in context.Brands on c.BrandId equals b.BrandId 20 | join cl in context.Colors on c.ColorId equals cl.ColorId 21 | 22 | select new CarDetailDto 23 | { 24 | CarId = c.CarId, 25 | BrandId = c.BrandId, 26 | ColorId = c.ColorId, 27 | CarName = c.CarName, 28 | BrandName = b.BrandName, 29 | ColorName = cl.ColorName, 30 | DailyPrice = c.DailyPrice, 31 | ModelYear = c.ModelYear, 32 | Description = c.Description, 33 | CarImage = (from img in context.CarImages 34 | where (c.CarId == img.CarId) 35 | select new CarImage { Id = img.Id, CarId = c.CarId, CreationTime = img.CreationTime, ImagePath = img.ImagePath }).ToList() 36 | }; 37 | 38 | return filter == null ? result.ToList() : result.Where(filter).ToList(); 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /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.Collections.Generic; 7 | using System.Linq; 8 | using System.Linq.Expressions; 9 | 10 | namespace DataAccess.Concrete.EntityFramework 11 | { 12 | public class EfRentalDal : EfEntityRepositoryBase, IRentalDal 13 | { 14 | public List GetRentalDetails(Expression> filter = null) 15 | { 16 | using (MyDatabaseContext context = new MyDatabaseContext()) 17 | { 18 | var result = from r in context.Rentals 19 | join car in context.Cars on r.CarId equals car.CarId 20 | join brand in context.Brands on car.BrandId equals brand.BrandId 21 | join color in context.Colors on car.ColorId equals color.ColorId 22 | join customer in context.Customers on r.CustomerId equals customer.Id 23 | join user in context.Users on customer.UserId equals user.Id 24 | 25 | select new RentalDetailDto 26 | { 27 | Id = r.Id, 28 | CarId = car.CarId, 29 | CustomerId = customer.Id, 30 | CarName = car.CarName, 31 | ReturnDate = r.ReturnDate, 32 | RentDate = r.RentDate, 33 | DailyPrice = car.DailyPrice, 34 | BrandName = brand.BrandName, 35 | ColorName = color.ColorName, 36 | CompanyName = customer.CompanyName, 37 | CustomerName = user.FirstName + " " + user.LastName, 38 | }; 39 | 40 | return filter == null ? result.ToList() : result.Where(filter).ToList(); 41 | } 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /WebAPI/Controllers/UsersController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Business.Abstract; 3 | using Core.Entities.Concrete; 4 | 5 | namespace WebAPI.Controllers 6 | { 7 | [Route("api/[controller]")] 8 | [ApiController] 9 | public class UsersController : ControllerBase 10 | { 11 | private readonly IUserService _userService; 12 | 13 | public UsersController(IUserService userService) 14 | { 15 | _userService = userService; 16 | } 17 | 18 | [HttpPost("add")] 19 | public IActionResult Add(User user) 20 | { 21 | var result = _userService.Add(user); 22 | if (result.Success) 23 | { 24 | return Ok(result); 25 | } 26 | 27 | return BadRequest(result.Message); 28 | } 29 | 30 | [HttpPost("delete")] 31 | public IActionResult Delete(User user) 32 | { 33 | var result = _userService.Delete(user); 34 | if (result.Success) 35 | { 36 | return Ok(result); 37 | } 38 | 39 | return BadRequest(result.Message); 40 | } 41 | 42 | [HttpPost("update")] 43 | public IActionResult Update(User user) 44 | { 45 | var result = _userService.Update(user); 46 | if (result.Success) 47 | { 48 | return Ok(result); 49 | } 50 | 51 | return BadRequest(result.Message); 52 | } 53 | 54 | [HttpGet("getall")] 55 | public IActionResult GetAll() 56 | { 57 | var result = _userService.GetAll(); 58 | if (result.Success) 59 | { 60 | return Ok(result); 61 | } 62 | 63 | return BadRequest(result.Message); 64 | } 65 | 66 | [HttpGet("getbyid")] 67 | public IActionResult GetById(int id) 68 | { 69 | var result = _userService.GetById(id); 70 | if (result.Success) 71 | { 72 | return Ok(result); 73 | } 74 | 75 | return BadRequest(result.Message); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /WebAPI/Controllers/ColorsController.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Entities.Concrete; 3 | using Microsoft.AspNetCore.Mvc; 4 | 5 | namespace WebAPI.Controllers 6 | { 7 | [Route("api/[controller]")] 8 | [ApiController] 9 | public class ColorsController : ControllerBase 10 | { 11 | private readonly IColorService _colorService; 12 | 13 | public ColorsController(IColorService colorService) 14 | { 15 | _colorService = colorService; 16 | } 17 | 18 | [HttpPost("add")] 19 | public IActionResult Add(Color color) 20 | { 21 | var result = _colorService.Add(color); 22 | if (result.Success) 23 | { 24 | return Ok(result); 25 | } 26 | 27 | return BadRequest(result.Message); 28 | } 29 | 30 | [HttpPost("update")] 31 | public IActionResult Update(Color color) 32 | { 33 | var result = _colorService.Update(color); 34 | if (result.Success) 35 | { 36 | return Ok(result); 37 | } 38 | 39 | return BadRequest(result.Message); 40 | } 41 | 42 | [HttpPost("delete")] 43 | public IActionResult Delete(Color color) 44 | { 45 | var result = _colorService.Delete(color); 46 | if (result.Success) 47 | { 48 | return Ok(result); 49 | } 50 | 51 | return BadRequest(result.Message); 52 | } 53 | 54 | [HttpGet("getall")] 55 | public IActionResult GetAll() 56 | { 57 | var result = _colorService.GetAll(); 58 | if (result.Success) 59 | { 60 | return Ok(result); 61 | } 62 | 63 | return BadRequest(result.Message); 64 | } 65 | 66 | [HttpGet("getbyid")] 67 | public IActionResult GetById(int id) 68 | { 69 | var result = _colorService.GetById(id); 70 | if (result.Success) 71 | { 72 | return Ok(result); 73 | } 74 | 75 | return BadRequest(result.Message); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /WebAPI/Controllers/BrandsController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Business.Abstract; 3 | using Entities.Concrete; 4 | 5 | namespace WebAPI.Controllers 6 | { 7 | [Route("api/[controller]")] 8 | [ApiController] 9 | public class BrandsController : ControllerBase 10 | { 11 | private readonly IBrandService _brandService; 12 | 13 | public BrandsController(IBrandService brandService) 14 | { 15 | _brandService = brandService; 16 | } 17 | 18 | [HttpPost("add")] 19 | public IActionResult Add(Brand brand) 20 | { 21 | var result = _brandService.Add(brand); 22 | if (result.Success) 23 | { 24 | return Ok(result); 25 | } 26 | 27 | return BadRequest(result.Message); 28 | } 29 | 30 | [HttpPost("delete")] 31 | public IActionResult Delete(Brand brand) 32 | { 33 | var result = _brandService.Delete(brand); 34 | if(result.Success) 35 | { 36 | return Ok(result); 37 | } 38 | 39 | return BadRequest(result.Message); 40 | } 41 | 42 | [HttpPost("update")] 43 | public IActionResult Update(Brand brand) 44 | { 45 | var result = _brandService.Update(brand); 46 | if(result.Success) 47 | { 48 | return Ok(result); 49 | } 50 | 51 | return BadRequest(result.Message); 52 | } 53 | 54 | [HttpGet("getall")] 55 | public IActionResult GetAll() 56 | { 57 | var result = _brandService.GetAll(); 58 | if (result.Success) 59 | { 60 | return Ok(result); 61 | } 62 | 63 | return BadRequest(result.Message); 64 | } 65 | 66 | [HttpGet("getbyid")] 67 | public IActionResult GetById(int id) 68 | { 69 | var result = _brandService.GetById(id); 70 | if (result.Success) 71 | { 72 | return Ok(result); 73 | } 74 | 75 | return BadRequest(result.Message); 76 | } 77 | 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Core/DataAccess/EntityFramework/EfEntityRepositoryBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Linq.Expressions; 5 | using Core.Entities; 6 | using Microsoft.EntityFrameworkCore; 7 | 8 | namespace Core.DataAccess.EntityFramework 9 | { 10 | public class EfEntityRepositoryBase : IEntityRepository 11 | where TEntity : class, IEntity, new() 12 | where TContext : DbContext, new() 13 | { 14 | public void Add(TEntity entity) 15 | { 16 | using(TContext context = new TContext()) 17 | { 18 | var addedEntity = context.Entry(entity); 19 | addedEntity.State = EntityState.Added; 20 | context.SaveChanges(); 21 | } 22 | } 23 | 24 | public void Update(TEntity entity) 25 | { 26 | using(TContext context = new TContext()) 27 | { 28 | var updatedEntity = context.Entry(entity); 29 | updatedEntity.State = EntityState.Modified; 30 | context.SaveChanges(); 31 | } 32 | } 33 | 34 | public void Delete(TEntity entity) 35 | { 36 | using(TContext context = new TContext()) 37 | { 38 | var deletedEntity = context.Entry(entity); 39 | deletedEntity.State = EntityState.Deleted; 40 | context.SaveChanges(); 41 | } 42 | } 43 | 44 | public List GetAll(Expression> filter = null) 45 | { 46 | using(TContext context = new TContext()) 47 | { 48 | return filter == null ? context.Set().ToList() : context.Set().Where(filter).ToList(); 49 | } 50 | } 51 | 52 | public TEntity Get(Expression> filter) 53 | { 54 | using(TContext context = new TContext()) 55 | { 56 | return context.Set().SingleOrDefault(filter); 57 | } 58 | } 59 | 60 | public TEntity GetById(int Id) 61 | { 62 | throw new NotImplementedException(); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /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 Microsoft.Extensions.DependencyInjection; 6 | using System.Text.RegularExpressions; 7 | using System.Linq; 8 | 9 | namespace Core.CrossCuttingConcerns.Caching.Microsoft 10 | { 11 | public class MemoryCacheManager : ICacheManager 12 | { 13 | private readonly IMemoryCache _memoryCache; 14 | 15 | public MemoryCacheManager() 16 | { 17 | _memoryCache = ServiceTool.ServiceProvider.GetService(); 18 | } 19 | 20 | public void Add(string key, object value, int duration) 21 | { 22 | _memoryCache.Set(key, value, TimeSpan.FromMinutes(duration)); 23 | } 24 | 25 | public T Get(string key) 26 | { 27 | return _memoryCache.Get(key); 28 | } 29 | 30 | public object Get(string key) 31 | { 32 | return _memoryCache.Get(key); 33 | } 34 | 35 | public bool IsAdd(string key) 36 | { 37 | return _memoryCache.TryGetValue(key, out _); 38 | } 39 | 40 | public void Remove(string key) 41 | { 42 | _memoryCache.Remove(key); 43 | } 44 | 45 | public void RemoveByPattern(string pattern) 46 | { 47 | var cacheEntriesCollectionDefinition = typeof(MemoryCache).GetProperty("EntriesCollection", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); 48 | var cacheEntriesCollection = cacheEntriesCollectionDefinition.GetValue(_memoryCache) as dynamic; 49 | List cacheCollectionValues = new List(); 50 | 51 | foreach (var cacheItem in cacheEntriesCollection) 52 | { 53 | ICacheEntry cacheItemValue = cacheItem.GetType().GetProperty("Value").GetValue(cacheItem, null); 54 | cacheCollectionValues.Add(cacheItemValue); 55 | } 56 | 57 | var regex = new Regex(pattern, RegexOptions.Singleline | RegexOptions.Compiled | RegexOptions.IgnoreCase); 58 | var keysToRemove = cacheCollectionValues.Where(d => regex.IsMatch(d.Key.ToString())).Select(d => d.Key).ToList(); 59 | 60 | foreach (var key in keysToRemove) 61 | { 62 | _memoryCache.Remove(key); 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Core/Utilities/Helpers/FileHelper.cs: -------------------------------------------------------------------------------- 1 | using Core.Utilities.Results; 2 | using Microsoft.AspNetCore.Http; 3 | using System; 4 | using System.IO; 5 | 6 | namespace Core.Utilities.Helpers 7 | { 8 | public class FileHelper 9 | { 10 | public static string Add(IFormFile file) 11 | { 12 | string sourcePath = Path.GetTempFileName(); 13 | string destFileNameForDb = CreateNewFilePathForDB(file); 14 | string destFileNameForLocalFolder = CreateNewFilePathForLocalFolder(destFileNameForDb); 15 | 16 | if (file.Length>0) 17 | { 18 | using (var stream = new FileStream(sourcePath,FileMode.Create)) 19 | { 20 | file.CopyTo(stream); 21 | } 22 | } 23 | 24 | File.Move(sourcePath,destFileNameForLocalFolder); 25 | return destFileNameForDb; 26 | } 27 | 28 | public static IResult Delete(string path) 29 | { 30 | try 31 | { 32 | File.Delete(path); 33 | } 34 | catch(Exception exception) 35 | { 36 | return new ErrorResult(exception.Message); 37 | } 38 | 39 | return new SuccessResult(); 40 | } 41 | 42 | public static string Update(string sourcePath, IFormFile file) 43 | { 44 | string pathForDb = CreateNewFilePathForDB(file); 45 | string pathForFolder = CreateNewFilePathForLocalFolder(pathForDb); 46 | 47 | if(sourcePath.Length > 0) 48 | { 49 | using(var stream = new FileStream(pathForFolder, FileMode.Create)) 50 | { 51 | file.CopyTo(stream); 52 | } 53 | } 54 | 55 | File.Delete(sourcePath); 56 | return pathForDb; 57 | } 58 | 59 | public static string CreateNewFilePathForDB(IFormFile file) 60 | { 61 | FileInfo fileInfo = new FileInfo(file.FileName); 62 | string fileExtension = fileInfo.Extension; 63 | string newPath = Guid.NewGuid().ToString() + fileExtension; 64 | 65 | string result = $@"CarImages\{newPath}"; 66 | return result; 67 | } 68 | 69 | public static string CreateNewFilePathForLocalFolder(string pathForLocalFolder) 70 | { 71 | string path = Environment.CurrentDirectory + @"\wwwroot\" + pathForLocalFolder; 72 | return path; 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Business/DependencyResolvers/Autofac/AutofacBusinessModule.cs: -------------------------------------------------------------------------------- 1 | using Autofac; 2 | using Autofac.Extras.DynamicProxy; 3 | using Business.Abstract; 4 | using Business.Concrete; 5 | using Castle.DynamicProxy; 6 | using Core.Utilities.Interceptors; 7 | using DataAccess.Abstract; 8 | using DataAccess.Concrete.EntityFramework; 9 | using Core.Utilities.Security.JWT; 10 | using Microsoft.AspNetCore.Http; 11 | 12 | namespace Business.DependencyResolvers.Autofac 13 | { 14 | public class AutofacBusinessModule : Module 15 | { 16 | protected override void Load(ContainerBuilder builder) 17 | { 18 | builder.RegisterType().As().SingleInstance(); 19 | builder.RegisterType().As().SingleInstance(); 20 | 21 | builder.RegisterType().As().SingleInstance(); 22 | builder.RegisterType().As().SingleInstance(); 23 | 24 | builder.RegisterType().As().SingleInstance(); 25 | builder.RegisterType().As().SingleInstance(); 26 | 27 | builder.RegisterType().As().SingleInstance(); 28 | builder.RegisterType().As().SingleInstance(); 29 | 30 | builder.RegisterType().As().SingleInstance(); 31 | builder.RegisterType().As().SingleInstance(); 32 | 33 | builder.RegisterType().As().SingleInstance(); 34 | builder.RegisterType().As().SingleInstance(); 35 | 36 | builder.RegisterType().As().SingleInstance(); 37 | builder.RegisterType().As().SingleInstance(); 38 | 39 | builder.RegisterType().As().SingleInstance(); 40 | builder.RegisterType().As().SingleInstance(); 41 | 42 | builder.RegisterType().As(); 43 | builder.RegisterType().As(); 44 | 45 | var assembly = System.Reflection.Assembly.GetExecutingAssembly(); 46 | 47 | builder.RegisterAssemblyTypes(assembly).AsImplementedInterfaces() 48 | .EnableInterfaceInterceptors(new ProxyGenerationOptions() 49 | { 50 | Selector = new AspectInterceptorSelector() 51 | }).SingleInstance(); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /WebAPI/Controllers/CustomersController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Business.Abstract; 3 | using Entities.Concrete; 4 | 5 | namespace WebAPI.Controllers 6 | { 7 | [Route("api/[controller]")] 8 | [ApiController] 9 | public class CustomersController : ControllerBase 10 | { 11 | private readonly ICustomerService _customerService; 12 | 13 | public CustomersController(ICustomerService customerService) 14 | { 15 | _customerService = customerService; 16 | } 17 | 18 | [HttpPost("add")] 19 | public IActionResult Add(Customer customer) 20 | { 21 | var result = _customerService.Add(customer); 22 | if(result.Success) 23 | { 24 | return Ok(result); 25 | } 26 | 27 | return BadRequest(result.Message); 28 | } 29 | 30 | [HttpPost("delete")] 31 | public IActionResult Delete(Customer customer) 32 | { 33 | var result = _customerService.Delete(customer); 34 | if(result.Success) 35 | { 36 | return Ok(result); 37 | } 38 | 39 | return BadRequest(result.Message); 40 | } 41 | 42 | [HttpPost("update")] 43 | public IActionResult Update(Customer customer) 44 | { 45 | var result = _customerService.Update(customer); 46 | if(result.Success) 47 | { 48 | return Ok(result); 49 | } 50 | 51 | return BadRequest(result.Message); 52 | } 53 | 54 | [HttpGet("getall")] 55 | public IActionResult GetAll() 56 | { 57 | var result = _customerService.GetAll(); 58 | if(result.Success) 59 | { 60 | return Ok(result); 61 | } 62 | 63 | return BadRequest(result.Message); 64 | } 65 | 66 | [HttpGet("getcostumerbyid")] 67 | public IActionResult GetCustomerById(int id) 68 | { 69 | var result = _customerService.GetById(id); 70 | if (result.Success) 71 | { 72 | return Ok(result); 73 | } 74 | 75 | return BadRequest(result.Message); 76 | } 77 | 78 | [HttpGet("getcustomerdetails")] 79 | public IActionResult GetCustomerDetails() 80 | { 81 | var result = _customerService.GetCustomerDetails(); 82 | if (result.Success) 83 | { 84 | return Ok(result); 85 | } 86 | 87 | return BadRequest(result.Message); 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /Business/Concrete/RentalManager.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Business.Abstract; 3 | using Business.Constants; 4 | using Business.ValidationRules.FluentValidation; 5 | using Core.Aspects.Autofac.Caching; 6 | using Core.Aspects.Autofac.Performance; 7 | using Core.Aspects.Autofac.Validation; 8 | using Core.Utilities.Results; 9 | using DataAccess.Abstract; 10 | using Entities.Concrete; 11 | using Entities.DTOs; 12 | 13 | namespace Business.Concrete 14 | { 15 | public class RentalManager : IRentalService 16 | { 17 | private readonly IRentalDal _rentalDal; 18 | 19 | public RentalManager(IRentalDal rentalDal) 20 | { 21 | _rentalDal = rentalDal; 22 | } 23 | 24 | [ValidationAspect(typeof(RentalValidator))] 25 | public IResult Add(Rental rental) 26 | { 27 | if (rental.ReturnDate == null) 28 | { 29 | return new ErrorResult(Messages.RentalInvalidation); 30 | } 31 | 32 | _rentalDal.Add(rental); 33 | return new SuccessResult(Messages.RentalAdded); 34 | } 35 | 36 | public IResult Update(Rental rental) 37 | { 38 | _rentalDal.Update(rental); 39 | return new SuccessResult(Messages.RentalUpdated); 40 | } 41 | 42 | public IResult Delete(Rental rental) 43 | { 44 | _rentalDal.Delete(rental); 45 | return new SuccessResult(Messages.RentalDeleted); 46 | } 47 | 48 | public IDataResult> GetAll() 49 | { 50 | return new SuccessDataResult>(_rentalDal.GetAll()); 51 | } 52 | 53 | public IDataResult GetById(int rentalId) 54 | { 55 | return new SuccessDataResult(_rentalDal.Get(r => r.Id == rentalId)); 56 | } 57 | 58 | public IDataResult> GetAllRental() 59 | { 60 | return new SuccessDataResult>(_rentalDal.GetAll()); 61 | } 62 | 63 | [CacheAspect] 64 | [PerformanceAspect(10)] 65 | public IDataResult> GetRentalDetails() 66 | { 67 | return new SuccessDataResult>(_rentalDal.GetRentalDetails()); 68 | } 69 | 70 | public IDataResult> GetRentalDetailsByCarId(int carId) 71 | { 72 | return new SuccessDataResult>(_rentalDal.GetRentalDetails(r => r.CarId == carId)); 73 | } 74 | 75 | public IDataResult> GetRentalDetailsByCustomerId(int customerId) 76 | { 77 | return new SuccessDataResult>(_rentalDal.GetRentalDetails(r => r.CustomerId == customerId)); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /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 | 12 | namespace Core.Utilities.Security.JWT 13 | { 14 | public class JwtHelper : ITokenHelper 15 | { 16 | public IConfiguration Configuration { get; } 17 | private readonly TokenOptions _tokenOptions; 18 | private DateTime _accessTokenExpiration; 19 | public JwtHelper(IConfiguration configuration) 20 | { 21 | Configuration = configuration; 22 | _tokenOptions = Configuration.GetSection("TokenOptions").Get(); 23 | 24 | } 25 | public AccessToken CreateToken(User user, List operationClaims) 26 | { 27 | _accessTokenExpiration = DateTime.Now.AddMinutes(_tokenOptions.AccessTokenExpiration); 28 | var securityKey = SecurityKeyHelper.CreateSecurityKey(_tokenOptions.SecurityKey); 29 | var signingCredentials = SigningCredentialsHelper.CreateSigningCredentials(securityKey); 30 | var jwt = CreateJwtSecurityToken(_tokenOptions, user, signingCredentials, operationClaims); 31 | var jwtSecurityTokenHandler = new JwtSecurityTokenHandler(); 32 | var token = jwtSecurityTokenHandler.WriteToken(jwt); 33 | 34 | return new AccessToken 35 | { 36 | Token = token, 37 | Expiration = _accessTokenExpiration 38 | }; 39 | 40 | } 41 | 42 | public JwtSecurityToken CreateJwtSecurityToken(TokenOptions tokenOptions, User user, 43 | SigningCredentials signingCredentials, List operationClaims) 44 | { 45 | var jwt = new JwtSecurityToken( 46 | issuer: tokenOptions.Issuer, 47 | audience: tokenOptions.Audience, 48 | expires: _accessTokenExpiration, 49 | notBefore: DateTime.Now, 50 | claims: SetClaims(user, operationClaims), 51 | signingCredentials: signingCredentials 52 | ); 53 | return jwt; 54 | } 55 | 56 | private IEnumerable SetClaims(User user, List operationClaims) 57 | { 58 | var claims = new List(); 59 | claims.AddNameIdentifier(user.Id.ToString()); 60 | claims.AddEmail(user.Email); 61 | claims.AddName($"{user.FirstName} {user.LastName}"); 62 | claims.AddRoles(operationClaims.Select(c => c.Name).ToArray()); 63 | 64 | return claims; 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /WebAPI/Controllers/CarImagesController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Business.Abstract; 3 | using Entities.Concrete; 4 | using Microsoft.AspNetCore.Http; 5 | 6 | namespace WebAPI.Controllers 7 | { 8 | [Route("api/[controller]")] 9 | [ApiController] 10 | public class CarImagesController : ControllerBase 11 | { 12 | private readonly ICarImageService _carImageService; 13 | 14 | public CarImagesController(ICarImageService carImageService) 15 | { 16 | _carImageService = carImageService; 17 | } 18 | 19 | [HttpPost("add")] 20 | public IActionResult Add([FromForm(Name = ("Image"))] IFormFile file,[FromForm] CarImage carImage) 21 | { 22 | var result = _carImageService.Add(file, carImage); 23 | if(result.Success) 24 | { 25 | return Ok(result); 26 | } 27 | 28 | return BadRequest(result); 29 | } 30 | 31 | [HttpPost("update")] 32 | public IActionResult Update([FromForm(Name = ("Image"))] IFormFile file, [FromForm] int id) 33 | { 34 | var carImage = _carImageService.GetById(id).Data; 35 | var result = _carImageService.Update(file, carImage); 36 | 37 | if(result.Success) 38 | { 39 | return Ok(result); 40 | } 41 | 42 | return BadRequest(result); 43 | } 44 | 45 | [HttpPost("delete")] 46 | public IActionResult Delete([FromForm] int id) 47 | { 48 | var carImage = _carImageService.GetById(id).Data; 49 | var result = _carImageService.Delete(carImage); 50 | 51 | if(result.Success) 52 | { 53 | return Ok(result); 54 | } 55 | 56 | return BadRequest(result); 57 | } 58 | 59 | [HttpGet("getbyid")] 60 | public IActionResult GetById(int id) 61 | { 62 | var result = _carImageService.GetById(id); 63 | if(result.Success) 64 | { 65 | return Ok(result); 66 | } 67 | 68 | return BadRequest(result); 69 | } 70 | 71 | [HttpGet("getall")] 72 | public IActionResult GetAll() 73 | { 74 | var result = _carImageService.GetAll(); 75 | if(result.Success) 76 | { 77 | return Ok(result); 78 | } 79 | 80 | return BadRequest(result); 81 | } 82 | 83 | [HttpGet("getbycarid")] 84 | public IActionResult GetByCarId(int carId) 85 | { 86 | var result = _carImageService.GetByCarId(carId); 87 | 88 | if(result.Success) 89 | { 90 | return Ok(result); 91 | } 92 | 93 | return BadRequest(result); 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /Business/Constants/Messages.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.Serialization; 2 | 3 | namespace Business.Constants 4 | { 5 | public static class Messages 6 | { 7 | public static string CarAdded = "Araba eklendi."; 8 | public static string CarNameValid = "Araba ismi geçersiz."; 9 | public static string MaintenanceTime = "Bakım zamanı."; 10 | public static string CarsListed = "Arabalar listelendi."; 11 | public static string CarUpdated = "Araba güncellendi."; 12 | public static string CarDeleted = "Araba silindi."; 13 | 14 | public static string BrandAdded = "Marka eklendi."; 15 | public static string BrandUpdated = "Marka güncellendi."; 16 | public static string BrandDeleted = "Marka silindi."; 17 | public static string BrandsListed = "Markalar listelendi."; 18 | 19 | public static string ColorAdded = "Renk eklendi."; 20 | public static string ColorUpdated = "Renk güncellendi."; 21 | public static string ColorDeleted = "Renk silindi."; 22 | public static string ColorsListed = "Renkler listelendi."; 23 | 24 | public static string UserAdded = "Kullanıcı eklendi."; 25 | public static string UserUpdated = "Kullanıcı güncellendi."; 26 | public static string UserDeleted = "Kullanıcı silindi."; 27 | public static string UsersListed = "Kullanıcı listelendi."; 28 | 29 | public static string CustomerAdded = "Müşteri eklendi."; 30 | public static string CustomerUpdated = "Müşteri güncellendi."; 31 | public static string CustomerDeleted = "Müşteri silindi."; 32 | public static string CustomersListed = "Müşteri listelendi."; 33 | 34 | 35 | public static string RentalAdded = "Kiralama eklendi."; 36 | public static string RentalUpdated = "Kiralama güncellendi."; 37 | public static string RentalDeleted = "Kiralama silindi."; 38 | public static string RentalInvalidation = "Araba kirada!"; 39 | 40 | public static string CarCountOfBrandError = "15 den fazla marka olamaz."; 41 | public static string CarNameAlreadyExists = "Bu isim de zaten bir araba var."; 42 | public static string BrandLimitExceded = "Marka limiti aşıldı."; 43 | 44 | public static string CarImageLimitExceded = "Bir araba 5'den fazla resim eklenemez."; 45 | public static string CarImageAdded = "Araba resmi eklendi."; 46 | 47 | public static string AuthorizationDenied = "Yetkiniz yok!"; 48 | public static string UserAlreadyExists = "Kullanıcı mevcut"; 49 | public static string AccessTokenCreated = "Token oluşturuldu"; 50 | public static string SuccessfulLogin = "Başarılı giriş"; 51 | public static string PasswordError = "Parola hatası"; 52 | public static string UserNotFound = "Kullanıcı bulunamadı"; 53 | public static string UserRegistered = "Kayıt oldu"; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /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.DTOs; 8 | 9 | namespace Business.Concrete 10 | { 11 | public class AuthManager : IAuthService 12 | { 13 | private readonly IUserService _userService; 14 | private readonly ITokenHelper _tokenHelper; 15 | 16 | public AuthManager(IUserService userService, ITokenHelper tokenHelper) 17 | { 18 | _userService = userService; 19 | _tokenHelper = tokenHelper; 20 | } 21 | 22 | public AuthManager(ITokenHelper tokenHelper) 23 | { 24 | _tokenHelper = tokenHelper; 25 | } 26 | 27 | public IDataResult Register(UserForRegisterDto userForRegisterDto, string password) 28 | { 29 | byte[] passwordHash, passwordSalt; 30 | HashingHelper.CreatePasswordHash(password, out passwordHash, out passwordSalt); 31 | var user = new User 32 | { 33 | Email = userForRegisterDto.Email, 34 | FirstName = userForRegisterDto.FirstName, 35 | LastName = userForRegisterDto.LastName, 36 | PasswordHash = passwordHash, 37 | PasswordSalt = passwordSalt, 38 | Status = true 39 | }; 40 | _userService.Add(user); 41 | return new SuccessDataResult(user, Messages.UserRegistered); 42 | } 43 | 44 | public IDataResult Login(UserForLoginDto userForLoginDto) 45 | { 46 | var userToCheck = _userService.GetByMail(userForLoginDto.Email); 47 | if (userToCheck == null) 48 | { 49 | return new ErrorDataResult(Messages.UserNotFound); 50 | } 51 | 52 | if (!HashingHelper.VerifyPasswordHash(userForLoginDto.Password, userToCheck.PasswordHash, userToCheck.PasswordSalt)) 53 | { 54 | return new ErrorDataResult(Messages.PasswordError); 55 | } 56 | 57 | return new SuccessDataResult(userToCheck, Messages.SuccessfulLogin); 58 | } 59 | 60 | public IResult UserExists(string email) 61 | { 62 | if (_userService.GetByMail(email) != null) 63 | { 64 | return new ErrorResult(Messages.UserAlreadyExists); 65 | } 66 | return new SuccessResult(); 67 | } 68 | 69 | public IDataResult CreateAccessToken(User user) 70 | { 71 | var claims = _userService.GetClaims(user); 72 | var accessToken = _tokenHelper.CreateToken(user, claims); 73 | return new SuccessDataResult(accessToken, Messages.AccessTokenCreated); 74 | } 75 | } 76 | } -------------------------------------------------------------------------------- /WebAPI/Startup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.Extensions.Configuration; 4 | using Microsoft.Extensions.DependencyInjection; 5 | using Microsoft.Extensions.Hosting; 6 | using Core.Utilities.Security.Encryption; 7 | using Core.Utilities.Security.JWT; 8 | using Microsoft.AspNetCore.Authentication.JwtBearer; 9 | using Microsoft.AspNetCore.Http; 10 | using Microsoft.IdentityModel.Tokens; 11 | using Core.Utilities.IoC; 12 | using Core.Extensions; 13 | using Core.DependencyResolvers; 14 | 15 | namespace WebAPI 16 | { 17 | public class Startup 18 | { 19 | public Startup(IConfiguration configuration) 20 | { 21 | Configuration = configuration; 22 | } 23 | 24 | public IConfiguration Configuration { get; } 25 | 26 | // This method gets called by the runtime. Use this method to add services to the container. 27 | public void ConfigureServices(IServiceCollection services) 28 | { 29 | services.AddControllers(); 30 | 31 | services.AddCors(); 32 | 33 | var tokenOptions = Configuration.GetSection("TokenOptions").Get(); 34 | 35 | services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) 36 | .AddJwtBearer(options => 37 | { 38 | options.TokenValidationParameters = new TokenValidationParameters 39 | { 40 | ValidateIssuer = true, 41 | ValidateAudience = true, 42 | ValidateLifetime = true, 43 | ValidIssuer = tokenOptions.Issuer, 44 | ValidAudience = tokenOptions.Audience, 45 | ValidateIssuerSigningKey = true, 46 | IssuerSigningKey = SecurityKeyHelper.CreateSecurityKey(tokenOptions.SecurityKey) 47 | }; 48 | }); 49 | 50 | services.AddDependencyResolvers(new ICoreModule[] { 51 | new CoreModule() 52 | }); 53 | } 54 | 55 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 56 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 57 | { 58 | if(env.IsDevelopment()) 59 | { 60 | app.UseDeveloperExceptionPage(); 61 | } 62 | 63 | app.UseCors(builder=>builder.WithOrigins("http://localhost:4200").AllowAnyHeader()); 64 | 65 | app.UseHttpsRedirection(); 66 | 67 | app.UseRouting(); 68 | 69 | app.UseStaticFiles(); 70 | 71 | app.UseAuthentication(); 72 | 73 | app.UseAuthorization(); 74 | 75 | app.UseEndpoints(endpoints => 76 | { 77 | endpoints.MapControllers(); 78 | }); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /DataAccess/Concrete/InMemory/InMemoryCarDal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Linq.Expressions; 5 | using DataAccess.Abstract; 6 | using Entities.Concrete; 7 | using Entities.DTOs; 8 | 9 | namespace DataAccess.Concrete.InMemory 10 | { 11 | public class InMemoryCarDal : ICarDal 12 | { 13 | private List _cars; 14 | 15 | public InMemoryCarDal() 16 | { 17 | _cars = new List 18 | { 19 | new Car {CarId = 1, BrandId = 1, ColorId = 1, DailyPrice = 100, ModelYear = 2010, Description = "Sports Car"}, 20 | new Car {CarId = 2, BrandId = 1, ColorId = 1, DailyPrice = 200, ModelYear = 2011, Description = "Company Car"}, 21 | new Car {CarId = 3, BrandId = 2, ColorId = 1, DailyPrice = 300, ModelYear = 2012, Description = "Convertible"}, 22 | new Car {CarId = 4, BrandId = 3, ColorId = 2, DailyPrice = 400, ModelYear = 2013, Description = "Coupe"}, 23 | new Car {CarId = 5, BrandId = 3, ColorId = 2, DailyPrice = 500, ModelYear = 2014, Description = "Sports Utility Vehicle"} 24 | }; 25 | } 26 | 27 | public void Add(Car car) 28 | { 29 | _cars.Add(car); 30 | } 31 | 32 | public void Update(Car car) 33 | { 34 | Car carToUpdate = _cars.SingleOrDefault(c => c.CarId == car.CarId); 35 | 36 | carToUpdate.CarId = car.CarId; 37 | carToUpdate.BrandId = car.BrandId; 38 | carToUpdate.ColorId = car.ColorId; 39 | carToUpdate.DailyPrice = car.DailyPrice; 40 | carToUpdate.Description = car.Description; 41 | carToUpdate.ModelYear = car.ModelYear; 42 | } 43 | 44 | public void Delete(Car car) 45 | { 46 | Car carToDelete = _cars.SingleOrDefault(c => c.CarId == car.CarId); 47 | _cars.Remove(carToDelete); 48 | } 49 | 50 | public List GetAll(Expression> filter) 51 | { 52 | throw new NotImplementedException(); 53 | } 54 | 55 | public Car Get(Expression> filter) 56 | { 57 | throw new NotImplementedException(); 58 | } 59 | 60 | public List GetAll() 61 | { 62 | return _cars; 63 | } 64 | 65 | public Car GetById(int carId) 66 | { 67 | throw new NotImplementedException(); 68 | } 69 | 70 | public List GetCarDetails() 71 | { 72 | throw new NotImplementedException(); 73 | } 74 | 75 | public List GetAllBrand(int brandId) 76 | { 77 | return _cars.Where(c => c.BrandId == brandId).ToList(); 78 | } 79 | 80 | public List GetCarDetails(Expression> filter = null) 81 | { 82 | throw new NotImplementedException(); 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 | private readonly ICardService _cardService; 17 | 18 | public CardsController(ICardService cardService) 19 | { 20 | _cardService = cardService; 21 | } 22 | 23 | [HttpPost("add")] 24 | public IActionResult Add(Card card) 25 | { 26 | var result = _cardService.Add(card); 27 | if (result.Success) 28 | { 29 | return Ok(result); 30 | } 31 | 32 | return BadRequest(result); 33 | } 34 | 35 | [HttpPost("update")] 36 | public IActionResult Update(Card card) 37 | { 38 | var result = _cardService.Update(card); 39 | if (result.Success) 40 | { 41 | return Ok(result); 42 | } 43 | 44 | return BadRequest(result); 45 | } 46 | 47 | [HttpPost("delete")] 48 | public IActionResult Delete(Card card) 49 | { 50 | var result = _cardService.Delete(card); 51 | if (result.Success) 52 | { 53 | return Ok(result); 54 | } 55 | 56 | return BadRequest(result); 57 | } 58 | 59 | [HttpGet("getall")] 60 | public IActionResult GetAll() 61 | { 62 | var result = _cardService.GetAll(); 63 | if (result.Success) 64 | { 65 | return Ok(result); 66 | } 67 | 68 | return BadRequest(result); 69 | } 70 | 71 | [HttpGet("getbyid")] 72 | public IActionResult GetById(int id) 73 | { 74 | var result = _cardService.GetById(id); 75 | if (result.Success) 76 | { 77 | return Ok(result); 78 | } 79 | return BadRequest(result); 80 | } 81 | 82 | [HttpGet("getbycardnumber")] 83 | public IActionResult GetByCardNumber(string cardNumber) 84 | { 85 | var result = _cardService.GetByCardNumber(cardNumber); 86 | if (result.Success) 87 | { 88 | return Ok(result); 89 | } 90 | return BadRequest(result); 91 | } 92 | 93 | [HttpPost("iscardexist")] 94 | public IActionResult IsCardExist(Card card) 95 | { 96 | var result = _cardService.IsCardExist(card); 97 | if (result.Success) 98 | { 99 | return Ok(result); 100 | } 101 | return BadRequest(result); 102 | 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /WebAPI/Controllers/RentalsController.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Entities.Concrete; 3 | using Microsoft.AspNetCore.Mvc; 4 | 5 | namespace WebAPI.Controllers 6 | { 7 | [Route("api/[controller]")] 8 | [ApiController] 9 | public class RentalsController : ControllerBase 10 | { 11 | private readonly IRentalService _rentalService; 12 | 13 | public RentalsController(IRentalService rentalService) 14 | { 15 | _rentalService = rentalService; 16 | } 17 | 18 | [HttpPost("add")] 19 | public IActionResult Add(Rental rental) 20 | { 21 | var result = _rentalService.Add(rental); 22 | if (result.Success) 23 | { 24 | return Ok(result); 25 | } 26 | 27 | return BadRequest(result.Message); 28 | } 29 | 30 | [HttpPost("delete")] 31 | public IActionResult Delete(Rental rental) 32 | { 33 | var result = _rentalService.Delete(rental); 34 | if (result.Success) 35 | { 36 | return Ok(result); 37 | } 38 | 39 | return BadRequest(result.Message); 40 | } 41 | 42 | [HttpPost("update")] 43 | public IActionResult Update(Rental rental) 44 | { 45 | var result = _rentalService.Update(rental); 46 | if (result.Success) 47 | { 48 | return Ok(result); 49 | } 50 | 51 | return BadRequest(result.Message); 52 | } 53 | 54 | [HttpGet("getall")] 55 | public IActionResult GetAll() 56 | { 57 | var result = _rentalService.GetAll(); 58 | if (result.Success) 59 | { 60 | return Ok(result); 61 | } 62 | 63 | return BadRequest(result.Message); 64 | } 65 | 66 | [HttpGet("getbyid")] 67 | public IActionResult GetById(int id) 68 | { 69 | var result = _rentalService.GetById(id); 70 | if (result.Success) 71 | { 72 | return Ok(result); 73 | } 74 | 75 | return BadRequest(result.Message); 76 | } 77 | 78 | [HttpGet("getrentaldetails")] 79 | public IActionResult GetRentalDetails() 80 | { 81 | var result = _rentalService.GetRentalDetails(); 82 | if (result.Success) 83 | { 84 | return Ok(result); 85 | } 86 | 87 | return BadRequest(result.Message); 88 | } 89 | 90 | [HttpGet("getrentaldetailsbycarid")] 91 | public IActionResult GetRentalDetailsByCarId(int carId) 92 | { 93 | var result = _rentalService.GetRentalDetailsByCarId(carId); 94 | if (result.Success) 95 | { 96 | return Ok(result); 97 | } 98 | 99 | return BadRequest(result.Message); 100 | } 101 | 102 | [HttpGet("getrentaldetailsbycustomerid")] 103 | public IActionResult GetRentalDetailsByCustomerId(int customerId) 104 | { 105 | var result = _rentalService.GetRentalDetailsByCustomerId(customerId); 106 | if (result.Success) 107 | { 108 | return Ok(result); 109 | } 110 | 111 | return BadRequest(result.Message); 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /RentACarProject.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31019.35 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataAccess", "DataAccess\DataAccess.csproj", "{BF9A88BA-CD00-4E3E-9526-ED9C3EEEA0E6}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Entities", "Entities\Entities.csproj", "{EE215E30-67B5-4033-8CC6-C899D2E63837}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Business", "Business\Business.csproj", "{02AD45DC-E164-4F9F-9CC6-8EE60AA315A7}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleUI", "ConsoleUI\ConsoleUI.csproj", "{EFC31674-AD10-4337-AA0D-3C73517F944B}" 13 | EndProject 14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core", "Core\Core.csproj", "{66DB7D24-9C56-4319-9370-734F41EBA71B}" 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAPI", "WebAPI\WebAPI.csproj", "{664A43D4-9557-46D7-A43D-DD61799B5B0A}" 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 | {BF9A88BA-CD00-4E3E-9526-ED9C3EEEA0E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {BF9A88BA-CD00-4E3E-9526-ED9C3EEEA0E6}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {BF9A88BA-CD00-4E3E-9526-ED9C3EEEA0E6}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {BF9A88BA-CD00-4E3E-9526-ED9C3EEEA0E6}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {EE215E30-67B5-4033-8CC6-C899D2E63837}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {EE215E30-67B5-4033-8CC6-C899D2E63837}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {EE215E30-67B5-4033-8CC6-C899D2E63837}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {EE215E30-67B5-4033-8CC6-C899D2E63837}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {02AD45DC-E164-4F9F-9CC6-8EE60AA315A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {02AD45DC-E164-4F9F-9CC6-8EE60AA315A7}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {02AD45DC-E164-4F9F-9CC6-8EE60AA315A7}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {02AD45DC-E164-4F9F-9CC6-8EE60AA315A7}.Release|Any CPU.Build.0 = Release|Any CPU 36 | {EFC31674-AD10-4337-AA0D-3C73517F944B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 37 | {EFC31674-AD10-4337-AA0D-3C73517F944B}.Debug|Any CPU.Build.0 = Debug|Any CPU 38 | {EFC31674-AD10-4337-AA0D-3C73517F944B}.Release|Any CPU.ActiveCfg = Release|Any CPU 39 | {EFC31674-AD10-4337-AA0D-3C73517F944B}.Release|Any CPU.Build.0 = Release|Any CPU 40 | {66DB7D24-9C56-4319-9370-734F41EBA71B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 41 | {66DB7D24-9C56-4319-9370-734F41EBA71B}.Debug|Any CPU.Build.0 = Debug|Any CPU 42 | {66DB7D24-9C56-4319-9370-734F41EBA71B}.Release|Any CPU.ActiveCfg = Release|Any CPU 43 | {66DB7D24-9C56-4319-9370-734F41EBA71B}.Release|Any CPU.Build.0 = Release|Any CPU 44 | {664A43D4-9557-46D7-A43D-DD61799B5B0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 45 | {664A43D4-9557-46D7-A43D-DD61799B5B0A}.Debug|Any CPU.Build.0 = Debug|Any CPU 46 | {664A43D4-9557-46D7-A43D-DD61799B5B0A}.Release|Any CPU.ActiveCfg = Release|Any CPU 47 | {664A43D4-9557-46D7-A43D-DD61799B5B0A}.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 = {1852C158-8362-4351-8D6C-71E7950E9C98} 54 | EndGlobalSection 55 | EndGlobal 56 | -------------------------------------------------------------------------------- /Business/Concrete/CarImageManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Business.Abstract; 4 | using Business.Constants; 5 | using Business.ValidationRules.FluentValidation; 6 | using Core.Aspects.Autofac.Validation; 7 | using Core.Utilities.Business; 8 | using Core.Utilities.Helpers; 9 | using Core.Utilities.Results; 10 | using DataAccess.Abstract; 11 | using Entities.Concrete; 12 | using Microsoft.AspNetCore.Http; 13 | using System.Linq; 14 | 15 | namespace Business.Concrete 16 | { 17 | public class CarImageManager : ICarImageService 18 | { 19 | private readonly ICarImageDal _carImageDal; 20 | 21 | public CarImageManager(ICarImageDal carImageDal) 22 | { 23 | _carImageDal = carImageDal; 24 | } 25 | 26 | [ValidationAspect(typeof(CarImageValidator))] 27 | public IResult Add(IFormFile file, CarImage carImage) 28 | { 29 | IResult result = BusinessRules.Run(CheckIfCarImageLimitExceded(carImage.CarId)); 30 | 31 | if(result != null) 32 | { 33 | return result; 34 | } 35 | 36 | carImage.ImagePath = FileHelper.Add(file); 37 | carImage.CreationTime = DateTime.Now; 38 | _carImageDal.Add(carImage); 39 | 40 | return new SuccessResult(Messages.CarImageAdded); 41 | } 42 | 43 | public IResult Update(IFormFile file, CarImage carImage) 44 | { 45 | carImage.ImagePath = FileHelper.Update(Environment.CurrentDirectory + @"\wwwroot\" 46 | + _carImageDal.Get(c => c.Id == carImage.Id).ImagePath, file); 47 | carImage.CreationTime = DateTime.Now; 48 | _carImageDal.Update(carImage); 49 | 50 | return new SuccessResult(); 51 | } 52 | 53 | public IResult Delete(CarImage carImage) 54 | { 55 | FileHelper.Delete(Environment.CurrentDirectory + @"\wwwroot\" + carImage.ImagePath); 56 | _carImageDal.Delete(carImage); 57 | 58 | return new SuccessResult(); 59 | } 60 | 61 | public IDataResult> GetAll() 62 | { 63 | return new SuccessDataResult>(_carImageDal.GetAll()); 64 | } 65 | 66 | public IDataResult GetById(int carImageId) 67 | { 68 | return new SuccessDataResult(_carImageDal.Get(c => c.Id == carImageId)); 69 | } 70 | 71 | public IDataResult> GetByCarId(int carId) 72 | { 73 | IResult result = BusinessRules.Run(CheckIfAnyCarImageExists(carId)); 74 | 75 | if(result != null) 76 | { 77 | return new ErrorDataResult>(result.Message); 78 | } 79 | 80 | return new SuccessDataResult>(CheckIfAnyCarImageExists(carId).Data); 81 | } 82 | 83 | private IResult CheckIfCarImageLimitExceded(int carId) 84 | { 85 | var carImageCount = _carImageDal.GetAll(c => c.CarId == carId).Count; 86 | if(carImageCount > 5) 87 | { 88 | return new ErrorResult(Messages.CarImageLimitExceded); 89 | } 90 | 91 | return new SuccessResult(); 92 | } 93 | 94 | private IDataResult> CheckIfAnyCarImageExists(int carId) 95 | { 96 | string path = @"\CarImages\DefaultCarImage.jpg"; 97 | var result = _carImageDal.GetAll(c => c.CarId == carId).Any(); 98 | 99 | if(result) 100 | { 101 | return new SuccessDataResult>(_carImageDal.GetAll(c => c.CarId == carId)); 102 | } 103 | 104 | List carImage = new List(); 105 | carImage.Add(new CarImage { CarId = carId, ImagePath = path, CreationTime = DateTime.Now }); 106 | 107 | return new SuccessDataResult>(carImage); 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /ConsoleUI/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Business.Concrete; 3 | using DataAccess.Concrete.EntityFramework; 4 | using DataAccess.Concrete.InMemory; 5 | using Entities.Concrete; 6 | 7 | namespace ConsoleUI 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | CarManager carManager = new CarManager(new EfCarDal(), new BrandManager(new EfBrandDal())); 14 | BrandManager brandManager = new BrandManager(new EfBrandDal()); 15 | ColorManager colorManager = new ColorManager(new EfColorDal()); 16 | UserManager userManager = new UserManager(new EfUserDal()); 17 | CustomerManager customerManager = new CustomerManager(new EfCustomerDal()); 18 | RentalManager rentalManager = new RentalManager(new EfRentalDal()); 19 | 20 | GetAllUsers(userManager); 21 | GetAllCustomers(customerManager); 22 | RentalAdd(rentalManager); 23 | } 24 | 25 | private static void RentalAdd(RentalManager rentalManager) 26 | { 27 | var result = rentalManager.Add(new Rental 28 | { 29 | CarId = 5, 30 | CustomerId = 2, 31 | RentDate = DateTime.Now, 32 | ReturnDate = DateTime.Today 33 | }); // ReturnDate= Null verilirse araç kirada mesajı verir. 34 | Console.WriteLine(result.Message); 35 | } 36 | 37 | private static void GetAllCustomers(CustomerManager customerManager) 38 | { 39 | var abc = 22; 40 | abc++; 41 | abc -= 22; 42 | Console.WriteLine("Result:" + abc); 43 | 44 | var result = customerManager.GetAll(); 45 | if (result.Success) 46 | { 47 | foreach (var customer in result.Data) 48 | { 49 | Console.WriteLine(customer.CompanyName); 50 | } 51 | } 52 | } 53 | 54 | private static void GetAllUsers(UserManager userManager) 55 | { 56 | var result = userManager.GetAll(); 57 | if (result.Success) 58 | { 59 | foreach (var user in result.Data) 60 | { 61 | Console.WriteLine(user.FirstName); 62 | } 63 | } 64 | } 65 | 66 | private static void GetCarDetails(CarManager carManager) 67 | { 68 | var result = carManager.GetCarDetails(); 69 | 70 | if (result.Success) 71 | { 72 | foreach (var car in result.Data) 73 | { 74 | Console.WriteLine($"CarName: {car.CarName}, BrandName: {car.BrandName}, ColorName: {car.ColorName}"); 75 | } 76 | } 77 | 78 | } 79 | 80 | private static void BrandGetAll(BrandManager brandManager) 81 | { 82 | foreach (var brand in brandManager.GetAll().Data) 83 | { 84 | Console.WriteLine(brand.BrandName); 85 | } 86 | } 87 | 88 | private static void CarsGetAll(CarManager carManager) 89 | { 90 | carManager.Add(new Car() 91 | { 92 | CarName = "Mondeo", 93 | DailyPrice = 550, 94 | BrandId = 8, 95 | Description = "Dizel", 96 | ColorId = 5, 97 | ModelYear = 2018 98 | }); 99 | 100 | foreach (var car in carManager.GetAll().Data) 101 | { 102 | Console.WriteLine("Car Name: {0}", car.CarName); 103 | } 104 | } 105 | 106 | private static void CarsDailyPrice(CarManager carManager) 107 | { 108 | foreach (var car in carManager.GetByDailyPrice(2, 400).Data) 109 | { 110 | Console.WriteLine(car.Description + " DailyPrice: " + car.DailyPrice); 111 | } 112 | } 113 | 114 | private static void CarsColorId(CarManager carManager) 115 | { 116 | foreach (var car in carManager.GetCarsByColorId(1).Data) 117 | { 118 | Console.WriteLine(car.Description + " ColorId: " + car.ColorId); 119 | } 120 | } 121 | 122 | private static void CarsBrandId(CarManager carManager) 123 | { 124 | foreach (var car in carManager.GetCarsByBrandId(2).Data) 125 | { 126 | Console.WriteLine(car.Description + " BrandId: " + car.BrandId); 127 | } 128 | } 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /WebAPI/Controllers/CarsController.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Entities.Concrete; 3 | using Microsoft.AspNetCore.Mvc; 4 | 5 | namespace WebAPI.Controllers 6 | { 7 | [Route("api/[controller]")] 8 | [ApiController] 9 | public class CarsController : ControllerBase 10 | { 11 | private readonly ICarService _carService; 12 | 13 | public CarsController(ICarService carService) 14 | { 15 | _carService = carService; 16 | } 17 | 18 | [HttpPost("add")] 19 | public IActionResult Add(Car car) 20 | { 21 | var result = _carService.Add(car); 22 | if (result.Success) 23 | { 24 | return Ok(result); 25 | } 26 | 27 | return BadRequest(result); 28 | } 29 | 30 | [HttpPost("delete")] 31 | public IActionResult Delete(Car car) 32 | { 33 | var result = _carService.Delete(car); 34 | if (result.Success) 35 | { 36 | return Ok(result); 37 | } 38 | 39 | return BadRequest(result); 40 | } 41 | 42 | [HttpPost("update")] 43 | public IActionResult Update(Car car) 44 | { 45 | var result = _carService.Update(car); 46 | if (result.Success) 47 | { 48 | return Ok(result); 49 | } 50 | 51 | return BadRequest(result); 52 | } 53 | 54 | [HttpGet("getall")] 55 | public IActionResult GetAll() 56 | { 57 | var result= _carService.GetAll(); 58 | if(result.Success) 59 | { 60 | return Ok(result); 61 | } 62 | 63 | return BadRequest(result.Message); 64 | } 65 | 66 | [HttpGet("getbyid")] 67 | public IActionResult GetById(int id) 68 | { 69 | var result = _carService.GetCarsByCarId(id); 70 | if(result.Success) 71 | { 72 | return Ok(result); 73 | } 74 | 75 | return BadRequest(result.Message); 76 | } 77 | 78 | [HttpGet("getbybrand")] 79 | public IActionResult GetByBrand(int brandId) 80 | { 81 | var result = _carService.GetCarsByBrandId(brandId); 82 | if(result.Success) 83 | { 84 | return Ok(result); 85 | } 86 | 87 | return BadRequest(result.Message); 88 | } 89 | 90 | [HttpGet("getcardetails")] 91 | public IActionResult GetCarDetails() 92 | { 93 | var result = _carService.GetCarDetails(); 94 | if (result.Success) 95 | { 96 | return Ok(result); 97 | } 98 | return BadRequest(result); 99 | } 100 | 101 | [HttpGet("getcardetailsbycarid")] 102 | public IActionResult GetCarDetailsByCarId(int carId) 103 | { 104 | var result = _carService.GetCarDetailsByCarId(carId); 105 | if (result.Success) 106 | { 107 | return Ok(result); 108 | } 109 | return BadRequest(result); 110 | } 111 | 112 | [HttpGet("getcardetailsbybrandid")] 113 | public IActionResult GetCarDetailsByBrandId(int brandId) 114 | { 115 | var result = _carService.GetCarDetailsByBrandId(brandId); 116 | if (result.Success) 117 | { 118 | return Ok(result); 119 | } 120 | return BadRequest(result); 121 | } 122 | 123 | [HttpGet("getcardetailsbycolorid")] 124 | public IActionResult GetCarDetailsByColorId(int colorId) 125 | { 126 | var result = _carService.GetCarDetailsByColorId(colorId); 127 | if (result.Success) 128 | { 129 | return Ok(result); 130 | } 131 | return BadRequest(result); 132 | } 133 | 134 | [HttpGet("getcarlistbrandidcolorid")] 135 | public IActionResult GetCarListBrandIdColorId(int brandId, int colorId) 136 | { 137 | var result = _carService.GetCarListBrandIdColorId(brandId, colorId); 138 | if (result.Success) 139 | { 140 | return Ok(result); 141 | } 142 | return BadRequest(result); 143 | } 144 | 145 | [HttpPost("transaction")] 146 | public IActionResult TransactionTest(Car car) 147 | { 148 | var result = _carService.AddTransactionalTest(car); 149 | if (result.Success) 150 | { 151 | return Ok(result.Message); 152 | } 153 | 154 | return BadRequest(result.Message); 155 | } 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /Business/Concrete/CarManager.cs: -------------------------------------------------------------------------------- 1 | using Business.Abstract; 2 | using Business.Constants; 3 | using Business.ValidationRules.FluentValidation; 4 | using Core.Aspects.Autofac.Validation; 5 | using Core.Utilities.Results; 6 | using DataAccess.Abstract; 7 | using Entities.Concrete; 8 | using Entities.DTOs; 9 | using System; 10 | using System.Collections.Generic; 11 | using System.Linq; 12 | using Core.Utilities.Business; 13 | using Business.BusinessAspects.Autofac; 14 | using Core.Aspects.Autofac.Caching; 15 | using Core.Aspects.Autofac.Transaction; 16 | using System.Threading; 17 | using Core.Aspects.Autofac.Performance; 18 | 19 | namespace Business.Concrete 20 | { 21 | public class CarManager : ICarService 22 | { 23 | private readonly ICarDal _carDal; 24 | private readonly IBrandService _brandService; 25 | 26 | public CarManager(ICarDal carDal, IBrandService brandService) 27 | { 28 | _carDal = carDal; 29 | _brandService = brandService; 30 | } 31 | 32 | [PerformanceAspect(5)] 33 | //[CacheAspect] 34 | public IDataResult> GetAll() 35 | { 36 | if (DateTime.Now.Hour == 22) 37 | { 38 | return new ErrorDataResult>(Messages.MaintenanceTime); 39 | } 40 | 41 | return new SuccessDataResult>(_carDal.GetAll(), Messages.CarsListed); 42 | } 43 | 44 | [CacheAspect] 45 | public IDataResult GetCarsByCarId(int carId) 46 | { 47 | return new SuccessDataResult(_carDal.Get(c => c.CarId == carId)); 48 | } 49 | 50 | [CacheAspect] 51 | public IDataResult> GetCarsByBrandId(int brandId) 52 | { 53 | return new SuccessDataResult>(_carDal.GetAll(c => c.BrandId == brandId)); 54 | } 55 | 56 | [CacheAspect] 57 | public IDataResult> GetCarsByColorId(int colorId) 58 | { 59 | return new SuccessDataResult>(_carDal.GetAll(c => c.ColorId == colorId)); 60 | } 61 | 62 | public IDataResult> GetByDailyPrice(decimal min, decimal max) 63 | { 64 | return new SuccessDataResult>(_carDal.GetAll(c => c.DailyPrice >= min && c.DailyPrice <= max)); 65 | } 66 | 67 | [CacheRemoveAspect("ICarService.Get")] 68 | [SecuredOperation("car.add,admin")] 69 | [ValidationAspect(typeof(CarValidator))] 70 | public IResult Add(Car car) 71 | { 72 | IResult result = BusinessRules.Run(CheckIfCarNameExists(car.CarName), 73 | CheckIfCarCountBrandCorrect(car.BrandId), CheckIfBrandLimitExceded()); 74 | 75 | if (result != null) 76 | { 77 | return result; 78 | } 79 | 80 | _carDal.Add(car); 81 | return new SuccessResult(Messages.CarAdded); 82 | } 83 | 84 | [CacheRemoveAspect("ICarService.Get")] 85 | public IResult Update(Car car) 86 | { 87 | _carDal.Update(car); 88 | return new SuccessResult(Messages.CarUpdated); 89 | } 90 | 91 | [CacheRemoveAspect("ICarService.Get")] 92 | public IResult Delete(Car car) 93 | { 94 | _carDal.Delete(car); 95 | return new SuccessResult(Messages.CarDeleted); 96 | } 97 | 98 | [CacheAspect] 99 | public IDataResult> GetCarDetails() 100 | { 101 | Thread.Sleep(2000); 102 | return new SuccessDataResult>(_carDal.GetCarDetails()); 103 | } 104 | 105 | [CacheAspect] 106 | public IDataResult> GetCarDetailsByCarId(int carId) 107 | { 108 | return new SuccessDataResult>(_carDal.GetCarDetails(c => c.CarId == carId)); 109 | } 110 | 111 | [CacheAspect] 112 | public IDataResult> GetCarDetailsByBrandId(int brandId) 113 | { 114 | return new SuccessDataResult>(_carDal.GetCarDetails(c => c.BrandId == brandId)); 115 | } 116 | 117 | [CacheAspect] 118 | public IDataResult> GetCarDetailsByColorId(int colorId) 119 | { 120 | return new SuccessDataResult>(_carDal.GetCarDetails(c => c.ColorId == colorId)); 121 | } 122 | 123 | [TransactionScopeAspect] 124 | public IResult AddTransactionalTest(Car car) 125 | { 126 | _carDal.Update(car); 127 | _carDal.Add(car); 128 | return new SuccessResult(Messages.CarUpdated); 129 | } 130 | 131 | private IResult CheckIfCarCountBrandCorrect(int brandId) 132 | { 133 | var result = _carDal.GetAll(c => c.BrandId == brandId).Count; 134 | if (result >= 15) 135 | { 136 | return new ErrorResult(Messages.CarCountOfBrandError); 137 | } 138 | 139 | return new SuccessResult(); 140 | } 141 | private IResult CheckIfCarNameExists(string carName) 142 | { 143 | var result = _carDal.GetAll(c => c.CarName == carName).Any(); 144 | if (result) 145 | { 146 | return new ErrorResult(Messages.CarNameAlreadyExists); 147 | } 148 | 149 | return new SuccessResult(); 150 | } 151 | 152 | private IResult CheckIfBrandLimitExceded() 153 | { 154 | var result = _brandService.GetAll().Data.Count; 155 | if (result > 15) 156 | { 157 | return new ErrorResult(Messages.BrandLimitExceded); 158 | } 159 | 160 | return new SuccessResult(); 161 | } 162 | 163 | public IDataResult> GetCarListBrandIdColorId(int brandId, int colorId) 164 | { 165 | var results = _carDal.GetCarDetails(c => c.ColorId == colorId && c.BrandId == brandId); 166 | if (results.Count == 0) 167 | { 168 | return new ErrorDataResult>(new List()); 169 | } 170 | return new SuccessDataResult>(results); 171 | } 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /.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 --------------------------------------------------------------------------------