├── .config └── dotnet-tools.json ├── .csharpierrc ├── .editorconfig ├── .gitattributes ├── .github └── workflows │ └── dotnet.yml ├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── RentACarProject.sln ├── RentACarProject.sln.DotSettings ├── docs └── Semantic Commit Messages.md ├── src └── rentACar │ ├── Application │ ├── Application.csproj │ ├── ApplicationServiceRegistration.cs │ ├── Features │ │ ├── AdditionalServices │ │ │ ├── Commands │ │ │ │ ├── Create │ │ │ │ │ ├── CreateAdditionalServiceCommand.cs │ │ │ │ │ ├── CreateAdditionalServiceCommandValidator.cs │ │ │ │ │ └── CreatedAdditionalServiceResponse.cs │ │ │ │ ├── Delete │ │ │ │ │ ├── DeleteAdditionalServiceCommand.cs │ │ │ │ │ └── DeletedAdditionalServiceResponse.cs │ │ │ │ └── Update │ │ │ │ │ ├── UpdateAdditionalServiceCommand.cs │ │ │ │ │ ├── UpdateAdditionalServiceCommandValidator.cs │ │ │ │ │ └── UpdatedAdditionalServiceResponse.cs │ │ │ ├── Constants │ │ │ │ ├── AdditionalServicesMessages.cs │ │ │ │ └── AdditionalServicesOperationClaims.cs │ │ │ ├── Profiles │ │ │ │ └── MappingProfiles.cs │ │ │ ├── Queries │ │ │ │ ├── GetById │ │ │ │ │ ├── GetByIdAdditionalServiceQuery.cs │ │ │ │ │ └── GetByIdAdditionalServiceResponse.cs │ │ │ │ └── GetList │ │ │ │ │ ├── GetListAdditionalServiceListItemDto.cs │ │ │ │ │ └── GetListAdditionalServiceQuery.cs │ │ │ └── Rules │ │ │ │ └── AdditionalServiceBusinessRules.cs │ │ ├── Auth │ │ │ ├── Commands │ │ │ │ ├── EnableEmailAuthenticator │ │ │ │ │ └── EnableEmailAuthenticatorCommand.cs │ │ │ │ ├── EnableOtpAuthenticator │ │ │ │ │ ├── EnableOtpAuthenticatorCommand.cs │ │ │ │ │ └── EnabledOtpAuthenticatorResponse.cs │ │ │ │ ├── Login │ │ │ │ │ ├── LoggedResponse.cs │ │ │ │ │ ├── LoginCommand.cs │ │ │ │ │ └── LoginCommandValidator.cs │ │ │ │ ├── RefleshToken │ │ │ │ │ ├── RefreshTokenCommand.cs │ │ │ │ │ └── RefreshedTokensResponse.cs │ │ │ │ ├── Register │ │ │ │ │ ├── RegisterCommand.cs │ │ │ │ │ ├── RegisterCommandValidator.cs │ │ │ │ │ └── RegisteredResponse.cs │ │ │ │ ├── RevokeToken │ │ │ │ │ ├── RevokeTokenCommand.cs │ │ │ │ │ └── RevokedTokenResponse.cs │ │ │ │ ├── VerifyEmailAuthenticator │ │ │ │ │ └── VerifyEmailAuthenticatorCommand.cs │ │ │ │ └── VerifyOtpAuthenticator │ │ │ │ │ └── VerifyOtpAuthenticatorCommand.cs │ │ │ ├── Constants │ │ │ │ └── AuthMessages.cs │ │ │ ├── Profiles │ │ │ │ └── MappingProfiles.cs │ │ │ └── Rules │ │ │ │ └── AuthBusinessRules.cs │ │ ├── Brands │ │ │ ├── Commands │ │ │ │ ├── Create │ │ │ │ │ ├── CreateBrandCommand.cs │ │ │ │ │ ├── CreateBrandCommandValidator.cs │ │ │ │ │ ├── CreateBulkBrandCommand.cs │ │ │ │ │ └── CreatedBrandResponse.cs │ │ │ │ ├── Delete │ │ │ │ │ ├── DeleteBrandCommand.cs │ │ │ │ │ └── DeletedBrandResponse.cs │ │ │ │ └── Update │ │ │ │ │ ├── UpdateBrandCommand.cs │ │ │ │ │ ├── UpdateBrandCommandValidator.cs │ │ │ │ │ └── UpdatedBrandResponse.cs │ │ │ ├── Constants │ │ │ │ ├── BrandsMessages.cs │ │ │ │ └── BrandsOperationClaims.cs │ │ │ ├── Profiles │ │ │ │ └── MappingProfiles.cs │ │ │ ├── Queries │ │ │ │ ├── GetById │ │ │ │ │ ├── GetByIdBrandQuery.cs │ │ │ │ │ └── GetByIdBrandResponse.cs │ │ │ │ └── GetList │ │ │ │ │ ├── GetListBrandListItemDto.cs │ │ │ │ │ └── GetListBrandQuery.cs │ │ │ └── Rules │ │ │ │ └── BrandBusinessRules.cs │ │ ├── CarDamages │ │ │ ├── Commands │ │ │ │ ├── Create │ │ │ │ │ ├── CreateCarDamageCommand.cs │ │ │ │ │ ├── CreateCarDamageCommandValidator.cs │ │ │ │ │ └── CreatedCarDamageResponse.cs │ │ │ │ ├── Delete │ │ │ │ │ ├── DeleteCarDamageCommand.cs │ │ │ │ │ └── DeletedCarDamageResponse.cs │ │ │ │ └── Update │ │ │ │ │ ├── UpdateCarDamageCommand.cs │ │ │ │ │ ├── UpdateCarDamageCommandValidator.cs │ │ │ │ │ └── UpdatedCarDamageResponse.cs │ │ │ ├── Constants │ │ │ │ ├── CarDamagesMessages.cs │ │ │ │ └── CarDamagesOperationClaims.cs │ │ │ ├── Profiles │ │ │ │ └── MappingProfiles.cs │ │ │ ├── Queries │ │ │ │ ├── GetById │ │ │ │ │ ├── GetByIdCarDamageQuery.cs │ │ │ │ │ └── GetByIdCarDamageResponse.cs │ │ │ │ ├── GetList │ │ │ │ │ ├── GetListCarDamageListItemDto.cs │ │ │ │ │ └── GetListCarDamageQuery.cs │ │ │ │ └── GetListByCarId │ │ │ │ │ ├── GetListByCarIdCarDamageListItemDto.cs │ │ │ │ │ └── GetListByCarIdCarDamageQuery.cs │ │ │ └── Rules │ │ │ │ └── CarDamageBusinessRules.cs │ │ ├── Cars │ │ │ ├── Commands │ │ │ │ ├── Create │ │ │ │ │ ├── CreateCarCommand.cs │ │ │ │ │ ├── CreateCarCommandValidator.cs │ │ │ │ │ └── CreatedCarResponse.cs │ │ │ │ ├── Delete │ │ │ │ │ ├── DeleteCarCommand.cs │ │ │ │ │ └── DeletedCarResponse.cs │ │ │ │ ├── DeliverRental │ │ │ │ │ ├── DeliverRentalCarCommand.cs │ │ │ │ │ └── DeliveredCarResponse.cs │ │ │ │ ├── Maintain │ │ │ │ │ ├── MaintainCarCommand.cs │ │ │ │ │ └── MaintainedCarResponse.cs │ │ │ │ └── Update │ │ │ │ │ ├── UpdateCarCommand.cs │ │ │ │ │ ├── UpdateCarCommandValidator.cs │ │ │ │ │ └── UpdatedCarResponse.cs │ │ │ ├── Constants │ │ │ │ ├── CarsMessages.cs │ │ │ │ └── CarsOperationClaims.cs │ │ │ ├── Profiles │ │ │ │ └── MappingProfiles.cs │ │ │ ├── Queries │ │ │ │ ├── GetById │ │ │ │ │ ├── GetByIdCarQuery.cs │ │ │ │ │ └── GetByIdCarResponse.cs │ │ │ │ ├── GetList │ │ │ │ │ ├── GetListCarListItemDto.cs │ │ │ │ │ └── GetListCarQuery.cs │ │ │ │ └── GetListByDynamic │ │ │ │ │ ├── GetListByDynamicCarListItemDto.cs │ │ │ │ │ └── GetListByDynamicCarQuery.cs │ │ │ ├── Rules │ │ │ │ └── CarBusinessRules.cs │ │ │ └── Validations │ │ │ │ └── CarCustomValidationRules.cs │ │ ├── Colors │ │ │ ├── Commands │ │ │ │ ├── Create │ │ │ │ │ ├── CreateColorCommand.cs │ │ │ │ │ ├── CreateColorCommandValidator.cs │ │ │ │ │ └── CreatedColorResponse.cs │ │ │ │ ├── Delete │ │ │ │ │ ├── DeleteColorCommand.cs │ │ │ │ │ └── DeletedColorResponse.cs │ │ │ │ └── Update │ │ │ │ │ ├── UpdateColorCommand.cs │ │ │ │ │ ├── UpdateColorCommandValidator.cs │ │ │ │ │ └── UpdatedColorResponse.cs │ │ │ ├── Constants │ │ │ │ ├── ColorsMessages.cs │ │ │ │ └── ColorsOperationClaims.cs │ │ │ ├── Profiles │ │ │ │ └── MappingProfiles.cs │ │ │ ├── Queries │ │ │ │ ├── GetById │ │ │ │ │ ├── GetByIdColorQuery.cs │ │ │ │ │ └── GetByIdColorResponse.cs │ │ │ │ └── GetList │ │ │ │ │ ├── GetListColorListItemDto.cs │ │ │ │ │ └── GetListColorQuery.cs │ │ │ └── Rules │ │ │ │ └── ColorBusinessRules.cs │ │ ├── CorporateCustomers │ │ │ ├── Commands │ │ │ │ ├── Create │ │ │ │ │ ├── CreateCorporateCustomerCommand.cs │ │ │ │ │ ├── CreateCorporateCustomerCommandValidator.cs │ │ │ │ │ └── CreatedCorporateCustomerResponse.cs │ │ │ │ ├── Delete │ │ │ │ │ ├── DeleteCorporateCustomerCommand.cs │ │ │ │ │ └── DeletedCorporateCustomerResponse.cs │ │ │ │ └── Update │ │ │ │ │ ├── UpdateCorporateCustomerCommand.cs │ │ │ │ │ ├── UpdateCorporateCustomerCommandValidator.cs │ │ │ │ │ └── UpdatedCorporateCustomerResponse.cs │ │ │ ├── Constants │ │ │ │ ├── CorporateCustomersMessages.cs │ │ │ │ └── CorporateCustomersOperationClaims.cs │ │ │ ├── Profiles │ │ │ │ └── MappingProfiles.cs │ │ │ ├── Queries │ │ │ │ ├── GetByCustomerId │ │ │ │ │ ├── GetByCustomerIdCorporateCustomerQuery.cs │ │ │ │ │ └── GetByCustomerIdCorporateCustomerResponse.cs │ │ │ │ ├── GetById │ │ │ │ │ ├── GetByIdCorporateCustomerQuery.cs │ │ │ │ │ └── GetByIdCorporateCustomerResponse.cs │ │ │ │ └── GetList │ │ │ │ │ ├── GetListCorporateCustomerListItemDto.cs │ │ │ │ │ └── GetListCorporateCustomerQuery.cs │ │ │ └── Rules │ │ │ │ └── CorporateCustomerBusinessRules.cs │ │ ├── Customers │ │ │ ├── Commands │ │ │ │ ├── Create │ │ │ │ │ ├── CreateCustomerCommand.cs │ │ │ │ │ ├── CreateCustomerCommandValidator.cs │ │ │ │ │ └── CreatedCustomerResponse.cs │ │ │ │ ├── Delete │ │ │ │ │ ├── DeleteCustomerCommand.cs │ │ │ │ │ └── DeletedCustomerResponse.cs │ │ │ │ └── Update │ │ │ │ │ ├── UpdateCustomerCommand.cs │ │ │ │ │ ├── UpdateCustomerCommandValidator.cs │ │ │ │ │ └── UpdatedCustomerResponse.cs │ │ │ ├── Constants │ │ │ │ ├── CustomersMessages.cs │ │ │ │ └── CustomersOperationClaims.cs │ │ │ ├── Profiles │ │ │ │ └── MappingProfiles.cs │ │ │ ├── Queries │ │ │ │ ├── GetById │ │ │ │ │ ├── GetByIdCustomerQuery.cs │ │ │ │ │ └── GetByIdCustomerResponse.cs │ │ │ │ ├── GetByUserId │ │ │ │ │ ├── GetByUserIdCustomerQuery.cs │ │ │ │ │ └── GetByUserIdCustomerResponse.cs │ │ │ │ └── GetList │ │ │ │ │ ├── GetListCustomerListItemDto.cs │ │ │ │ │ └── GetListCustomerQuery.cs │ │ │ └── Rules │ │ │ │ └── CustomerBusinessRules.cs │ │ ├── FindeksCreditRates │ │ │ ├── Commands │ │ │ │ ├── Create │ │ │ │ │ ├── CreateFindeksCreditRateCommand.cs │ │ │ │ │ ├── CreateFindeksCreditRateCommandValidator.cs │ │ │ │ │ └── CreatedFindeksCreditRateResponse.cs │ │ │ │ ├── Delete │ │ │ │ │ ├── DeleteFindeksCreditRateCommand.cs │ │ │ │ │ └── DeletedFindeksCreditRateResponse.cs │ │ │ │ ├── Update │ │ │ │ │ ├── UpdateFindeksCreditRateCommand.cs │ │ │ │ │ ├── UpdateFindeksCreditRateCommandValidator.cs │ │ │ │ │ └── UpdatedFindeksCreditRateResponse.cs │ │ │ │ ├── UpdateByUserIdFromService │ │ │ │ │ ├── UpdateByUserIdFindeksCreditRateFromServiceCommand.cs │ │ │ │ │ ├── UpdateByUserIdFindeksCreditRateFromServiceCommandValidator.cs │ │ │ │ │ └── UpdateByUserIdFindeksCreditRateFromServiceResponse.cs │ │ │ │ └── UpdateFromService │ │ │ │ │ ├── UpdateFindeksCreditRateFromServiceCommand.cs │ │ │ │ │ ├── UpdateFindeksCreditRateFromServiceCommandValidator.cs │ │ │ │ │ └── UpdateFindeksCreditRateFromServiceResponse.cs │ │ │ ├── Constants │ │ │ │ ├── FindeksCreditRatesMessages.cs │ │ │ │ └── FindeksCreditRatesOperationClaims.cs │ │ │ ├── Profiles │ │ │ │ └── MappingProfiles.cs │ │ │ ├── Queries │ │ │ │ ├── GetByCustomerIdFindeksCreditRate │ │ │ │ │ ├── GetByCustomerIdFindeksCreditRateQuery.cs │ │ │ │ │ └── GetByCustomerIdFindeksCreditRateResponse.cs │ │ │ │ ├── GetByIdFindeksCreditRate │ │ │ │ │ ├── GetByIdFindeksCreditRateQuery.cs │ │ │ │ │ └── GetByIdFindeksCreditRateResponse.cs │ │ │ │ └── GetListFindeksCreditRate │ │ │ │ │ ├── GetListFindeksCreditRateListItemDto.cs │ │ │ │ │ └── GetListFindeksCreditRateQuery.cs │ │ │ └── Rules │ │ │ │ └── FindeksCreditRateBusinessRules.cs │ │ ├── Fuels │ │ │ ├── Commands │ │ │ │ ├── Create │ │ │ │ │ ├── CreateFuelCommand.cs │ │ │ │ │ ├── CreateFuelCommandValidator.cs │ │ │ │ │ └── CreatedFuelResponse.cs │ │ │ │ ├── Delete │ │ │ │ │ ├── DeleteFuelCommand.cs │ │ │ │ │ └── DeletedFuelResponse.cs │ │ │ │ └── Update │ │ │ │ │ ├── UpdateFuelCommand.cs │ │ │ │ │ ├── UpdateFuelCommandValidator.cs │ │ │ │ │ └── UpdatedFuelResponse.cs │ │ │ ├── Constants │ │ │ │ ├── FuelsMessages.cs │ │ │ │ └── FuelsOperationClaims.cs │ │ │ ├── Profiles │ │ │ │ └── MappingProfiles.cs │ │ │ ├── Queries │ │ │ │ ├── GetById │ │ │ │ │ ├── GetByIdFuelQuery.cs │ │ │ │ │ └── GetByIdFuelResponse.cs │ │ │ │ └── GetList │ │ │ │ │ ├── GetListFuelListItemDto.cs │ │ │ │ │ └── GetListFuelQuery.cs │ │ │ └── Rules │ │ │ │ └── FuelBusinessRules.cs │ │ ├── IndividualCustomers │ │ │ ├── Commands │ │ │ │ ├── Create │ │ │ │ │ ├── CreateIndividualCustomerCommand.cs │ │ │ │ │ ├── CreateIndividualCustomerCommandValidator.cs │ │ │ │ │ └── CreatedIndividualCustomerResponse.cs │ │ │ │ ├── Delete │ │ │ │ │ ├── DeleteIndividualCustomerCommand.cs │ │ │ │ │ └── DeletedIndividualCustomerResponse.cs │ │ │ │ └── Update │ │ │ │ │ ├── UpdateIndividualCustomerCommand.cs │ │ │ │ │ ├── UpdateIndividualCustomerCommandValidator.cs │ │ │ │ │ └── UpdatedIndividualCustomerResponse.cs │ │ │ ├── Constants │ │ │ │ ├── IndividualCustomersMessages.cs │ │ │ │ └── IndividualCustomersOperationClaims.cs │ │ │ ├── Profiles │ │ │ │ └── MappingProfiles.cs │ │ │ ├── Queries │ │ │ │ ├── GetByCustomerId │ │ │ │ │ ├── GetByCustomerIdIndividualCustomerQuery.cs │ │ │ │ │ └── GetByCustomerIdIndividualCustomerResponse.cs │ │ │ │ ├── GetById │ │ │ │ │ ├── GetByIdIndividualCustomerQuery.cs │ │ │ │ │ └── GetByIdIndividualCustomerResponse.cs │ │ │ │ └── GetList │ │ │ │ │ ├── GetListIndividualCustomerListItemDto.cs │ │ │ │ │ └── GetListIndividualCustomerQuery.cs │ │ │ └── Rules │ │ │ │ └── IndividualCustomerBusinessRules.cs │ │ ├── Invoices │ │ │ ├── Commands │ │ │ │ ├── Create │ │ │ │ │ ├── CreateInvoiceCommand.cs │ │ │ │ │ ├── CreateInvoiceCommandValidator.cs │ │ │ │ │ └── CreatedInvoiceResponse.cs │ │ │ │ ├── Delete │ │ │ │ │ ├── DeleteInvoiceCommand.cs │ │ │ │ │ └── DeletedInvoiceResponse.cs │ │ │ │ └── Update │ │ │ │ │ ├── UpdateInvoiceCommand.cs │ │ │ │ │ ├── UpdateInvoiceCommandValidator.cs │ │ │ │ │ └── UpdatedInvoiceResponse.cs │ │ │ ├── Constants │ │ │ │ ├── InvoicesMessages.cs │ │ │ │ └── InvoicesOperationClaims.cs │ │ │ ├── Profiles │ │ │ │ └── MappingProfiles.cs │ │ │ ├── Queries │ │ │ │ ├── GetById │ │ │ │ │ ├── GetByIdInvoiceQuery.cs │ │ │ │ │ └── GetByIdInvoiceResponse.cs │ │ │ │ ├── GetList │ │ │ │ │ ├── GetListInvoiceListItemDto.cs │ │ │ │ │ └── GetListInvoiceQuery.cs │ │ │ │ ├── GetListByCustomer │ │ │ │ │ ├── GetListByCustomerInvoiceListItemDto.cs │ │ │ │ │ └── GetListByCustomerInvoiceQuery.cs │ │ │ │ └── GetListByDates │ │ │ │ │ ├── GetListByDatesInvoiceListItemDto.cs │ │ │ │ │ └── GetListByDatesInvoiceQuery.cs │ │ │ └── Rules │ │ │ │ └── InvoiceBusinessRules.cs │ │ ├── Models │ │ │ ├── Commands │ │ │ │ ├── Create │ │ │ │ │ ├── CreateModelCommand.cs │ │ │ │ │ ├── CreateModelCommandValidator.cs │ │ │ │ │ └── CreatedModelResponse.cs │ │ │ │ ├── Delete │ │ │ │ │ ├── DeleteModelCommand.cs │ │ │ │ │ └── DeletedModelResponse.cs │ │ │ │ └── Update │ │ │ │ │ ├── UpdateModelCommand.cs │ │ │ │ │ ├── UpdateModelCommandValidator.cs │ │ │ │ │ └── UpdatedModelResponse.cs │ │ │ ├── Constants │ │ │ │ ├── ModelsMessages.cs │ │ │ │ └── ModelsOperationClaims.cs │ │ │ ├── Profiles │ │ │ │ └── MappingProfiles.cs │ │ │ ├── Queries │ │ │ │ ├── GetById │ │ │ │ │ ├── GetByIdModelQuery.cs │ │ │ │ │ └── GetByIdModelResponse.cs │ │ │ │ ├── GetList │ │ │ │ │ ├── GetListModelListItemDto.cs │ │ │ │ │ └── GetListModelQuery.cs │ │ │ │ └── GetListByDynamic │ │ │ │ │ ├── GetListByDynamicModelListItemDto.cs │ │ │ │ │ └── GetListByDynamicModelQuery.cs │ │ │ └── Rules │ │ │ │ └── ModelBusinessRules.cs │ │ ├── OperationClaims │ │ │ ├── Commands │ │ │ │ ├── Create │ │ │ │ │ ├── CreateOperationClaimCommand.cs │ │ │ │ │ ├── CreateOperationClaimCommandValidator.cs │ │ │ │ │ └── CreatedOperationClaimResponse.cs │ │ │ │ ├── Delete │ │ │ │ │ ├── DeleteOperationClaimCommand.cs │ │ │ │ │ └── DeletedOperationClaimResponse.cs │ │ │ │ └── Update │ │ │ │ │ ├── UpdateOperationClaimCommand.cs │ │ │ │ │ ├── UpdateOperationClaimCommandValidator.cs │ │ │ │ │ └── UpdatedOperationClaimResponse.cs │ │ │ ├── Constants │ │ │ │ ├── GeneralOperationClaims.cs │ │ │ │ ├── OperationClaimsMessages.cs │ │ │ │ └── OperationClaimsOperationClaims.cs │ │ │ ├── Profiles │ │ │ │ └── MappingProfiles.cs │ │ │ ├── Queries │ │ │ │ ├── GetById │ │ │ │ │ ├── GetByIdOperationClaimQuery.cs │ │ │ │ │ └── GetByIdOperationClaimResponse.cs │ │ │ │ └── GetList │ │ │ │ │ ├── GetListOperationClaimListItemDto.cs │ │ │ │ │ └── GetListOperationClaimQuery.cs │ │ │ └── Rules │ │ │ │ └── OperationClaimBusinessRules.cs │ │ ├── RentalBranches │ │ │ ├── Commands │ │ │ │ ├── Create │ │ │ │ │ ├── CreateRentalBranchCommand.cs │ │ │ │ │ ├── CreateRentalBranchCommandValidator.cs │ │ │ │ │ └── CreatedRentalBranchResponse.cs │ │ │ │ ├── Delete │ │ │ │ │ ├── DeleteRentalBranchCommand.cs │ │ │ │ │ └── DeletedRentalBranchResponse.cs │ │ │ │ └── Update │ │ │ │ │ ├── UpdateRentalBranchCommand.cs │ │ │ │ │ ├── UpdateRentalBranchCommandValidator.cs │ │ │ │ │ └── UpdatedRentalBranchResponse.cs │ │ │ ├── Constants │ │ │ │ ├── RentalBranchesMessages.cs │ │ │ │ └── RentalBranchesOperationClaims.cs │ │ │ ├── Profiles │ │ │ │ └── MappingProfiles.cs │ │ │ ├── Queries │ │ │ │ ├── GetById │ │ │ │ │ ├── GetByIdRentalBranchQuery.cs │ │ │ │ │ └── GetByIdRentalBranchResponse.cs │ │ │ │ └── GetList │ │ │ │ │ ├── GetListRentalBranchListItemDto.cs │ │ │ │ │ └── GetListRentalBranchQuery.cs │ │ │ └── Rules │ │ │ │ └── RentalBranchBusinessRules.cs │ │ ├── Rentals │ │ │ ├── Commands │ │ │ │ ├── Create │ │ │ │ │ ├── CreateRentalCommand.cs │ │ │ │ │ ├── CreateRentalCommandValidator.cs │ │ │ │ │ └── CreatedRentalResponse.cs │ │ │ │ ├── Delete │ │ │ │ │ ├── DeleteRentalCommand.cs │ │ │ │ │ └── DeletedRentalResponse.cs │ │ │ │ ├── PickUp │ │ │ │ │ ├── PickUpRentalCommand.cs │ │ │ │ │ ├── PickUpRentalCommandValidator.cs │ │ │ │ │ └── PickUpRentalResponse.cs │ │ │ │ └── Update │ │ │ │ │ ├── UpdateRentalCommand.cs │ │ │ │ │ ├── UpdateRentalCommandValidator.cs │ │ │ │ │ └── UpdatedRentalResponse.cs │ │ │ ├── Constants │ │ │ │ ├── RentalsMessages.cs │ │ │ │ └── RentalsOperationClaims.cs │ │ │ ├── Profiles │ │ │ │ └── MappingProfiles.cs │ │ │ ├── Queries │ │ │ │ ├── GetById │ │ │ │ │ ├── GetByIdRentalQuery.cs │ │ │ │ │ └── GetByIdRentalResponse.cs │ │ │ │ └── GetList │ │ │ │ │ ├── GetListRentalListItemDto.cs │ │ │ │ │ └── GetListRentalQuery.cs │ │ │ └── Rules │ │ │ │ └── RentalBusinessRules.cs │ │ ├── Transmissions │ │ │ ├── Commands │ │ │ │ ├── Create │ │ │ │ │ ├── CreateTransmissionCommand.cs │ │ │ │ │ ├── CreateTransmissionCommandValidator.cs │ │ │ │ │ └── CreatedTransmissionResponse.cs │ │ │ │ ├── Delete │ │ │ │ │ ├── DeleteTransmissionCommand.cs │ │ │ │ │ └── DeletedTransmissionResponse.cs │ │ │ │ └── Update │ │ │ │ │ ├── UpdateTransmissionCommand.cs │ │ │ │ │ ├── UpdateTransmissionCommandValidator.cs │ │ │ │ │ └── UpdatedTransmissionResponse.cs │ │ │ ├── Constants │ │ │ │ ├── TransmissionsMessages.cs │ │ │ │ └── TransmissionsOperationClaims.cs │ │ │ ├── Profiles │ │ │ │ └── MappingProfiles.cs │ │ │ ├── Queries │ │ │ │ ├── GetById │ │ │ │ │ ├── GetByIdTransmissionQuery.cs │ │ │ │ │ └── GetByIdTransmissionResponse.cs │ │ │ │ └── GetList │ │ │ │ │ ├── GetListTransmissionListItemDto.cs │ │ │ │ │ └── GetListTransmissionQuery.cs │ │ │ └── Rules │ │ │ │ └── TransmissionBusinessRules.cs │ │ ├── UserOperationClaims │ │ │ ├── Commands │ │ │ │ ├── Create │ │ │ │ │ ├── CreateUserOperationClaimCommand.cs │ │ │ │ │ ├── CreateUserOperationClaimCommandValidator.cs │ │ │ │ │ └── CreatedUserOperationClaimResponse.cs │ │ │ │ ├── Delete │ │ │ │ │ ├── DeleteUserOperationClaimCommand.cs │ │ │ │ │ └── DeletedUserOperationClaimResponse.cs │ │ │ │ └── Update │ │ │ │ │ ├── UpdateUserOperationClaimCommand.cs │ │ │ │ │ ├── UpdateUserOperationClaimCommandValidator.cs │ │ │ │ │ └── UpdatedUserOperationClaimResponse.cs │ │ │ ├── Constants │ │ │ │ ├── UserOperationClaimsMessages.cs │ │ │ │ └── UserOperationClaimsOperationClaims.cs │ │ │ ├── Profiles │ │ │ │ └── MappingProfiles.cs │ │ │ ├── Queries │ │ │ │ ├── GetById │ │ │ │ │ ├── GetByIdUserOperationClaimQuery.cs │ │ │ │ │ └── GetByIdUserOperationClaimResponse.cs │ │ │ │ └── GetList │ │ │ │ │ ├── GetListUserOperationClaimListItemDto.cs │ │ │ │ │ └── GetListUserOperationClaimQuery.cs │ │ │ └── Rules │ │ │ │ └── UserOperationClaimBusinessRules.cs │ │ └── Users │ │ │ ├── Commands │ │ │ ├── Create │ │ │ │ ├── CreateUserCommand.cs │ │ │ │ ├── CreateUserCommandValidator.cs │ │ │ │ └── CreatedUserResponse.cs │ │ │ ├── Delete │ │ │ │ ├── DeleteUserCommand.cs │ │ │ │ └── DeletedUserResponse.cs │ │ │ ├── Update │ │ │ │ ├── UpdateUserCommand.cs │ │ │ │ ├── UpdateUserCommandValidator.cs │ │ │ │ └── UpdatedUserResponse.cs │ │ │ └── UpdateFromAuth │ │ │ │ ├── UpdateUserFromAuthCommand.cs │ │ │ │ ├── UpdateUserFromAuthCommandValidator.cs │ │ │ │ └── UpdatedUserFromAuthResponse.cs │ │ │ ├── Constants │ │ │ └── UsersOperationClaims.cs │ │ │ ├── Profiles │ │ │ └── MappingProfiles.cs │ │ │ ├── Queries │ │ │ ├── GetById │ │ │ │ ├── GetByIdUserQuery.cs │ │ │ │ └── GetByIdUserResponse.cs │ │ │ └── GetList │ │ │ │ ├── GetListUserListItemDto.cs │ │ │ │ └── GetListUserQuery.cs │ │ │ └── Rules │ │ │ └── UserBusinessRules.cs │ └── Services │ │ ├── AdditionalServiceService │ │ ├── AdditionalServiceManager.cs │ │ └── IAdditionalServiceService.cs │ │ ├── AuthService │ │ ├── AuthManager.cs │ │ └── IAuthService.cs │ │ ├── AuthenticatorService │ │ ├── AuthenticatorManager.cs │ │ └── IAuthenticatorService.cs │ │ ├── CarService │ │ ├── CarManager.cs │ │ └── ICarService.cs │ │ ├── CustomerService │ │ ├── CustomerManager.cs │ │ └── ICustomerService.cs │ │ ├── FindeksCreditRateService │ │ ├── FindeksCreditRateManager.cs │ │ └── IFindeksCreditRateService.cs │ │ ├── FindeksService │ │ └── IFindeksService.cs │ │ ├── ImageService │ │ └── ImageServiceBase.cs │ │ ├── InvoiceService │ │ ├── IInvoiceService.cs │ │ └── InvoiceManager.cs │ │ ├── ModelService │ │ ├── IModelService.cs │ │ └── ModelManager.cs │ │ ├── POSService │ │ └── IPOSService.cs │ │ ├── RentalService │ │ ├── IRentalService.cs │ │ └── RentalManager.cs │ │ ├── RentalsIAdditionalServiceService │ │ ├── IRentalsAdditionalServiceService.cs │ │ └── RentalsAdditionalServiceManager.cs │ │ ├── Repositories │ │ ├── IAdditionalServiceRepository.cs │ │ ├── IBrandRepository.cs │ │ ├── ICarDamageRepository.cs │ │ ├── ICarRepository.cs │ │ ├── IColorRepository.cs │ │ ├── ICorporateCustomerRepository.cs │ │ ├── ICustomerRepository.cs │ │ ├── IEmailAuthenticatorRepository.cs │ │ ├── IFindeksCreditRateRepository.cs │ │ ├── IFuelRepository.cs │ │ ├── IIndividualCustomerRepository.cs │ │ ├── IInvoiceRepository.cs │ │ ├── IModelRepository.cs │ │ ├── IOperationClaimRepository.cs │ │ ├── IOtpAuthenticatorRepository.cs │ │ ├── IRefreshTokenRepository.cs │ │ ├── IRentalBranchRepository.cs │ │ ├── IRentalRepository.cs │ │ ├── IRentalsAdditionalServiceRepository.cs │ │ ├── ITransmissionRepository.cs │ │ ├── IUserOperationClaimRepository.cs │ │ └── IUserRepository.cs │ │ └── UserService │ │ ├── IUserService.cs │ │ └── UserManager.cs │ ├── Domain │ ├── Domain.csproj │ ├── Entities │ │ ├── AdditionalService.cs │ │ ├── Brand.cs │ │ ├── Car.cs │ │ ├── CarDamage.cs │ │ ├── Color.cs │ │ ├── CorporateCustomer.cs │ │ ├── Customer.cs │ │ ├── FindeksCreditRate.cs │ │ ├── Fuel.cs │ │ ├── IndividualCustomer.cs │ │ ├── Invoice.cs │ │ ├── Model.cs │ │ ├── Rental.cs │ │ ├── RentalBranch.cs │ │ ├── RentalsAdditionalService.cs │ │ └── Transmission.cs │ └── Enums │ │ ├── CarStates.cs │ │ └── City.cs │ ├── Infrastructure │ ├── Adapters │ │ ├── FakeFindeksService │ │ │ └── FakeFindeksServiceAdapter.cs │ │ ├── FakePOSService │ │ │ └── FakePOSServiceAdapter.cs │ │ └── ImageService │ │ │ └── CloudinaryImageServiceAdapter.cs │ ├── Infrastructure.csproj │ └── InfrastructureServiceRegistration.cs │ ├── Persistence │ ├── Contexts │ │ └── BaseDbContext.cs │ ├── EntityConfigurations │ │ ├── AdditionalServiceConfiguration.cs │ │ ├── BrandConfiguration.cs │ │ ├── CarConfiguration.cs │ │ ├── CarDamageConfiguration.cs │ │ ├── ColorConfiguration.cs │ │ ├── CorporateCustomerConfiguration.cs │ │ ├── CustomerConfiguration.cs │ │ ├── EmailAuthenticatorConfiguration.cs │ │ ├── FindeksCreditRateConfiguration.cs │ │ ├── FuelConfiguration.cs │ │ ├── IndividualCustomerConfiguration.cs │ │ ├── InvoiceConfiguration.cs │ │ ├── ModelConfiguration.cs │ │ ├── OperationClaimConfiguration.cs │ │ ├── OtpAuthenticatorConfiguration.cs │ │ ├── RefreshTokenConfiguration.cs │ │ ├── RentalBranchConfiguration.cs │ │ ├── RentalConfiguration.cs │ │ ├── RentalsAdditionalServiceConfiguration.cs │ │ ├── TransmissionConfiguration.cs │ │ ├── UserConfiguration.cs │ │ └── UserOperationClaimConfiguration.cs │ ├── Migrations │ │ ├── 20221017160726_All.Designer.cs │ │ ├── 20221017160726_All.cs │ │ ├── 20221127171312_MakeUpdatedDateAsNullable.Designer.cs │ │ ├── 20221127171312_MakeUpdatedDateAsNullable.cs │ │ └── BaseDbContextModelSnapshot.cs │ ├── Persistence.csproj │ ├── PersistenceServiceRegistration.cs │ └── Repositories │ │ ├── AdditionalServiceRepository.cs │ │ ├── BrandRepository.cs │ │ ├── CarDamageRepository.cs │ │ ├── CarRepository.cs │ │ ├── ColorRepository.cs │ │ ├── CorporateCustomerRepository.cs │ │ ├── CustomerRepository.cs │ │ ├── EmailAuthenticatorRepository.cs │ │ ├── FindeksCreditRateRepository.cs │ │ ├── FuelRepository.cs │ │ ├── IndividualCustomerRepository.cs │ │ ├── InvoiceRepository.cs │ │ ├── ModelRepository.cs │ │ ├── OperationClaimRepository.cs │ │ ├── OtpAuthenticatorRepository.cs │ │ ├── RefreshTokenRepository.cs │ │ ├── RentalBranchRepository.cs │ │ ├── RentalRepository.cs │ │ ├── RentalsAdditionalServiceRepository.cs │ │ ├── TransmissionRepository.cs │ │ ├── UserOperationClaimRepository.cs │ │ └── UserRepository.cs │ └── WebAPI │ ├── Controllers │ ├── AdditionalServicesController.cs │ ├── AuthController.cs │ ├── BaseController.cs │ ├── BrandsController.cs │ ├── CarDamagesController.cs │ ├── CarsController.cs │ ├── ColorsController.cs │ ├── CorporateCustomerController.cs │ ├── CustomerController.cs │ ├── Dtos │ │ └── UpdateByAuthFromServiceRequestDto.cs │ ├── ElasticTestController.cs │ ├── FindeksCreditScoreController.cs │ ├── FuelsController.cs │ ├── IndividualCustomerController.cs │ ├── InvoicesController.cs │ ├── ModelsController.cs │ ├── OperationClaimsController.cs │ ├── RentalBranchesController.cs │ ├── RentalsController.cs │ ├── TransmissionsController.cs │ ├── UserOperationClaimsController.cs │ └── UsersController.cs │ ├── Program.cs │ ├── Properties │ └── launchSettings.json │ ├── WebAPI.csproj │ ├── WebAPIConfiguration.cs │ ├── appsettings.Development.json │ └── appsettings.json └── tests └── Application.Tests ├── Application.Tests.csproj ├── DependencyResolvers ├── BrandServiceRegistration.cs └── ColorServiceRegistration.cs ├── Features ├── Brands │ ├── Commands │ │ ├── CreateBrand │ │ │ └── CreateBrandTests.cs │ │ ├── DeleteBrand │ │ │ └── DeleteBrandTests.cs │ │ └── UpdateBrand │ │ │ └── UpdateBrandTests.cs │ └── Queries │ │ ├── GetByIdBrand │ │ └── GetByIdBrandTests.cs │ │ └── GetListBrand │ │ └── GetListBrandTests.cs └── Colors │ ├── Commands │ ├── CreateColor │ │ └── CreateColorTests.cs │ ├── DeleteColor │ │ └── DeleteColorTests.cs │ └── UpdateColor │ │ └── UpdateColorTests.cs │ └── Queries │ ├── GetByIdColor │ └── GetByIdColorTests.cs │ └── GetListColor │ └── GetListColorTests.cs ├── Mocks ├── FakeData │ ├── BrandFakeData.cs │ └── ColorFakeData.cs └── Repositories │ ├── BrandMockRepository.cs │ └── ColorMockRepository.cs └── Startup.cs /.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "csharpier": { 6 | "version": "0.22.1", 7 | "commands": [ 8 | "dotnet-csharpier" 9 | ] 10 | }, 11 | "roslynator.dotnet.cli": { 12 | "version": "0.5.0", 13 | "commands": [ 14 | "roslynator" 15 | ] 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /.csharpierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 140, 3 | "useTabs": false, 4 | "tabWidth": 4, 5 | "preprocessorSymbolSets": [ 6 | "", 7 | "DEBUG", 8 | "DEBUG,CODE_STYLE" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /.github/workflows/dotnet.yml: -------------------------------------------------------------------------------- 1 | name: .NET 2 | 3 | on: 4 | push: 5 | branches: ["master"] 6 | pull_request: 7 | branches: ["master"] 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v3 15 | with: 16 | submodules: recursive 17 | - name: Setup .NET 18 | uses: actions/setup-dotnet@v3 19 | with: 20 | dotnet-version: 7.0.x 21 | - name: Restore dependencies 22 | run: dotnet restore 23 | - name: Build 24 | run: dotnet build --no-restore 25 | - name: Test 26 | run: dotnet test --no-build --verbosity normal 27 | - name: Restore tool dependencies 28 | run: dotnet tool restore 29 | - name: Check format 30 | run: dotnet csharpier --check . 31 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "src/corePackages"] 2 | path = src/corePackages 3 | url = https://github.com/kodlamaio-projects/DotNetCore.CorePackages.git 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Ahmet Çetinkaya 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /RentACarProject.sln.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | False 3 | False -------------------------------------------------------------------------------- /docs/Semantic Commit Messages.md: -------------------------------------------------------------------------------- 1 | # Semantic Commit Messages 2 | 3 | **Format:** `(?): ` (scope is optional.) 4 | 5 | ## 🏷️ Types 6 | 7 | - `feat`: (new feature for the user, not a new feature for build script) 8 | - `fix`: (bug fix for the user, not a fix to a build script) 9 | - `docs`: (changes to the documentation) 10 | - `style`: (formatting, missing semi colons, etc; no production code change) 11 | - `perf`: (production changes related to backward-compatible performance improvements) 12 | - `refactor`: (refactoring production code, eg. renaming a variable) 13 | - `test`: (adding missing tests, refactoring tests; no production code change) 14 | - `build`: (updating grunt tasks etc; no production code change) 15 | - `ci`: (changes to identify development changes related to the continuous integration and deployment system - involving scripts, configurations or tools) 16 | 17 | ## 💡 Example 18 | 19 | ``` 20 | feat(core): add otp authenticator 21 | ``` 22 | 23 | --- 24 | 25 |
26 | References 27 |
    28 |
  • https://www.conventionalcommits.org/
  • 29 |
  • https://seesparkbox.com/foundry/semantic_commit_messages
  • 30 |
  • http://karma-runner.github.io/1.0/dev/git-commit-msg.html
  • 31 |
  • https://nitayneeman.com/posts/understanding-semantic-commit-messages-using-git-and-angular/
  • 32 |
33 |
34 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/AdditionalServices/Commands/Create/CreateAdditionalServiceCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.AdditionalServices.Commands.Create; 4 | 5 | public class CreateAdditionalServiceCommandValidator : AbstractValidator 6 | { 7 | public CreateAdditionalServiceCommandValidator() 8 | { 9 | RuleFor(c => c.Name).NotEmpty().MinimumLength(2); 10 | RuleFor(c => c.DailyPrice).GreaterThan(0); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/AdditionalServices/Commands/Create/CreatedAdditionalServiceResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.AdditionalServices.Commands.Create; 4 | 5 | public class CreatedAdditionalServiceResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | public decimal DailyPrice { get; set; } 10 | } 11 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/AdditionalServices/Commands/Delete/DeletedAdditionalServiceResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.AdditionalServices.Commands.Delete; 4 | 5 | public class DeletedAdditionalServiceResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | public decimal DailyPrice { get; set; } 10 | } 11 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/AdditionalServices/Commands/Update/UpdateAdditionalServiceCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.AdditionalServices.Commands.Update; 4 | 5 | public class UpdateAdditionalServiceCommandValidator : AbstractValidator 6 | { 7 | public UpdateAdditionalServiceCommandValidator() 8 | { 9 | RuleFor(c => c.Name).NotEmpty().MinimumLength(2); 10 | RuleFor(c => c.DailyPrice).GreaterThan(0); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/AdditionalServices/Commands/Update/UpdatedAdditionalServiceResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.AdditionalServices.Commands.Update; 4 | 5 | public class UpdatedAdditionalServiceResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | public decimal DailyPrice { get; set; } 10 | } 11 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/AdditionalServices/Constants/AdditionalServicesMessages.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.AdditionalServices.Constants; 2 | 3 | public static class AdditionalServicesMessages 4 | { 5 | public const string AdditionalServiceNotExists = "AdditionalService not exists."; 6 | public const string AdditionalServiceNameExists = "Additional service name exists."; 7 | } 8 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/AdditionalServices/Constants/AdditionalServicesOperationClaims.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.AdditionalServices.Constants; 2 | 3 | public static class AdditionalServicesOperationClaims 4 | { 5 | public const string Admin = "additionalservices.admin"; 6 | 7 | public const string Read = "additionalservices.read"; 8 | public const string Write = "additionalservices.write"; 9 | 10 | public const string Add = "additionalservices.add"; 11 | public const string Update = "additionalservices.update"; 12 | public const string Delete = "additionalservices.delete"; 13 | } 14 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/AdditionalServices/Queries/GetById/GetByIdAdditionalServiceResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.AdditionalServices.Queries.GetById; 4 | 5 | public class GetByIdAdditionalServiceResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | public decimal DailyPrice { get; set; } 10 | } 11 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/AdditionalServices/Queries/GetList/GetListAdditionalServiceListItemDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Dtos; 2 | 3 | namespace Application.Features.AdditionalServices.Queries.GetList; 4 | 5 | public class GetListAdditionalServiceListItemDto : IDto 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | public decimal DailyPrice { get; set; } 10 | } 11 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Auth/Commands/EnableOtpAuthenticator/EnabledOtpAuthenticatorResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Auth.Commands.EnableOtpAuthenticator; 4 | 5 | public class EnabledOtpAuthenticatorResponse : IResponse 6 | { 7 | public string SecretKey { get; set; } 8 | } 9 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Auth/Commands/Login/LoggedResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | using Core.Security.Entities; 3 | using Core.Security.Enums; 4 | using Core.Security.JWT; 5 | 6 | namespace Application.Features.Auth.Commands.Login; 7 | 8 | public class LoggedResponse : IResponse 9 | { 10 | public AccessToken? AccessToken { get; set; } 11 | public RefreshToken? RefreshToken { get; set; } 12 | public AuthenticatorType? RequiredAuthenticatorType { get; set; } 13 | 14 | public LoggedHttpResponse ToHttpResponse() => 15 | new() { AccessToken = AccessToken, RequiredAuthenticatorType = RequiredAuthenticatorType }; 16 | 17 | public class LoggedHttpResponse 18 | { 19 | public AccessToken? AccessToken { get; set; } 20 | public AuthenticatorType? RequiredAuthenticatorType { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Auth/Commands/Login/LoginCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.Auth.Commands.Login; 4 | 5 | public class LoginCommandValidator : AbstractValidator 6 | { 7 | public LoginCommandValidator() 8 | { 9 | RuleFor(c => c.UserForLoginDto.Email).NotEmpty().EmailAddress(); 10 | RuleFor(c => c.UserForLoginDto.Password).NotEmpty().MinimumLength(4); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Auth/Commands/RefleshToken/RefreshedTokensResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | using Core.Security.Entities; 3 | using Core.Security.JWT; 4 | 5 | namespace Application.Features.Auth.Commands.RefleshToken; 6 | 7 | public class RefreshedTokensResponse : IResponse 8 | { 9 | public AccessToken AccessToken { get; set; } 10 | public RefreshToken RefreshToken { get; set; } 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Auth/Commands/Register/RegisterCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.Auth.Commands.Register; 4 | 5 | public class RegisterCommandValidator : AbstractValidator 6 | { 7 | public RegisterCommandValidator() 8 | { 9 | RuleFor(c => c.UserForRegisterDto.FirstName).NotEmpty().MinimumLength(2); 10 | RuleFor(c => c.UserForRegisterDto.LastName).NotEmpty().MinimumLength(2); 11 | RuleFor(c => c.UserForRegisterDto.Email).NotEmpty().EmailAddress(); 12 | RuleFor(c => c.UserForRegisterDto.Password).NotEmpty().MinimumLength(4); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Auth/Commands/Register/RegisteredResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | using Core.Security.Entities; 3 | using Core.Security.JWT; 4 | 5 | namespace Application.Features.Auth.Commands.Register; 6 | 7 | public class RegisteredResponse : IResponse 8 | { 9 | public AccessToken AccessToken { get; set; } 10 | public RefreshToken RefreshToken { get; set; } 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Auth/Commands/RevokeToken/RevokedTokenResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Auth.Commands.RevokeToken; 4 | 5 | public class RevokedTokenResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string Token { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Auth/Constants/AuthMessages.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.Auth.Constants; 2 | 3 | public static class AuthMessages 4 | { 5 | public const string EmailAuthenticatorDontExists = "Email authenticator don't exists."; 6 | public const string OtpAuthenticatorDontExists = "Otp authenticator don't exists."; 7 | public const string AlreadyVerifiedOtpAuthenticatorIsExists = "Already verified otp authenticator is exists."; 8 | public const string EmailActivationKeyDontExists = "Email Activation Key don't exists."; 9 | public const string UserDontExists = "User don't exists."; 10 | public const string UserHaveAlreadyAAuthenticator = "User have already a authenticator."; 11 | public const string RefreshDontExists = "Refresh don't exists."; 12 | public const string InvalidRefreshToken = "Invalid refresh token."; 13 | public const string UserMailAlreadyExists = "User mail already exists."; 14 | public const string PasswordDontMatch = "Password don't match."; 15 | } 16 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Auth/Profiles/MappingProfiles.cs: -------------------------------------------------------------------------------- 1 | using Application.Features.Auth.Commands.RevokeToken; 2 | using AutoMapper; 3 | using Core.Security.Entities; 4 | 5 | namespace Application.Features.Auth.Profiles; 6 | 7 | public class MappingProfiles : Profile 8 | { 9 | public MappingProfiles() 10 | { 11 | CreateMap().ReverseMap(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Brands/Commands/Create/CreateBrandCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.Brands.Commands.Create; 4 | 5 | public class CreateBrandCommandValidator : AbstractValidator 6 | { 7 | public CreateBrandCommandValidator() 8 | { 9 | RuleFor(c => c.Name).NotEmpty().MinimumLength(2); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Brands/Commands/Create/CreatedBrandResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Brands.Commands.Create; 4 | 5 | public class CreatedBrandResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Brands/Commands/Delete/DeletedBrandResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Brands.Commands.Delete; 4 | 5 | public class DeletedBrandResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | } 9 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Brands/Commands/Update/UpdateBrandCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.Brands.Commands.Update; 4 | 5 | public class UpdateBrandCommandValidator : AbstractValidator 6 | { 7 | public UpdateBrandCommandValidator() 8 | { 9 | RuleFor(c => c.Name).NotEmpty().MinimumLength(2); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Brands/Commands/Update/UpdatedBrandResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Brands.Commands.Update; 4 | 5 | public class UpdatedBrandResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Brands/Constants/BrandsMessages.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.Brands.Constants; 2 | 3 | public static class BrandsMessages 4 | { 5 | public const string BrandNotExists = "Brand not exists."; 6 | public const string BrandNameExists = "Brand name exists."; 7 | } 8 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Brands/Constants/BrandsOperationClaims.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.Brands.Constants; 2 | 3 | public static class BrandsOperationClaims 4 | { 5 | public const string Admin = "brands.admin"; 6 | 7 | public const string Read = "brands.read"; 8 | public const string Write = "brands.write"; 9 | 10 | public const string Add = "brands.add"; 11 | public const string Update = "brands.update"; 12 | public const string Delete = "brands.delete"; 13 | } 14 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Brands/Profiles/MappingProfiles.cs: -------------------------------------------------------------------------------- 1 | using Application.Features.Brands.Commands.Create; 2 | using Application.Features.Brands.Commands.Delete; 3 | using Application.Features.Brands.Commands.Update; 4 | using Application.Features.Brands.Queries.GetById; 5 | using Application.Features.Brands.Queries.GetList; 6 | using AutoMapper; 7 | using Core.Application.Responses; 8 | using Core.Persistence.Paging; 9 | using Domain.Entities; 10 | 11 | namespace Application.Features.Brands.Profiles; 12 | 13 | public class MappingProfiles : Profile 14 | { 15 | public MappingProfiles() 16 | { 17 | CreateMap().ReverseMap(); 18 | CreateMap().ReverseMap(); 19 | CreateMap().ReverseMap(); 20 | CreateMap().ReverseMap(); 21 | CreateMap().ReverseMap(); 22 | CreateMap().ReverseMap(); 23 | CreateMap().ReverseMap(); 24 | CreateMap().ReverseMap(); 25 | CreateMap, GetListResponse>().ReverseMap(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Brands/Queries/GetById/GetByIdBrandResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Brands.Queries.GetById; 4 | 5 | public class GetByIdBrandResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Brands/Queries/GetList/GetListBrandListItemDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Dtos; 2 | 3 | namespace Application.Features.Brands.Queries.GetList; 4 | 5 | public class GetListBrandListItemDto : IDto 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/CarDamages/Commands/Create/CreateCarDamageCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.CarDamages.Commands.Create; 4 | 5 | public class CreateCarDamageCommandValidator : AbstractValidator 6 | { 7 | public CreateCarDamageCommandValidator() 8 | { 9 | RuleFor(c => c.CarId).GreaterThan(0); 10 | RuleFor(c => c.DamageDescription).NotEmpty().MinimumLength(2); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/CarDamages/Commands/Create/CreatedCarDamageResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.CarDamages.Commands.Create; 4 | 5 | public class CreatedCarDamageResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public int CarId { get; set; } 9 | public string DamageDescription { get; set; } 10 | public bool IsFixed { get; set; } 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/CarDamages/Commands/Delete/DeletedCarDamageResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.CarDamages.Commands.Delete; 4 | 5 | public class DeletedCarDamageResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | } 9 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/CarDamages/Commands/Update/UpdateCarDamageCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.CarDamages.Commands.Update; 4 | 5 | public class UpdateCarDamageCommandValidator : AbstractValidator 6 | { 7 | public UpdateCarDamageCommandValidator() 8 | { 9 | RuleFor(c => c.CarId).GreaterThan(0); 10 | RuleFor(c => c.DamageDescription).NotEmpty().MinimumLength(2); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/CarDamages/Commands/Update/UpdatedCarDamageResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.CarDamages.Commands.Update; 4 | 5 | public class UpdatedCarDamageResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public int CarId { get; set; } 9 | public string DamageDescription { get; set; } 10 | public bool IsFixed { get; set; } 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/CarDamages/Constants/CarDamagesMessages.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.CarDamages.Constants; 2 | 3 | public static class CarDamagesMessages 4 | { 5 | public const string CarDamageNotExists = "CarDamage not exists."; 6 | } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/CarDamages/Constants/CarDamagesOperationClaims.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.CarDamages.Constants; 2 | 3 | public static class CarDamagesOperationClaims 4 | { 5 | public const string Admin = "cardamages.admin"; 6 | 7 | public const string Read = "cardamages.read"; 8 | public const string Write = "cardamages.write"; 9 | 10 | public const string Add = "cardamages.add"; 11 | public const string Update = "cardamages.update"; 12 | public const string Delete = "cardamages.delete"; 13 | } 14 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/CarDamages/Queries/GetById/GetByIdCarDamageResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.CarDamages.Queries.GetById; 4 | 5 | public class GetByIdCarDamageResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public int CarId { get; set; } 9 | public string DamageDescription { get; set; } 10 | public bool IsFixed { get; set; } 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/CarDamages/Queries/GetList/GetListCarDamageListItemDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Dtos; 2 | 3 | namespace Application.Features.CarDamages.Queries.GetList; 4 | 5 | public class GetListCarDamageListItemDto : IDto 6 | { 7 | public int Id { get; set; } 8 | public string CarModelBrandName { get; set; } 9 | public string CarModelName { get; set; } 10 | public short CarModelYear { get; set; } 11 | public string CarPlate { get; set; } 12 | public string DamageDescription { get; set; } 13 | public bool IsFixed { get; set; } 14 | } 15 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/CarDamages/Queries/GetListByCarId/GetListByCarIdCarDamageListItemDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Dtos; 2 | 3 | namespace Application.Features.CarDamages.Queries.GetListByCarId; 4 | 5 | public class GetListByCarIdCarDamageListItemDto : IDto 6 | { 7 | public int Id { get; set; } 8 | public string CarModelBrandName { get; set; } 9 | public string CarModelName { get; set; } 10 | public short CarModelYear { get; set; } 11 | public string CarPlate { get; set; } 12 | public string DamageDescription { get; set; } 13 | public bool IsFixed { get; set; } 14 | } 15 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/CarDamages/Rules/CarDamageBusinessRules.cs: -------------------------------------------------------------------------------- 1 | using Application.Features.CarDamages.Constants; 2 | using Application.Services.Repositories; 3 | using Core.Application.Rules; 4 | using Core.CrossCuttingConcerns.Exceptions.Types; 5 | using Domain.Entities; 6 | 7 | namespace Application.Features.CarDamages.Rules; 8 | 9 | public class CarDamageBusinessRules : BaseBusinessRules 10 | { 11 | private readonly ICarDamageRepository _carDamageRepository; 12 | 13 | public CarDamageBusinessRules(ICarDamageRepository carDamageRepository) 14 | { 15 | _carDamageRepository = carDamageRepository; 16 | } 17 | 18 | public async Task CarDamageIdShouldExistWhenSelected(int id) 19 | { 20 | CarDamage? result = await _carDamageRepository.GetAsync(predicate: b => b.Id == id, enableTracking: false); 21 | if (result == null) 22 | throw new BusinessException(CarDamagesMessages.CarDamageNotExists); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Cars/Commands/Create/CreateCarCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using Application.Features.Cars.Validations; 2 | using FluentValidation; 3 | 4 | namespace Application.Features.Cars.Commands.Create; 5 | 6 | public class CreateCarCommandValidator : AbstractValidator 7 | { 8 | public CreateCarCommandValidator() 9 | { 10 | RuleFor(c => c.ModelYear).GreaterThan((short)1900); 11 | RuleFor(c => c.Plate).NotEmpty().Must(CarCustomValidationRules.IsTurkeyPlate).WithMessage("Plate is not valid."); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Cars/Commands/Create/CreatedCarResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | using Domain.Enums; 3 | 4 | namespace Application.Features.Cars.Commands.Create; 5 | 6 | public class CreatedCarResponse : IResponse 7 | { 8 | public int Id { get; set; } 9 | public int ColorId { get; set; } 10 | public int ModelId { get; set; } 11 | public int RentalBranchId { get; set; } 12 | public CarState CarState { get; set; } 13 | public int Kilometer { get; set; } 14 | public short ModelYear { get; set; } 15 | public string Plate { get; set; } 16 | public short MinFindeksCreditRate { get; set; } 17 | } 18 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Cars/Commands/Delete/DeletedCarResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Cars.Commands.Delete; 4 | 5 | public class DeletedCarResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | } 9 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Cars/Commands/DeliverRental/DeliveredCarResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | using Domain.Enums; 3 | 4 | namespace Application.Features.Cars.Commands.DeliverRental; 5 | 6 | public class DeliveredCarResponse : IResponse 7 | { 8 | public int Id { get; set; } 9 | public int ColorId { get; set; } 10 | public int ModelId { get; set; } 11 | public int RentalBranchId { get; set; } 12 | public CarState CarState { get; set; } 13 | public int Kilometer { get; set; } 14 | public short ModelYear { get; set; } 15 | public string Plate { get; set; } 16 | public short MinFindeksCreditRate { get; set; } 17 | } 18 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Cars/Commands/Maintain/MaintainedCarResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | using Domain.Enums; 3 | 4 | namespace Application.Features.Cars.Commands.Maintain; 5 | 6 | public class MaintainedCarResponse : IResponse 7 | { 8 | public int Id { get; set; } 9 | public int ColorId { get; set; } 10 | public int ModelId { get; set; } 11 | public int RentalBranchId { get; set; } 12 | public CarState CarState { get; set; } 13 | public int Kilometer { get; set; } 14 | public short ModelYear { get; set; } 15 | public string Plate { get; set; } 16 | public short MinFindeksCreditRate { get; set; } 17 | } 18 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Cars/Commands/Update/UpdateCarCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using Application.Features.Cars.Validations; 2 | using FluentValidation; 3 | 4 | namespace Application.Features.Cars.Commands.Update; 5 | 6 | public class UpdateCarCommandValidator : AbstractValidator 7 | { 8 | public UpdateCarCommandValidator() 9 | { 10 | RuleFor(c => c.ModelYear).GreaterThan((short)1900); 11 | RuleFor(c => c.Plate).NotEmpty().Must(CarCustomValidationRules.IsTurkeyPlate).WithMessage("Plate is not valid."); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Cars/Commands/Update/UpdatedCarResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | using Domain.Enums; 3 | 4 | namespace Application.Features.Cars.Commands.Update; 5 | 6 | public class UpdatedCarResponse : IResponse 7 | { 8 | public int Id { get; set; } 9 | public int ColorId { get; set; } 10 | public int ModelId { get; set; } 11 | public int RentalBranchId { get; set; } 12 | public CarState CarState { get; set; } 13 | public int Kilometer { get; set; } 14 | public short ModelYear { get; set; } 15 | public string Plate { get; set; } 16 | public short MinFindeksCreditRate { get; set; } 17 | } 18 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Cars/Constants/CarsMessages.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.Cars.Constants; 2 | 3 | public static class CarsMessages 4 | { 5 | public const string CarNotExists = "Car not exists."; 6 | public const string CarCanNotBeMaintainWhenIsRented = "Car can't be maintain when is rented."; 7 | public const string CarCanNotBeRentWhenIsInMaintenance = "Car can not be rent when is in maintenance."; 8 | public const string CarCanNotBeRentWhenIsRented = "Car can not be rent when is rented."; 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Cars/Constants/CarsOperationClaims.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.Cars.Constants; 2 | 3 | public static class CarsOperationClaims 4 | { 5 | public const string Admin = "cars.admin"; 6 | 7 | public const string Read = "cars.read"; 8 | public const string Write = "cars.write"; 9 | 10 | public const string Add = "cars.add"; 11 | public const string Update = "cars.update"; 12 | public const string Delete = "cars.delete"; 13 | } 14 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Cars/Queries/GetById/GetByIdCarQuery.cs: -------------------------------------------------------------------------------- 1 | using Application.Features.Cars.Rules; 2 | using Application.Services.Repositories; 3 | using AutoMapper; 4 | using Domain.Entities; 5 | using MediatR; 6 | 7 | namespace Application.Features.Cars.Queries.GetById; 8 | 9 | public class GetByIdCarQuery : IRequest 10 | { 11 | public int Id { get; set; } 12 | 13 | public class GetByIdCarQueryHandler : IRequestHandler 14 | { 15 | private readonly ICarRepository _carRepository; 16 | private readonly IMapper _mapper; 17 | private readonly CarBusinessRules _carBusinessRules; 18 | 19 | public GetByIdCarQueryHandler(ICarRepository carRepository, CarBusinessRules carBusinessRules, IMapper mapper) 20 | { 21 | _carRepository = carRepository; 22 | _carBusinessRules = carBusinessRules; 23 | _mapper = mapper; 24 | } 25 | 26 | public async Task Handle(GetByIdCarQuery request, CancellationToken cancellationToken) 27 | { 28 | await _carBusinessRules.CarIdShouldExistWhenSelected(request.Id); 29 | 30 | Car? car = await _carRepository.GetAsync(c => c.Id == request.Id); 31 | GetByIdCarResponse carDto = _mapper.Map(car); 32 | return carDto; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Cars/Queries/GetById/GetByIdCarResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | using Domain.Enums; 3 | 4 | namespace Application.Features.Cars.Queries.GetById; 5 | 6 | public class GetByIdCarResponse : IResponse 7 | { 8 | public int Id { get; set; } 9 | public int ColorId { get; set; } 10 | public int ModelId { get; set; } 11 | public int RentalBranchId { get; set; } 12 | public CarState CarState { get; set; } 13 | public int Kilometer { get; set; } 14 | public short ModelYear { get; set; } 15 | public string Plate { get; set; } 16 | public short MinFindeksCreditRate { get; set; } 17 | } 18 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Cars/Queries/GetList/GetListCarListItemDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Dtos; 2 | using Domain.Enums; 3 | 4 | namespace Application.Features.Cars.Queries.GetList; 5 | 6 | public class GetListCarListItemDto : IDto 7 | { 8 | public int Id { get; set; } 9 | public string BrandName { get; set; } 10 | public string ModelName { get; set; } 11 | public string ColorName { get; set; } 12 | public string Plate { get; set; } 13 | public CarState CarState { get; set; } 14 | public short ModelYear { get; set; } 15 | } 16 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Cars/Queries/GetListByDynamic/GetListByDynamicCarListItemDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Dtos; 2 | using Domain.Enums; 3 | 4 | namespace Application.Features.Cars.Queries.GetListByDynamic; 5 | 6 | public class GetListByDynamicCarListItemDto : IDto 7 | { 8 | public int Id { get; set; } 9 | public string BrandName { get; set; } 10 | public string ModelName { get; set; } 11 | public string ColorName { get; set; } 12 | public string Plate { get; set; } 13 | public CarState CarState { get; set; } 14 | public short ModelYear { get; set; } 15 | } 16 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Cars/Validations/CarCustomValidationRules.cs: -------------------------------------------------------------------------------- 1 | using System.Text.RegularExpressions; 2 | 3 | namespace Application.Features.Cars.Validations; 4 | 5 | public static class CarCustomValidationRules 6 | { 7 | public static bool IsTurkeyPlate(string plate) 8 | { 9 | Regex regex = new(@"(0[1-9]|[1-7][0-9]|8[01])(([A-Z])(\d{4,5})|([A-Z]{2})(\d{3,4})|([A-Z]{3})(\d{2}))"); 10 | return regex.IsMatch(plate); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Colors/Commands/Create/CreateColorCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.Colors.Commands.Create; 4 | 5 | public class CreateColorCommandValidator : AbstractValidator 6 | { 7 | public CreateColorCommandValidator() 8 | { 9 | RuleFor(c => c.Name).NotEmpty().MinimumLength(2); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Colors/Commands/Create/CreatedColorResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Colors.Commands.Create; 4 | 5 | public class CreatedColorResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Colors/Commands/Delete/DeletedColorResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Colors.Commands.Delete; 4 | 5 | public class DeletedColorResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | } 9 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Colors/Commands/Update/UpdateColorCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.Colors.Commands.Update; 4 | 5 | public class UpdateColorCommandValidator : AbstractValidator 6 | { 7 | public UpdateColorCommandValidator() 8 | { 9 | RuleFor(c => c.Name).NotEmpty().MinimumLength(2); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Colors/Commands/Update/UpdatedColorResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Colors.Commands.Update; 4 | 5 | public class UpdatedColorResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Colors/Constants/ColorsMessages.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.Colors.Constants; 2 | 3 | public static class ColorsMessages 4 | { 5 | public const string ColorNotExists = "Color not exists."; 6 | public const string ColorNameExists = "Color name exists."; 7 | } 8 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Colors/Constants/ColorsOperationClaims.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.Colors.Constants; 2 | 3 | public static class ColorsOperationClaims 4 | { 5 | public const string Admin = "colors.admin"; 6 | 7 | public const string Read = "colors.read"; 8 | public const string Write = "colors.write"; 9 | 10 | public const string Add = "colors.add"; 11 | public const string Update = "colors.update"; 12 | public const string Delete = "colors.delete"; 13 | } 14 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Colors/Profiles/MappingProfiles.cs: -------------------------------------------------------------------------------- 1 | using Application.Features.Colors.Commands.Create; 2 | using Application.Features.Colors.Commands.Delete; 3 | using Application.Features.Colors.Commands.Update; 4 | using Application.Features.Colors.Queries.GetById; 5 | using Application.Features.Colors.Queries.GetList; 6 | using AutoMapper; 7 | using Core.Application.Responses; 8 | using Core.Persistence.Paging; 9 | using Domain.Entities; 10 | 11 | namespace Application.Features.Colors.Profiles; 12 | 13 | public class MappingProfiles : Profile 14 | { 15 | public MappingProfiles() 16 | { 17 | CreateMap().ReverseMap(); 18 | CreateMap().ReverseMap(); 19 | CreateMap().ReverseMap(); 20 | CreateMap().ReverseMap(); 21 | CreateMap().ReverseMap(); 22 | CreateMap().ReverseMap(); 23 | CreateMap().ReverseMap(); 24 | CreateMap().ReverseMap(); 25 | CreateMap, GetListResponse>().ReverseMap(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Colors/Queries/GetById/GetByIdColorResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Colors.Queries.GetById; 4 | 5 | public class GetByIdColorResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Colors/Queries/GetList/GetListColorListItemDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Dtos; 2 | 3 | namespace Application.Features.Colors.Queries.GetList; 4 | 5 | public class GetListColorListItemDto : IDto 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Colors/Rules/ColorBusinessRules.cs: -------------------------------------------------------------------------------- 1 | using Application.Features.Colors.Constants; 2 | using Application.Services.Repositories; 3 | using Core.Application.Rules; 4 | using Core.CrossCuttingConcerns.Exceptions.Types; 5 | using Core.Persistence.Paging; 6 | using Domain.Entities; 7 | 8 | namespace Application.Features.Colors.Rules; 9 | 10 | public class ColorBusinessRules : BaseBusinessRules 11 | { 12 | private readonly IColorRepository _colorRepository; 13 | 14 | public ColorBusinessRules(IColorRepository colorRepository) 15 | { 16 | _colorRepository = colorRepository; 17 | } 18 | 19 | public async Task ColorIdShouldExistWhenSelected(int id) 20 | { 21 | Color? result = await _colorRepository.GetAsync(predicate: b => b.Id == id, enableTracking: false); 22 | if (result == null) 23 | throw new BusinessException(ColorsMessages.ColorNotExists); 24 | } 25 | 26 | public async Task ColorNameCanNotBeDuplicatedWhenInserted(string name) 27 | { 28 | IPaginate result = await _colorRepository.GetListAsync(predicate: b => b.Name == name, enableTracking: false); 29 | if (result.Items.Any()) 30 | throw new BusinessException(ColorsMessages.ColorNameExists); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/CorporateCustomers/Commands/Create/CreateCorporateCustomerCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.CorporateCustomers.Commands.Create; 4 | 5 | public class CreateCorporateCustomerCommandValidator : AbstractValidator 6 | { 7 | public CreateCorporateCustomerCommandValidator() 8 | { 9 | RuleFor(c => c.CustomerId).GreaterThan(0); 10 | RuleFor(c => c.CompanyName).NotEmpty().MinimumLength(2); 11 | RuleFor(c => c.TaxNo).NotEmpty().MinimumLength(2); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/CorporateCustomers/Commands/Create/CreatedCorporateCustomerResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.CorporateCustomers.Commands.Create; 4 | 5 | public class CreatedCorporateCustomerResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string CompanyName { get; set; } 9 | public string TaxNo { get; set; } 10 | } 11 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/CorporateCustomers/Commands/Delete/DeletedCorporateCustomerResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.CorporateCustomers.Commands.Delete; 4 | 5 | public class DeletedCorporateCustomerResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | } 9 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/CorporateCustomers/Commands/Update/UpdateCorporateCustomerCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.CorporateCustomers.Commands.Update; 4 | 5 | public class UpdateCorporateCustomerCommandValidator : AbstractValidator 6 | { 7 | public UpdateCorporateCustomerCommandValidator() 8 | { 9 | RuleFor(c => c.CustomerId).GreaterThan(0); 10 | RuleFor(c => c.CompanyName).NotEmpty().MinimumLength(2); 11 | RuleFor(c => c.TaxNo).NotEmpty().MinimumLength(2); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/CorporateCustomers/Commands/Update/UpdatedCorporateCustomerResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.CorporateCustomers.Commands.Update; 4 | 5 | public class UpdatedCorporateCustomerResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string CompanyName { get; set; } 9 | public string TaxNo { get; set; } 10 | } 11 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/CorporateCustomers/Constants/CorporateCustomersMessages.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.CorporateCustomers.Constants; 2 | 3 | public static class CorporateCustomersMessages 4 | { 5 | public const string CorporateCustomerNotExists = "CorporateCustomer not exists."; 6 | public const string CorporateCustomerTaxNoAlreadyExists = "Corporate customer tax no already exists."; 7 | } 8 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/CorporateCustomers/Constants/CorporateCustomersOperationClaims.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.CorporateCustomers.Constants; 2 | 3 | public static class CorporateCustomersOperationClaims 4 | { 5 | public const string Admin = "corporatecustomers.admin"; 6 | 7 | public const string Read = "corporatecustomers.read"; 8 | public const string Write = "corporatecustomers.write"; 9 | 10 | public const string Add = "corporatecustomers.add"; 11 | public const string Update = "corporatecustomers.update"; 12 | public const string Delete = "corporatecustomers.delete"; 13 | } 14 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/CorporateCustomers/Queries/GetByCustomerId/GetByCustomerIdCorporateCustomerResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.CorporateCustomers.Queries.GetByCustomerId; 4 | 5 | public class GetByCustomerIdCorporateCustomerResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string CompanyName { get; set; } 9 | public string TaxNo { get; set; } 10 | } 11 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/CorporateCustomers/Queries/GetById/GetByIdCorporateCustomerResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.CorporateCustomers.Queries.GetById; 4 | 5 | public class GetByIdCorporateCustomerResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string CompanyName { get; set; } 9 | public string TaxNo { get; set; } 10 | } 11 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/CorporateCustomers/Queries/GetList/GetListCorporateCustomerListItemDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Dtos; 2 | 3 | namespace Application.Features.CorporateCustomers.Queries.GetList; 4 | 5 | public class GetListCorporateCustomerListItemDto : IDto 6 | { 7 | public int Id { get; set; } 8 | public string CompanyName { get; set; } 9 | public string TaxNo { get; set; } 10 | } 11 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Customers/Commands/Create/CreateCustomerCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.Customers.Commands.Create; 4 | 5 | public class CreateCustomerCommandValidator : AbstractValidator 6 | { 7 | public CreateCustomerCommandValidator() 8 | { 9 | RuleFor(c => c.UserId).GreaterThan(0); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Customers/Commands/Create/CreatedCustomerResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Customers.Commands.Create; 4 | 5 | public class CreatedCustomerResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public int UserId { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Customers/Commands/Delete/DeletedCustomerResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Customers.Commands.Delete; 4 | 5 | public class DeletedCustomerResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | } 9 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Customers/Commands/Update/UpdateCustomerCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.Customers.Commands.Update; 4 | 5 | public class UpdateCustomerCommandValidator : AbstractValidator 6 | { 7 | public UpdateCustomerCommandValidator() 8 | { 9 | RuleFor(c => c.UserId).GreaterThan(0); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Customers/Commands/Update/UpdatedCustomerResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Customers.Commands.Update; 4 | 5 | public class UpdatedCustomerResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public int UserId { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Customers/Constants/CustomersMessages.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.Customers.Constants; 2 | 3 | public static class CustomersMessages 4 | { 5 | public const string CustomerNotExists = "Customer not exists."; 6 | } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Customers/Constants/CustomersOperationClaims.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.Customers.Constants; 2 | 3 | public static class CustomersOperationClaims 4 | { 5 | public const string Admin = "customers.admin"; 6 | 7 | public const string Read = "customers.read"; 8 | public const string Write = "customers.write"; 9 | 10 | public const string Add = "customers.add"; 11 | public const string Update = "customers.update"; 12 | public const string Delete = "customers.delete"; 13 | } 14 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Customers/Queries/GetById/GetByIdCustomerResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Customers.Queries.GetById; 4 | 5 | public class GetByIdCustomerResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public int UserId { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Customers/Queries/GetByUserId/GetByUserIdCustomerResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Customers.Queries.GetByUserId; 4 | 5 | public class GetByUserIdCustomerResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public int UserId { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Customers/Queries/GetList/GetListCustomerListItemDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Dtos; 2 | 3 | namespace Application.Features.Customers.Queries.GetList; 4 | 5 | public class GetListCustomerListItemDto : IDto 6 | { 7 | public int Id { get; set; } 8 | public int UserId { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Customers/Rules/CustomerBusinessRules.cs: -------------------------------------------------------------------------------- 1 | using Application.Features.Customers.Constants; 2 | using Application.Services.Repositories; 3 | using Core.Application.Rules; 4 | using Core.CrossCuttingConcerns.Exceptions.Types; 5 | using Domain.Entities; 6 | 7 | namespace Application.Features.Customers.Rules; 8 | 9 | public class CustomerBusinessRules : BaseBusinessRules 10 | { 11 | private readonly ICustomerRepository _customerRepository; 12 | 13 | public CustomerBusinessRules(ICustomerRepository customerRepository) 14 | { 15 | _customerRepository = customerRepository; 16 | } 17 | 18 | public async Task CustomerIdShouldExist(int id) 19 | { 20 | Customer? result = await _customerRepository.GetAsync(predicate: b => b.Id == id, enableTracking: false); 21 | if (result == null) 22 | throw new BusinessException(CustomersMessages.CustomerNotExists); 23 | } 24 | 25 | public Task CustomerShouldBeExist(Customer? customer) 26 | { 27 | if (customer is null) 28 | throw new BusinessException(CustomersMessages.CustomerNotExists); 29 | return Task.CompletedTask; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/FindeksCreditRates/Commands/Create/CreateFindeksCreditRateCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.FindeksCreditRates.Commands.Create; 4 | 5 | public class CreateFindeksCreditRateCommandValidator : AbstractValidator 6 | { 7 | public CreateFindeksCreditRateCommandValidator() 8 | { 9 | RuleFor(f => f.Score).GreaterThanOrEqualTo(Convert.ToInt16(0)).LessThanOrEqualTo(Convert.ToInt16(1900)); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/FindeksCreditRates/Commands/Create/CreatedFindeksCreditRateResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.FindeksCreditRates.Commands.Create; 4 | 5 | public class CreatedFindeksCreditRateResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public int Score { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/FindeksCreditRates/Commands/Delete/DeletedFindeksCreditRateResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.FindeksCreditRates.Commands.Delete; 4 | 5 | public class DeletedFindeksCreditRateResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | } 9 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/FindeksCreditRates/Commands/Update/UpdateFindeksCreditRateCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.FindeksCreditRates.Commands.Update; 4 | 5 | public class UpdateFindeksCreditRateCommandValidator : AbstractValidator 6 | { 7 | public UpdateFindeksCreditRateCommandValidator() 8 | { 9 | RuleFor(f => f.Score).GreaterThanOrEqualTo(Convert.ToInt16(0)).LessThanOrEqualTo(Convert.ToInt16(1900)); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/FindeksCreditRates/Commands/Update/UpdatedFindeksCreditRateResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.FindeksCreditRates.Commands.Update; 4 | 5 | public class UpdatedFindeksCreditRateResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public int Score { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/FindeksCreditRates/Commands/UpdateByUserIdFromService/UpdateByUserIdFindeksCreditRateFromServiceCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.FindeksCreditRates.Commands.UpdateByUserIdFromService; 4 | 5 | public class UpdateByUserIdFindeksCreditRateFromServiceCommandValidator 6 | : AbstractValidator 7 | { 8 | public UpdateByUserIdFindeksCreditRateFromServiceCommandValidator() 9 | { 10 | RuleFor(c => c.UserId).GreaterThan(0); 11 | RuleFor(c => c.IdentityNumber).NotEmpty().MinimumLength(2); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/FindeksCreditRates/Commands/UpdateByUserIdFromService/UpdateByUserIdFindeksCreditRateFromServiceResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.FindeksCreditRates.Commands.UpdateByUserIdFromService; 4 | 5 | public class UpdateByUserIdFindeksCreditRateFromServiceResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public int Score { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/FindeksCreditRates/Commands/UpdateFromService/UpdateFindeksCreditRateFromServiceCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.FindeksCreditRates.Commands.UpdateFromService; 4 | 5 | public class UpdateFindeksCreditRateFromServiceCommandValidator : AbstractValidator 6 | { 7 | public UpdateFindeksCreditRateFromServiceCommandValidator() 8 | { 9 | RuleFor(c => c.IdentityNumber).NotEmpty().MinimumLength(2); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/FindeksCreditRates/Commands/UpdateFromService/UpdateFindeksCreditRateFromServiceResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.FindeksCreditRates.Commands.UpdateFromService; 4 | 5 | public class UpdateFindeksCreditRateFromServiceResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public int Score { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/FindeksCreditRates/Constants/FindeksCreditRatesMessages.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.FindeksCreditRates.Constants; 2 | 3 | public static class FindeksCreditRatesMessages 4 | { 5 | public const string FindeksCreditRateNotExists = "Findeks Credit Rate not exists."; 6 | } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/FindeksCreditRates/Constants/FindeksCreditRatesOperationClaims.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.FindeksCreditRates.Constants; 2 | 3 | public static class FindeksCreditRatesOperationClaims 4 | { 5 | public const string Admin = "findekscreditrates.admin"; 6 | 7 | public const string Read = "findekscreditrates.read"; 8 | public const string Write = "findekscreditrates.write"; 9 | 10 | public const string Add = "findekscreditrates.add"; 11 | public const string Update = "findekscreditrates.update"; 12 | public const string Delete = "findekscreditrates.delete"; 13 | } 14 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/FindeksCreditRates/Queries/GetByCustomerIdFindeksCreditRate/GetByCustomerIdFindeksCreditRateResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.FindeksCreditRates.Queries.GetByCustomerIdFindeksCreditRate; 4 | 5 | public class GetByCustomerIdFindeksCreditRateResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public int Score { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/FindeksCreditRates/Queries/GetByIdFindeksCreditRate/GetByIdFindeksCreditRateResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.FindeksCreditRates.Queries.GetByIdFindeksCreditRate; 4 | 5 | public class GetByIdFindeksCreditRateResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public int Score { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/FindeksCreditRates/Queries/GetListFindeksCreditRate/GetListFindeksCreditRateListItemDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Dtos; 2 | 3 | namespace Application.Features.FindeksCreditRates.Queries.GetListFindeksCreditRate; 4 | 5 | public class GetListFindeksCreditRateListItemDto : IDto 6 | { 7 | public int Id { get; set; } 8 | public int Score { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/FindeksCreditRates/Rules/FindeksCreditRateBusinessRules.cs: -------------------------------------------------------------------------------- 1 | using Application.Features.FindeksCreditRates.Constants; 2 | using Application.Services.Repositories; 3 | using Core.Application.Rules; 4 | using Core.CrossCuttingConcerns.Exceptions.Types; 5 | using Domain.Entities; 6 | 7 | namespace Application.Features.FindeksCreditRates.Rules; 8 | 9 | public class FindeksCreditRateBusinessRules : BaseBusinessRules 10 | { 11 | private readonly IFindeksCreditRateRepository _findeksCreditRateRepository; 12 | 13 | public FindeksCreditRateBusinessRules(IFindeksCreditRateRepository findeksCreditRateRepository) 14 | { 15 | _findeksCreditRateRepository = findeksCreditRateRepository; 16 | } 17 | 18 | public async Task FindeksCreditRateIdShouldExistWhenSelected(int id) 19 | { 20 | FindeksCreditRate? result = await _findeksCreditRateRepository.GetAsync(predicate: b => b.Id == id, enableTracking: false); 21 | if (result == null) 22 | throw new BusinessException(FindeksCreditRatesMessages.FindeksCreditRateNotExists); 23 | } 24 | 25 | public Task FindeksCreditShouldBeExist(FindeksCreditRate? findeksCreditRate) 26 | { 27 | if (findeksCreditRate is null) 28 | throw new BusinessException(FindeksCreditRatesMessages.FindeksCreditRateNotExists); 29 | return Task.CompletedTask; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Fuels/Commands/Create/CreateFuelCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.Fuels.Commands.Create; 4 | 5 | public class CreateFuelCommandValidator : AbstractValidator 6 | { 7 | public CreateFuelCommandValidator() 8 | { 9 | RuleFor(c => c.Name).NotEmpty().MinimumLength(2); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Fuels/Commands/Create/CreatedFuelResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Fuels.Commands.Create; 4 | 5 | public class CreatedFuelResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Fuels/Commands/Delete/DeletedFuelResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Fuels.Commands.Delete; 4 | 5 | public class DeletedFuelResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | } 9 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Fuels/Commands/Update/UpdateFuelCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.Fuels.Commands.Update; 4 | 5 | public class UpdateFuelCommandValidator : AbstractValidator 6 | { 7 | public UpdateFuelCommandValidator() 8 | { 9 | RuleFor(c => c.Name).NotEmpty().MinimumLength(2); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Fuels/Commands/Update/UpdatedFuelResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Fuels.Commands.Update; 4 | 5 | public class UpdatedFuelResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Fuels/Constants/FuelsMessages.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.Fuels.Constants; 2 | 3 | public static class FuelsMessages 4 | { 5 | public const string FuelNotExists = "Fuel not exists."; 6 | public const string FuelNameExists = "Fuel name exists."; 7 | } 8 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Fuels/Constants/FuelsOperationClaims.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.Fuels.Constants; 2 | 3 | public static class FuelsOperationClaims 4 | { 5 | public const string Admin = "fuels.admin"; 6 | 7 | public const string Read = "fuels.read"; 8 | public const string Write = "fuels.write"; 9 | 10 | public const string Add = "fuels.add"; 11 | public const string Update = "fuels.update"; 12 | public const string Delete = "fuels.delete"; 13 | } 14 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Fuels/Profiles/MappingProfiles.cs: -------------------------------------------------------------------------------- 1 | using Application.Features.Fuels.Commands.Create; 2 | using Application.Features.Fuels.Commands.Delete; 3 | using Application.Features.Fuels.Commands.Update; 4 | using Application.Features.Fuels.Queries.GetById; 5 | using Application.Features.Fuels.Queries.GetList; 6 | using AutoMapper; 7 | using Core.Application.Responses; 8 | using Core.Persistence.Paging; 9 | using Domain.Entities; 10 | 11 | namespace Application.Features.Fuels.Profiles; 12 | 13 | public class MappingProfiles : Profile 14 | { 15 | public MappingProfiles() 16 | { 17 | CreateMap().ReverseMap(); 18 | CreateMap().ReverseMap(); 19 | CreateMap().ReverseMap(); 20 | CreateMap().ReverseMap(); 21 | CreateMap().ReverseMap(); 22 | CreateMap().ReverseMap(); 23 | CreateMap().ReverseMap(); 24 | CreateMap().ReverseMap(); 25 | CreateMap, GetListResponse>().ReverseMap(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Fuels/Queries/GetById/GetByIdFuelResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Fuels.Queries.GetById; 4 | 5 | public class GetByIdFuelResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Fuels/Queries/GetList/GetListFuelListItemDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Dtos; 2 | 3 | namespace Application.Features.Fuels.Queries.GetList; 4 | 5 | public class GetListFuelListItemDto : IDto 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Fuels/Queries/GetList/GetListFuelQuery.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using AutoMapper; 3 | using Core.Application.Requests; 4 | using Core.Application.Responses; 5 | using Core.Persistence.Paging; 6 | using Domain.Entities; 7 | using MediatR; 8 | 9 | namespace Application.Features.Fuels.Queries.GetList; 10 | 11 | public class GetListFuelQuery : IRequest> 12 | { 13 | public PageRequest PageRequest { get; set; } 14 | 15 | public class GetListFuelQueryHandler : IRequestHandler> 16 | { 17 | private readonly IFuelRepository _fuelRepository; 18 | private readonly IMapper _mapper; 19 | 20 | public GetListFuelQueryHandler(IFuelRepository fuelRepository, IMapper mapper) 21 | { 22 | _fuelRepository = fuelRepository; 23 | _mapper = mapper; 24 | } 25 | 26 | public async Task> Handle(GetListFuelQuery request, CancellationToken cancellationToken) 27 | { 28 | IPaginate fuels = await _fuelRepository.GetListAsync(index: request.PageRequest.Page, size: request.PageRequest.PageSize); 29 | var mappedFuelListModel = _mapper.Map>(fuels); 30 | return mappedFuelListModel; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Fuels/Rules/FuelBusinessRules.cs: -------------------------------------------------------------------------------- 1 | using Application.Features.Fuels.Constants; 2 | using Application.Services.Repositories; 3 | using Core.Application.Rules; 4 | using Core.CrossCuttingConcerns.Exceptions.Types; 5 | using Core.Persistence.Paging; 6 | using Domain.Entities; 7 | 8 | namespace Application.Features.Fuels.Rules; 9 | 10 | public class FuelBusinessRules : BaseBusinessRules 11 | { 12 | private readonly IFuelRepository _fuelRepository; 13 | 14 | public FuelBusinessRules(IFuelRepository fuelRepository) 15 | { 16 | _fuelRepository = fuelRepository; 17 | } 18 | 19 | public async Task FuelIdShouldExistWhenSelected(int id) 20 | { 21 | Fuel? result = await _fuelRepository.GetAsync(predicate: b => b.Id == id, enableTracking: false); 22 | if (result == null) 23 | throw new BusinessException(FuelsMessages.FuelNotExists); 24 | } 25 | 26 | public async Task FuelNameCanNotBeDuplicatedWhenInserted(string name) 27 | { 28 | IPaginate result = await _fuelRepository.GetListAsync(predicate: b => b.Name == name, enableTracking: false); 29 | if (result.Items.Any()) 30 | throw new BusinessException(FuelsMessages.FuelNameExists); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/IndividualCustomers/Commands/Create/CreateIndividualCustomerCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.IndividualCustomers.Commands.Create; 4 | 5 | public class CreateIndividualCustomerCommandValidator : AbstractValidator 6 | { 7 | public CreateIndividualCustomerCommandValidator() 8 | { 9 | RuleFor(c => c.CustomerId).GreaterThan(0); 10 | RuleFor(c => c.FirstName).NotEmpty().MinimumLength(2); 11 | RuleFor(c => c.LastName).NotEmpty().MinimumLength(2); 12 | RuleFor(c => c.NationalIdentity).NotEmpty().MinimumLength(11).MaximumLength(11); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/IndividualCustomers/Commands/Create/CreatedIndividualCustomerResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.IndividualCustomers.Commands.Create; 4 | 5 | public class CreatedIndividualCustomerResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string FirstName { get; set; } 9 | public string LastName { get; set; } 10 | public string NationalIdentity { get; set; } 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/IndividualCustomers/Commands/Delete/DeletedIndividualCustomerResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.IndividualCustomers.Commands.Delete; 4 | 5 | public class DeletedIndividualCustomerResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | } 9 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/IndividualCustomers/Commands/Update/UpdateIndividualCustomerCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.IndividualCustomers.Commands.Update; 4 | 5 | public class UpdateIndividualCustomerCommandValidator : AbstractValidator 6 | { 7 | public UpdateIndividualCustomerCommandValidator() 8 | { 9 | RuleFor(c => c.CustomerId).GreaterThan(0); 10 | RuleFor(c => c.FirstName).NotEmpty().MinimumLength(2); 11 | RuleFor(c => c.LastName).NotEmpty().MinimumLength(2); 12 | RuleFor(c => c.NationalIdentity).NotEmpty().MinimumLength(11).MaximumLength(11); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/IndividualCustomers/Commands/Update/UpdatedIndividualCustomerResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.IndividualCustomers.Commands.Update; 4 | 5 | public class UpdatedIndividualCustomerResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string FirstName { get; set; } 9 | public string LastName { get; set; } 10 | public string NationalIdentity { get; set; } 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/IndividualCustomers/Constants/IndividualCustomersMessages.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.IndividualCustomers.Constants; 2 | 3 | public static class IndividualCustomersMessages 4 | { 5 | public const string IndividualCustomerNotExists = "Individual customer not exists."; 6 | 7 | public const string IndividualCustomerNationalIdentityAlreadyExists = "Individual customer national identity already exists."; 8 | } 9 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/IndividualCustomers/Constants/IndividualCustomersOperationClaims.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.IndividualCustomers.Constants; 2 | 3 | public static class IndividualCustomersOperationClaims 4 | { 5 | public const string Admin = "individualcustomers.admin"; 6 | 7 | public const string Read = "individualcustomers.read"; 8 | public const string Write = "individualcustomers.write"; 9 | 10 | public const string Add = "individualcustomers.add"; 11 | public const string Update = "individualcustomers.update"; 12 | public const string Delete = "individualcustomers.delete"; 13 | } 14 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/IndividualCustomers/Queries/GetByCustomerId/GetByCustomerIdIndividualCustomerResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.IndividualCustomers.Queries.GetByCustomerId; 4 | 5 | public class GetByCustomerIdIndividualCustomerResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string FirstName { get; set; } 9 | public string LastName { get; set; } 10 | public string NationalIdentity { get; set; } 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/IndividualCustomers/Queries/GetById/GetByIdIndividualCustomerResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.IndividualCustomers.Queries.GetById; 4 | 5 | public class GetByIdIndividualCustomerResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string FirstName { get; set; } 9 | public string LastName { get; set; } 10 | public string NationalIdentity { get; set; } 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/IndividualCustomers/Queries/GetList/GetListIndividualCustomerListItemDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Dtos; 2 | 3 | namespace Application.Features.IndividualCustomers.Queries.GetList; 4 | 5 | public class GetListIndividualCustomerListItemDto : IDto 6 | { 7 | public int Id { get; set; } 8 | public string FirstName { get; set; } 9 | public string LastName { get; set; } 10 | public string NationalIdentity { get; set; } 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Invoices/Commands/Create/CreateInvoiceCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.Invoices.Commands.Create; 4 | 5 | public class CreateInvoiceCommandValidator : AbstractValidator 6 | { 7 | public CreateInvoiceCommandValidator() 8 | { 9 | RuleFor(c => c.CustomerId).GreaterThan(0); 10 | RuleFor(c => c.RentalPrice).GreaterThan(0); 11 | RuleFor(c => c.RentalStartDate).LessThan(c => c.RentalEndDate); 12 | RuleFor(c => c.RentalEndDate).GreaterThan(c => c.RentalStartDate); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Invoices/Commands/Create/CreatedInvoiceResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Invoices.Commands.Create; 4 | 5 | public class CreatedInvoiceResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public int CustomerId { get; set; } 9 | public string No { get; set; } 10 | public DateTime CreatedDate { get; set; } 11 | public DateTime RentalStartDate { get; set; } 12 | public DateTime RentalEndDate { get; set; } 13 | public short TotalRentalDate { get; set; } 14 | public decimal RentalPrice { get; set; } 15 | } 16 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Invoices/Commands/Delete/DeletedInvoiceResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Invoices.Commands.Delete; 4 | 5 | public class DeletedInvoiceResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | } 9 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Invoices/Commands/Update/UpdateInvoiceCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.Invoices.Commands.Update; 4 | 5 | public class UpdateInvoiceCommandValidator : AbstractValidator 6 | { 7 | public UpdateInvoiceCommandValidator() 8 | { 9 | RuleFor(c => c.CustomerId).GreaterThan(0); 10 | RuleFor(c => c.RentalPrice).GreaterThan(0); 11 | RuleFor(c => c.RentalStartDate).LessThan(c => c.RentalEndDate); 12 | RuleFor(c => c.RentalEndDate).GreaterThan(c => c.RentalStartDate); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Invoices/Commands/Update/UpdatedInvoiceResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Invoices.Commands.Update; 4 | 5 | public class UpdatedInvoiceResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public int CustomerId { get; set; } 9 | public string No { get; set; } 10 | public DateTime CreatedDate { get; set; } 11 | public DateTime RentalStartDate { get; set; } 12 | public DateTime RentalEndDate { get; set; } 13 | public short TotalRentalDate { get; set; } 14 | public decimal RentalPrice { get; set; } 15 | } 16 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Invoices/Constants/InvoicesMessages.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.Invoices.Constants; 2 | 3 | public static class InvoicesMessages 4 | { 5 | public const string InvoiceNotExists = "Invoice not exists."; 6 | } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Invoices/Constants/InvoicesOperationClaims.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.Invoices.Constants; 2 | 3 | public static class InvoicesOperationClaims 4 | { 5 | public const string Admin = "invoices.admin"; 6 | 7 | public const string Read = "invoices.read"; 8 | public const string Write = "invoices.write"; 9 | 10 | public const string Add = "invoices.add"; 11 | public const string Update = "invoices.update"; 12 | public const string Delete = "invoices.delete"; 13 | } 14 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Invoices/Queries/GetById/GetByIdInvoiceResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Invoices.Queries.GetById; 4 | 5 | public class GetByIdInvoiceResponse : IResponse 6 | { 7 | public int CustomerId { get; set; } 8 | public string No { get; set; } 9 | public DateTime CreatedDate { get; set; } 10 | public DateTime RentalStartDate { get; set; } 11 | public DateTime RentalEndDate { get; set; } 12 | public short TotalRentalDate { get; set; } 13 | public decimal RentalPrice { get; set; } 14 | } 15 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Invoices/Queries/GetList/GetListInvoiceListItemDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Dtos; 2 | 3 | namespace Application.Features.Invoices.Queries.GetList; 4 | 5 | public class GetListInvoiceListItemDto : IDto 6 | { 7 | public int Id { get; set; } 8 | public string CustomerName { get; set; } 9 | public string No { get; set; } 10 | public DateTime CreatedDate { get; set; } 11 | public DateTime RentalStartDate { get; set; } 12 | public DateTime RentalEndDate { get; set; } 13 | public short TotalRentalDate { get; set; } 14 | public decimal RentalPrice { get; set; } 15 | } 16 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Invoices/Queries/GetListByCustomer/GetListByCustomerInvoiceListItemDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Dtos; 2 | 3 | namespace Application.Features.Invoices.Queries.GetListByCustomer; 4 | 5 | public class GetListByCustomerInvoiceListItemDto : IDto 6 | { 7 | public int Id { get; set; } 8 | public string CustomerName { get; set; } 9 | public string No { get; set; } 10 | public DateTime CreatedDate { get; set; } 11 | public DateTime RentalStartDate { get; set; } 12 | public DateTime RentalEndDate { get; set; } 13 | public short TotalRentalDate { get; set; } 14 | public decimal RentalPrice { get; set; } 15 | } 16 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Invoices/Queries/GetListByDates/GetListByDatesInvoiceListItemDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Dtos; 2 | 3 | namespace Application.Features.Invoices.Queries.GetListByDates; 4 | 5 | public class GetListByDatesInvoiceListItemDto : IDto 6 | { 7 | public int Id { get; set; } 8 | public string CustomerName { get; set; } 9 | public string No { get; set; } 10 | public DateTime CreatedDate { get; set; } 11 | public DateTime RentalStartDate { get; set; } 12 | public DateTime RentalEndDate { get; set; } 13 | public short TotalRentalDate { get; set; } 14 | public decimal RentalPrice { get; set; } 15 | } 16 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Invoices/Rules/InvoiceBusinessRules.cs: -------------------------------------------------------------------------------- 1 | using Application.Features.Invoices.Constants; 2 | using Application.Services.Repositories; 3 | using Core.Application.Rules; 4 | using Core.CrossCuttingConcerns.Exceptions.Types; 5 | using Domain.Entities; 6 | 7 | namespace Application.Features.Invoices.Rules; 8 | 9 | public class InvoiceBusinessRules : BaseBusinessRules 10 | { 11 | private readonly IInvoiceRepository _invoiceRepository; 12 | 13 | public InvoiceBusinessRules(IInvoiceRepository invoiceRepository) 14 | { 15 | _invoiceRepository = invoiceRepository; 16 | } 17 | 18 | public async Task InvoiceIdShouldExistWhenSelected(int id) 19 | { 20 | Invoice? result = await _invoiceRepository.GetAsync(predicate: b => b.Id == id, enableTracking: false); 21 | if (result == null) 22 | throw new BusinessException(InvoicesMessages.InvoiceNotExists); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Models/Commands/Create/CreateModelCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.Models.Commands.Create; 4 | 5 | public class CreateModelCommandValidator : AbstractValidator 6 | { 7 | public CreateModelCommandValidator() 8 | { 9 | RuleFor(c => c.Name).MinimumLength(2); 10 | RuleFor(c => c.DailyPrice).GreaterThan(0); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Models/Commands/Create/CreatedModelResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Models.Commands.Create; 4 | 5 | public class CreatedModelResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public int BrandId { get; set; } 9 | public int FuelId { get; set; } 10 | public int TransmissionId { get; set; } 11 | public string Name { get; set; } 12 | public decimal DailyPrice { get; set; } 13 | public string ImageUrl { get; set; } 14 | } 15 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Models/Commands/Delete/DeletedModelResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Models.Commands.Delete; 4 | 5 | public class DeletedModelResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | } 9 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Models/Commands/Update/UpdateModelCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.Models.Commands.Update; 4 | 5 | public class UpdateModelCommandValidator : AbstractValidator 6 | { 7 | public UpdateModelCommandValidator() 8 | { 9 | RuleFor(c => c.Name).MinimumLength(2); 10 | RuleFor(c => c.DailyPrice).GreaterThan(0); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Models/Commands/Update/UpdatedModelResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Models.Commands.Update; 4 | 5 | public class UpdatedModelResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public int BrandId { get; set; } 9 | public int FuelId { get; set; } 10 | public int TransmissionId { get; set; } 11 | public string Name { get; set; } 12 | public decimal DailyPrice { get; set; } 13 | public string ImageUrl { get; set; } 14 | } 15 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Models/Constants/ModelsMessages.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.Models.Constants; 2 | 3 | public static class ModelsMessages 4 | { 5 | public const string ModelNotExists = "Model not exists."; 6 | } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Models/Constants/ModelsOperationClaims.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.Models.Constants; 2 | 3 | public static class ModelsOperationClaims 4 | { 5 | public const string Admin = "models.admin"; 6 | 7 | public const string Read = "models.read"; 8 | public const string Write = "models.write"; 9 | 10 | public const string Add = "models.add"; 11 | public const string Update = "models.update"; 12 | public const string Delete = "models.delete"; 13 | } 14 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Models/Queries/GetById/GetByIdModelResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Models.Queries.GetById; 4 | 5 | public class GetByIdModelResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public int BrandId { get; set; } 9 | public int FuelId { get; set; } 10 | public int TransmissionId { get; set; } 11 | public string Name { get; set; } 12 | public decimal DailyPrice { get; set; } 13 | public string ImageUrl { get; set; } 14 | } 15 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Models/Queries/GetList/GetListModelListItemDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Dtos; 2 | 3 | namespace Application.Features.Models.Queries.GetList; 4 | 5 | public class GetListModelListItemDto : IDto 6 | { 7 | public int Id { get; set; } 8 | public string BrandName { get; set; } 9 | public string FuelName { get; set; } 10 | public string TransmissionName { get; set; } 11 | public string Name { get; set; } 12 | public decimal DailyPrice { get; set; } 13 | public string ImageUrl { get; set; } 14 | } 15 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Models/Queries/GetListByDynamic/GetListByDynamicModelListItemDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Dtos; 2 | 3 | namespace Application.Features.Models.Queries.GetListByDynamic; 4 | 5 | public class GetListByDynamicModelListItemDto : IDto 6 | { 7 | public int Id { get; set; } 8 | public string BrandName { get; set; } 9 | public string FuelName { get; set; } 10 | public string TransmissionName { get; set; } 11 | public string Name { get; set; } 12 | public decimal DailyPrice { get; set; } 13 | public string ImageUrl { get; set; } 14 | } 15 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Models/Rules/ModelBusinessRules.cs: -------------------------------------------------------------------------------- 1 | using Application.Features.Models.Constants; 2 | using Application.Services.Repositories; 3 | using Core.Application.Rules; 4 | using Core.CrossCuttingConcerns.Exceptions.Types; 5 | using Domain.Entities; 6 | 7 | namespace Application.Features.Models.Rules; 8 | 9 | public class ModelBusinessRules : BaseBusinessRules 10 | { 11 | private readonly IModelRepository _modelRepository; 12 | 13 | public ModelBusinessRules(IModelRepository modelRepository) 14 | { 15 | _modelRepository = modelRepository; 16 | } 17 | 18 | public async Task ModelIdShouldExistWhenSelected(int id) 19 | { 20 | Model? result = await _modelRepository.GetAsync(predicate: c => c.Id == id, enableTracking: false); 21 | if (result == null) 22 | throw new BusinessException(ModelsMessages.ModelNotExists); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/OperationClaims/Commands/Create/CreateOperationClaimCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.OperationClaims.Commands.Create; 4 | 5 | public class CreateOperationClaimCommandValidator : AbstractValidator 6 | { 7 | public CreateOperationClaimCommandValidator() 8 | { 9 | RuleFor(c => c.Name).NotEmpty().MinimumLength(2); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/OperationClaims/Commands/Create/CreatedOperationClaimResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.OperationClaims.Commands.Create; 4 | 5 | public class CreatedOperationClaimResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/OperationClaims/Commands/Delete/DeletedOperationClaimResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.OperationClaims.Commands.Delete; 4 | 5 | public class DeletedOperationClaimResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | } 9 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/OperationClaims/Commands/Update/UpdateOperationClaimCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.OperationClaims.Commands.Update; 4 | 5 | public class UpdateOperationClaimCommandValidator : AbstractValidator 6 | { 7 | public UpdateOperationClaimCommandValidator() 8 | { 9 | RuleFor(c => c.Name).NotEmpty().MinimumLength(2); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/OperationClaims/Commands/Update/UpdatedOperationClaimResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.OperationClaims.Commands.Update; 4 | 5 | public class UpdatedOperationClaimResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/OperationClaims/Constants/GeneralOperationClaims.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.OperationClaims.Constants; 2 | 3 | public static class GeneralOperationClaims 4 | { 5 | public const string Admin = "Admin"; 6 | } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/OperationClaims/Constants/OperationClaimsMessages.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.OperationClaims.Constants; 2 | 3 | public static class OperationClaimsMessages 4 | { 5 | public const string OperationClaimNotExists = "Operation Claim not exists."; 6 | } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/OperationClaims/Constants/OperationClaimsOperationClaims.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.OperationClaims.Constants; 2 | 3 | public static class OperationClaimsOperationClaims 4 | { 5 | public const string Admin = "operationclaims.admin"; 6 | 7 | public const string Read = "operationclaims.read"; 8 | public const string Write = "operationclaims.write"; 9 | 10 | public const string Add = "operationclaims.add"; 11 | public const string Update = "operationclaims.update"; 12 | public const string Delete = "operationclaims.delete"; 13 | } 14 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/OperationClaims/Queries/GetById/GetByIdOperationClaimResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.OperationClaims.Queries.GetById; 4 | 5 | public class GetByIdOperationClaimResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/OperationClaims/Queries/GetList/GetListOperationClaimListItemDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Dtos; 2 | 3 | namespace Application.Features.OperationClaims.Queries.GetList; 4 | 5 | public class GetListOperationClaimListItemDto : IDto 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/OperationClaims/Rules/OperationClaimBusinessRules.cs: -------------------------------------------------------------------------------- 1 | using Application.Features.OperationClaims.Constants; 2 | using Application.Services.Repositories; 3 | using Core.Application.Rules; 4 | using Core.CrossCuttingConcerns.Exceptions.Types; 5 | using Core.Security.Entities; 6 | 7 | namespace Application.Features.OperationClaims.Rules; 8 | 9 | public class OperationClaimBusinessRules : BaseBusinessRules 10 | { 11 | private readonly IOperationClaimRepository _operationClaimRepository; 12 | 13 | public OperationClaimBusinessRules(IOperationClaimRepository operationClaimRepository) 14 | { 15 | _operationClaimRepository = operationClaimRepository; 16 | } 17 | 18 | public async Task OperationClaimIdShouldExistWhenSelected(int id) 19 | { 20 | OperationClaim? result = await _operationClaimRepository.GetAsync(predicate: b => b.Id == id, enableTracking: false); 21 | if (result == null) 22 | throw new BusinessException(OperationClaimsMessages.OperationClaimNotExists); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/RentalBranches/Commands/Create/CreateRentalBranchCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.RentalBranches.Commands.Create; 4 | 5 | public class CreateRentalBranchCommandValidator : AbstractValidator 6 | { 7 | public CreateRentalBranchCommandValidator() 8 | { 9 | RuleFor(c => c.City).NotEmpty(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/RentalBranches/Commands/Create/CreatedRentalBranchResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | using Domain.Enums; 3 | 4 | namespace Application.Features.RentalBranches.Commands.Create; 5 | 6 | public class CreatedRentalBranchResponse : IResponse 7 | { 8 | public int Id { get; set; } 9 | public City City { get; set; } 10 | } 11 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/RentalBranches/Commands/Delete/DeletedRentalBranchResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.RentalBranches.Commands.Delete; 4 | 5 | public class DeletedRentalBranchResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | } 9 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/RentalBranches/Commands/Update/UpdateRentalBranchCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.RentalBranches.Commands.Update; 4 | 5 | public class UpdateRentalBranchCommandValidator : AbstractValidator 6 | { 7 | public UpdateRentalBranchCommandValidator() 8 | { 9 | RuleFor(c => c.City).NotEmpty(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/RentalBranches/Commands/Update/UpdatedRentalBranchResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | using Domain.Enums; 3 | 4 | namespace Application.Features.RentalBranches.Commands.Update; 5 | 6 | public class UpdatedRentalBranchResponse : IResponse 7 | { 8 | public int Id { get; set; } 9 | public City City { get; set; } 10 | } 11 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/RentalBranches/Constants/RentalBranchesMessages.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.RentalBranches.Constants; 2 | 3 | public static class RentalBranchesMessages 4 | { 5 | public const string RentalBranchNotExists = "Rental Branch not exists."; 6 | } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/RentalBranches/Constants/RentalBranchesOperationClaims.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.RentalBranches.Constants; 2 | 3 | public static class RentalBranchesOperationClaims 4 | { 5 | public const string Admin = "rentalbranches.admin"; 6 | 7 | public const string Read = "rentalbranches.read"; 8 | public const string Write = "rentalbranches.write"; 9 | 10 | public const string Add = "rentalbranches.add"; 11 | public const string Update = "rentalbranches.update"; 12 | public const string Delete = "rentalbranches.delete"; 13 | } 14 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/RentalBranches/Profiles/MappingProfiles.cs: -------------------------------------------------------------------------------- 1 | using Application.Features.RentalBranches.Commands.Create; 2 | using Application.Features.RentalBranches.Commands.Delete; 3 | using Application.Features.RentalBranches.Commands.Update; 4 | using Application.Features.RentalBranches.Queries.GetById; 5 | using Application.Features.RentalBranches.Queries.GetList; 6 | using AutoMapper; 7 | using Core.Application.Responses; 8 | using Core.Persistence.Paging; 9 | using Domain.Entities; 10 | 11 | namespace Application.Features.RentalBranches.Profiles; 12 | 13 | public class MappingProfiles : Profile 14 | { 15 | public MappingProfiles() 16 | { 17 | CreateMap().ReverseMap(); 18 | CreateMap().ReverseMap(); 19 | CreateMap().ReverseMap(); 20 | CreateMap().ReverseMap(); 21 | CreateMap().ReverseMap(); 22 | CreateMap().ReverseMap(); 23 | CreateMap().ReverseMap(); 24 | CreateMap().ReverseMap(); 25 | CreateMap, GetListResponse>().ReverseMap(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/RentalBranches/Queries/GetById/GetByIdRentalBranchResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | using Domain.Enums; 3 | 4 | namespace Application.Features.RentalBranches.Queries.GetById; 5 | 6 | public class GetByIdRentalBranchResponse : IResponse 7 | { 8 | public int Id { get; set; } 9 | public City City { get; set; } 10 | } 11 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/RentalBranches/Queries/GetList/GetListRentalBranchListItemDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Dtos; 2 | using Domain.Enums; 3 | 4 | namespace Application.Features.RentalBranches.Queries.GetList; 5 | 6 | public class GetListRentalBranchListItemDto : IDto 7 | { 8 | public int Id { get; set; } 9 | public City City { get; set; } 10 | } 11 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/RentalBranches/Rules/RentalBranchBusinessRules.cs: -------------------------------------------------------------------------------- 1 | using Application.Features.RentalBranches.Constants; 2 | using Application.Services.Repositories; 3 | using Core.Application.Rules; 4 | using Core.CrossCuttingConcerns.Exceptions.Types; 5 | using Domain.Entities; 6 | 7 | namespace Application.Features.RentalBranches.Rules; 8 | 9 | public class RentalBranchBusinessRules : BaseBusinessRules 10 | { 11 | private readonly IRentalBranchRepository _rentalBranchRepository; 12 | 13 | public RentalBranchBusinessRules(IRentalBranchRepository rentalBranchRepository) 14 | { 15 | _rentalBranchRepository = rentalBranchRepository; 16 | } 17 | 18 | public async Task RentalBranchIdShouldExistWhenSelected(int id) 19 | { 20 | RentalBranch? result = await _rentalBranchRepository.GetAsync(predicate: b => b.Id == id, enableTracking: false); 21 | if (result == null) 22 | throw new BusinessException(RentalBranchesMessages.RentalBranchNotExists); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Rentals/Commands/Create/CreateRentalCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.Rentals.Commands.Create; 4 | 5 | public class CreateRentalCommandValidator : AbstractValidator 6 | { 7 | public CreateRentalCommandValidator() 8 | { 9 | RuleFor(c => c.RentStartDate).GreaterThan(DateTime.Now).LessThan(c => c.RentEndDate); 10 | RuleFor(c => c.RentEndDate).GreaterThan(c => c.RentStartDate); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Rentals/Commands/Create/CreatedRentalResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Rentals.Commands.Create; 4 | 5 | public class CreatedRentalResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string CarModelBrandName { get; set; } 9 | public string CarModelName { get; set; } 10 | public string CarColorName { get; set; } 11 | public short CarModelYear { get; set; } 12 | public string CarPlate { get; set; } 13 | public string CustomerFullName { get; set; } 14 | public string CustomerMail { get; set; } 15 | public DateTime RentStartDate { get; set; } 16 | public DateTime RentEndDate { get; set; } 17 | public DateTime? ReturnDate { get; set; } 18 | } 19 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Rentals/Commands/Delete/DeletedRentalResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Rentals.Commands.Delete; 4 | 5 | public class DeletedRentalResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | } 9 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Rentals/Commands/PickUp/PickUpRentalCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.Rentals.Commands.PickUp; 4 | 5 | public class PickUpRentalCommandValidator : AbstractValidator 6 | { 7 | public PickUpRentalCommandValidator() 8 | { 9 | RuleFor(c => c.RentEndRentalBranchId).GreaterThan(0); 10 | RuleFor(c => c.RentEndKilometer).GreaterThan(0); 11 | RuleFor(c => c.ReturnDate).GreaterThan(DateTime.Now); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Rentals/Commands/PickUp/PickUpRentalResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Rentals.Commands.PickUp; 4 | 5 | public class PickUpRentalResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public int CarId { get; set; } 9 | public int CustomerId { get; set; } 10 | public int RentStartRentalBranchId { get; set; } 11 | public int? RentEndRentalBranchId { get; set; } 12 | public DateTime RentStartDate { get; set; } 13 | public DateTime RentEndDate { get; set; } 14 | public DateTime? ReturnDate { get; set; } 15 | public int RentStartKilometer { get; set; } 16 | public int? RentEndKilometer { get; set; } 17 | } 18 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Rentals/Commands/Update/UpdateRentalCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.Rentals.Commands.Update; 4 | 5 | public class UpdateRentalCommandValidator : AbstractValidator 6 | { 7 | public UpdateRentalCommandValidator() 8 | { 9 | RuleFor(c => c.RentStartDate).LessThan(c => c.RentEndDate); 10 | RuleFor(c => c.RentEndDate).GreaterThan(c => c.RentStartDate); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Rentals/Commands/Update/UpdatedRentalResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Rentals.Commands.Update; 4 | 5 | public class UpdatedRentalResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public int CarId { get; set; } 9 | public int CustomerId { get; set; } 10 | public int RentStartRentalBranchId { get; set; } 11 | public int? RentEndRentalBranchId { get; set; } 12 | public DateTime RentStartDate { get; set; } 13 | public DateTime RentEndDate { get; set; } 14 | public DateTime? ReturnDate { get; set; } 15 | public int RentStartKilometer { get; set; } 16 | public int? RentEndKilometer { get; set; } 17 | } 18 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Rentals/Constants/RentalsMessages.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.Rentals.Constants; 2 | 3 | public static class RentalsMessages 4 | { 5 | public const string RentalNotExists = "Rental not exists."; 6 | 7 | public const string RentalCanNotBeUpdatedWhenThereIsAnotherRentedCarForTheDate = 8 | "Rental can't be updated when there is another rented car for the date."; 9 | 10 | public const string RentalCanNotBeCreatedWhenCustomerFindeksCreditScoreLowerThanCarMinFindeksScore = 11 | "Rental can not be created when customer findeks credit score lower than car min findeks score."; 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Rentals/Constants/RentalsOperationClaims.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.Rentals.Constants; 2 | 3 | public static class RentalsOperationClaims 4 | { 5 | public const string Admin = "rentals.admin"; 6 | 7 | public const string Read = "rentals.read"; 8 | public const string Write = "rentals.write"; 9 | 10 | public const string Update = "rentals.update"; 11 | public const string Delete = "rentals.delete"; 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Rentals/Queries/GetById/GetByIdRentalResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Rentals.Queries.GetById; 4 | 5 | public class GetByIdRentalResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public int CarId { get; set; } 9 | public int CustomerId { get; set; } 10 | public int RentStartRentalBranchId { get; set; } 11 | public int? RentEndRentalBranchId { get; set; } 12 | public DateTime RentStartDate { get; set; } 13 | public DateTime RentEndDate { get; set; } 14 | public DateTime? ReturnDate { get; set; } 15 | public int RentStartKilometer { get; set; } 16 | public int? RentEndKilometer { get; set; } 17 | } 18 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Rentals/Queries/GetList/GetListRentalListItemDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Dtos; 2 | 3 | namespace Application.Features.Rentals.Queries.GetList; 4 | 5 | public class GetListRentalListItemDto : IDto 6 | { 7 | public int Id { get; set; } 8 | public string CarModelBrandName { get; set; } 9 | public string CarModelName { get; set; } 10 | public string CarColorName { get; set; } 11 | public short CarModelYear { get; set; } 12 | public string CarPlate { get; set; } 13 | public string CustomerFullName { get; set; } 14 | public string CustomerMail { get; set; } 15 | public DateTime RentStartDate { get; set; } 16 | public DateTime RentEndDate { get; set; } 17 | public DateTime? ReturnDate { get; set; } 18 | } 19 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Transmissions/Commands/Create/CreateTransmissionCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.Transmissions.Commands.Create; 4 | 5 | public class CreateTransmissionCommandValidator : AbstractValidator 6 | { 7 | public CreateTransmissionCommandValidator() 8 | { 9 | RuleFor(c => c.Name).NotEmpty().MinimumLength(2); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Transmissions/Commands/Create/CreatedTransmissionResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Transmissions.Commands.Create; 4 | 5 | public class CreatedTransmissionResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Transmissions/Commands/Delete/DeletedTransmissionResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Transmissions.Commands.Delete; 4 | 5 | public class DeletedTransmissionResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | } 9 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Transmissions/Commands/Update/UpdateTransmissionCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.Transmissions.Commands.Update; 4 | 5 | public class UpdateTransmissionCommandValidator : AbstractValidator 6 | { 7 | public UpdateTransmissionCommandValidator() 8 | { 9 | RuleFor(c => c.Name).NotEmpty().MinimumLength(2); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Transmissions/Commands/Update/UpdatedTransmissionResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Transmissions.Commands.Update; 4 | 5 | public class UpdatedTransmissionResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Transmissions/Constants/TransmissionsMessages.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.Transmissions.Constants; 2 | 3 | public static class TransmissionsMessages 4 | { 5 | public const string TransmissionNotExists = "Transmission not exists."; 6 | public const string TransmissionNameExists = "Transmission name exists."; 7 | } 8 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Transmissions/Constants/TransmissionsOperationClaims.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.Transmissions.Constants; 2 | 3 | public static class TransmissionsOperationClaims 4 | { 5 | public const string Admin = "transmissions.admin"; 6 | 7 | public const string Read = "transmissions.read"; 8 | public const string Write = "transmissions.write"; 9 | 10 | public const string Add = "transmissions.add"; 11 | public const string Update = "transmissions.update"; 12 | public const string Delete = "transmissions.delete"; 13 | } 14 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Transmissions/Profiles/MappingProfiles.cs: -------------------------------------------------------------------------------- 1 | using Application.Features.Transmissions.Commands.Create; 2 | using Application.Features.Transmissions.Commands.Delete; 3 | using Application.Features.Transmissions.Commands.Update; 4 | using Application.Features.Transmissions.Queries.GetById; 5 | using Application.Features.Transmissions.Queries.GetList; 6 | using AutoMapper; 7 | using Core.Application.Responses; 8 | using Core.Persistence.Paging; 9 | using Domain.Entities; 10 | 11 | namespace Application.Features.Transmissions.Profiles; 12 | 13 | public class MappingProfiles : Profile 14 | { 15 | public MappingProfiles() 16 | { 17 | CreateMap().ReverseMap(); 18 | CreateMap().ReverseMap(); 19 | CreateMap().ReverseMap(); 20 | CreateMap().ReverseMap(); 21 | CreateMap().ReverseMap(); 22 | CreateMap().ReverseMap(); 23 | CreateMap().ReverseMap(); 24 | CreateMap().ReverseMap(); 25 | CreateMap, GetListResponse>().ReverseMap(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Transmissions/Queries/GetById/GetByIdTransmissionResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Transmissions.Queries.GetById; 4 | 5 | public class GetByIdTransmissionResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Transmissions/Queries/GetList/GetListTransmissionListItemDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Dtos; 2 | 3 | namespace Application.Features.Transmissions.Queries.GetList; 4 | 5 | public class GetListTransmissionListItemDto : IDto 6 | { 7 | public int Id { get; set; } 8 | public string Name { get; set; } 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/UserOperationClaims/Commands/Create/CreateUserOperationClaimCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.UserOperationClaims.Commands.Create; 4 | 5 | public class CreateUserOperationClaimCommandValidator : AbstractValidator 6 | { 7 | public CreateUserOperationClaimCommandValidator() 8 | { 9 | RuleFor(c => c.UserId).GreaterThan(0); 10 | RuleFor(c => c.OperationClaimId).GreaterThan(0); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/UserOperationClaims/Commands/Create/CreatedUserOperationClaimResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.UserOperationClaims.Commands.Create; 4 | 5 | public class CreatedUserOperationClaimResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public int UserId { get; set; } 9 | public int OperationClaimId { get; set; } 10 | } 11 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/UserOperationClaims/Commands/Delete/DeletedUserOperationClaimResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.UserOperationClaims.Commands.Delete; 4 | 5 | public class DeletedUserOperationClaimResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | } 9 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/UserOperationClaims/Commands/Update/UpdateUserOperationClaimCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.UserOperationClaims.Commands.Update; 4 | 5 | public class UpdateUserOperationClaimCommandValidator : AbstractValidator 6 | { 7 | public UpdateUserOperationClaimCommandValidator() 8 | { 9 | RuleFor(c => c.UserId).GreaterThan(0); 10 | RuleFor(c => c.OperationClaimId).GreaterThan(0); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/UserOperationClaims/Commands/Update/UpdatedUserOperationClaimResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.UserOperationClaims.Commands.Update; 4 | 5 | public class UpdatedUserOperationClaimResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public int UserId { get; set; } 9 | public int OperationClaimId { get; set; } 10 | } 11 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/UserOperationClaims/Constants/UserOperationClaimsMessages.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.UserOperationClaims.Constants; 2 | 3 | public static class UserOperationClaimsMessages 4 | { 5 | public const string UserOperationClaimNotExists = "UserOperationClaim not exists."; 6 | } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/UserOperationClaims/Constants/UserOperationClaimsOperationClaims.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.UserOperationClaims.Constants; 2 | 3 | public static class UserOperationClaimsOperationClaims 4 | { 5 | public const string Admin = "useroperationclaims.admin"; 6 | 7 | public const string Read = "useroperationclaims.read"; 8 | public const string Write = "useroperationclaims.write"; 9 | 10 | public const string Add = "useroperationclaims.add"; 11 | public const string Update = "useroperationclaims.update"; 12 | public const string Delete = "useroperationclaims.delete"; 13 | } 14 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/UserOperationClaims/Queries/GetById/GetByIdUserOperationClaimResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.UserOperationClaims.Queries.GetById; 4 | 5 | public class GetByIdUserOperationClaimResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public int UserId { get; set; } 9 | public int OperationClaimId { get; set; } 10 | } 11 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/UserOperationClaims/Queries/GetList/GetListUserOperationClaimListItemDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Dtos; 2 | 3 | namespace Application.Features.UserOperationClaims.Queries.GetList; 4 | 5 | public class GetListUserOperationClaimListItemDto : IDto 6 | { 7 | public int Id { get; set; } 8 | public int UserId { get; set; } 9 | public int OperationClaimId { get; set; } 10 | } 11 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/UserOperationClaims/Rules/UserOperationClaimBusinessRules.cs: -------------------------------------------------------------------------------- 1 | using Application.Features.UserOperationClaims.Constants; 2 | using Application.Services.Repositories; 3 | using Core.Application.Rules; 4 | using Core.CrossCuttingConcerns.Exceptions.Types; 5 | using Core.Security.Entities; 6 | 7 | namespace Application.Features.UserOperationClaims.Rules; 8 | 9 | public class UserOperationClaimBusinessRules : BaseBusinessRules 10 | { 11 | private readonly IUserOperationClaimRepository _userOperationClaimRepository; 12 | 13 | public UserOperationClaimBusinessRules(IUserOperationClaimRepository userOperationClaimRepository) 14 | { 15 | _userOperationClaimRepository = userOperationClaimRepository; 16 | } 17 | 18 | public async Task UserOperationClaimIdShouldExistWhenSelected(int id) 19 | { 20 | UserOperationClaim? result = await _userOperationClaimRepository.GetAsync(predicate: b => b.Id == id, enableTracking: false); 21 | if (result == null) 22 | throw new BusinessException(UserOperationClaimsMessages.UserOperationClaimNotExists); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Users/Commands/Create/CreateUserCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.Users.Commands.Create; 4 | 5 | public class CreateUserCommandValidator : AbstractValidator 6 | { 7 | public CreateUserCommandValidator() 8 | { 9 | RuleFor(c => c.FirstName).NotEmpty().MinimumLength(2); 10 | RuleFor(c => c.LastName).NotEmpty().MinimumLength(2); 11 | RuleFor(c => c.Email).NotEmpty().EmailAddress(); 12 | RuleFor(c => c.Password).NotEmpty().MinimumLength(4); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Users/Commands/Create/CreatedUserResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Users.Commands.Create; 4 | 5 | public class CreatedUserResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string FirstName { get; set; } 9 | public string LastName { get; set; } 10 | public string Email { get; set; } 11 | public bool Status { get; set; } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Users/Commands/Delete/DeletedUserResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Users.Commands.Delete; 4 | 5 | public class DeletedUserResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | } 9 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Users/Commands/Update/UpdateUserCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.Users.Commands.Update; 4 | 5 | public class UpdateUserCommandValidator : AbstractValidator 6 | { 7 | public UpdateUserCommandValidator() 8 | { 9 | RuleFor(c => c.FirstName).NotEmpty().MinimumLength(2); 10 | RuleFor(c => c.LastName).NotEmpty().MinimumLength(2); 11 | RuleFor(c => c.Email).NotEmpty().EmailAddress(); 12 | RuleFor(c => c.Password).NotEmpty().MinimumLength(4); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Users/Commands/Update/UpdatedUserResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Users.Commands.Update; 4 | 5 | public class UpdatedUserResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string FirstName { get; set; } 9 | public string LastName { get; set; } 10 | public string Email { get; set; } 11 | public bool Status { get; set; } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Users/Commands/UpdateFromAuth/UpdateUserFromAuthCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | 3 | namespace Application.Features.Users.Commands.UpdateFromAuth; 4 | 5 | public class UpdateUserFromAuthCommandValidator : AbstractValidator 6 | { 7 | public UpdateUserFromAuthCommandValidator() 8 | { 9 | RuleFor(c => c.FirstName).NotEmpty().MinimumLength(2); 10 | RuleFor(c => c.LastName).NotEmpty().MinimumLength(2); 11 | RuleFor(c => c.Password).NotEmpty().MinimumLength(4); 12 | RuleFor(c => c.NewPassword).NotEmpty().MinimumLength(4).Equal(c => c.Password); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Users/Commands/UpdateFromAuth/UpdatedUserFromAuthResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | using Core.Security.JWT; 3 | 4 | namespace Application.Features.Users.Commands.UpdateFromAuth; 5 | 6 | public class UpdatedUserFromAuthResponse : IResponse 7 | { 8 | public int Id { get; set; } 9 | public string FirstName { get; set; } 10 | public string LastName { get; set; } 11 | public string Email { get; set; } 12 | public AccessToken AccessToken { get; set; } 13 | } 14 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Users/Constants/UsersOperationClaims.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Features.Users.Constants; 2 | 3 | public static class UsersOperationClaims 4 | { 5 | public const string Admin = "users.admin"; 6 | 7 | public const string Read = "users.read"; 8 | public const string Write = "users.write"; 9 | 10 | public const string Add = "users.add"; 11 | public const string Update = "users.update"; 12 | public const string Delete = "users.delete"; 13 | } 14 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Users/Queries/GetById/GetByIdUserResponse.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Responses; 2 | 3 | namespace Application.Features.Users.Queries.GetById; 4 | 5 | public class GetByIdUserResponse : IResponse 6 | { 7 | public int Id { get; set; } 8 | public string FirstName { get; set; } 9 | public string LastName { get; set; } 10 | public string Email { get; set; } 11 | public bool Status { get; set; } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Application/Features/Users/Queries/GetList/GetListUserListItemDto.cs: -------------------------------------------------------------------------------- 1 | using Core.Application.Dtos; 2 | 3 | namespace Application.Features.Users.Queries.GetList; 4 | 5 | public class GetListUserListItemDto : IDto 6 | { 7 | public int Id { get; set; } 8 | public string FirstName { get; set; } 9 | public string LastName { get; set; } 10 | public string Email { get; set; } 11 | public bool Status { get; set; } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/AdditionalServiceService/AdditionalServiceManager.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Domain.Entities; 3 | 4 | namespace Application.Services.AdditionalServiceService; 5 | 6 | public class AdditionalServiceManager : IAdditionalServiceService 7 | { 8 | private readonly IAdditionalServiceRepository _additionalServiceRepository; 9 | 10 | public AdditionalServiceManager(IAdditionalServiceRepository additionalServiceRepository) 11 | { 12 | _additionalServiceRepository = additionalServiceRepository; 13 | } 14 | 15 | public async Task> GetListByIds(int[] ids) 16 | { 17 | IList additionalServices = (await _additionalServiceRepository.GetListAsync(a => ids.Contains(a.Id))).Items; 18 | 19 | return additionalServices; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/AdditionalServiceService/IAdditionalServiceService.cs: -------------------------------------------------------------------------------- 1 | using Domain.Entities; 2 | 3 | namespace Application.Services.AdditionalServiceService; 4 | 5 | public interface IAdditionalServiceService 6 | { 7 | public Task> GetListByIds(int[] ids); 8 | } 9 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/AuthService/IAuthService.cs: -------------------------------------------------------------------------------- 1 | using Core.Security.Entities; 2 | using Core.Security.JWT; 3 | 4 | namespace Application.Services.AuthService; 5 | 6 | public interface IAuthService 7 | { 8 | public Task CreateAccessToken(User user); 9 | public Task CreateRefreshToken(User user, string ipAddress); 10 | public Task GetRefreshTokenByToken(string token); 11 | public Task AddRefreshToken(RefreshToken refreshToken); 12 | public Task DeleteOldRefreshTokens(int userId); 13 | public Task RevokeDescendantRefreshTokens(RefreshToken refreshToken, string ipAddress, string reason); 14 | 15 | public Task RevokeRefreshToken(RefreshToken token, string ipAddress, string? reason = null, string? replacedByToken = null); 16 | 17 | public Task RotateRefreshToken(User user, RefreshToken refreshToken, string ipAddress); 18 | } 19 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/AuthenticatorService/IAuthenticatorService.cs: -------------------------------------------------------------------------------- 1 | using Core.Security.Entities; 2 | 3 | namespace Application.Services.AuthenticatorService; 4 | 5 | public interface IAuthenticatorService 6 | { 7 | public Task CreateEmailAuthenticator(User user); 8 | public Task CreateOtpAuthenticator(User user); 9 | public Task ConvertSecretKeyToString(byte[] secretKey); 10 | public Task SendAuthenticatorCode(User user); 11 | public Task VerifyAuthenticatorCode(User user, string authenticatorCode); 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/CarService/ICarService.cs: -------------------------------------------------------------------------------- 1 | using Domain.Entities; 2 | 3 | namespace Application.Services.CarService; 4 | 5 | public interface ICarService 6 | { 7 | public Task GetById(int Id); 8 | public Task PickUpCar(Rental rental); 9 | 10 | public Task GetAvailableCarToRent(int modelId, int rentStartRentalBranch, DateTime rentStartDate, DateTime rentEndDate); 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/CustomerService/CustomerManager.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Domain.Entities; 3 | 4 | namespace Application.Services.CustomerService; 5 | 6 | public class CustomerManager : ICustomerService 7 | { 8 | private readonly ICustomerRepository _customerRepository; 9 | 10 | public CustomerManager(ICustomerRepository customerRepository) 11 | { 12 | _customerRepository = customerRepository; 13 | } 14 | 15 | public async Task GetByUserId(int userId) 16 | { 17 | Customer? customer = await _customerRepository.GetAsync(c => c.UserId == userId); 18 | return customer; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/CustomerService/ICustomerService.cs: -------------------------------------------------------------------------------- 1 | using Domain.Entities; 2 | 3 | namespace Application.Services.CustomerService; 4 | 5 | public interface ICustomerService 6 | { 7 | public Task GetByUserId(int userId); 8 | } 9 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/FindeksCreditRateService/FindeksCreditRateManager.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Core.CrossCuttingConcerns.Exceptions.Types; 3 | using Domain.Entities; 4 | 5 | namespace Application.Services.FindeksCreditRateService; 6 | 7 | public class FindeksCreditRateManager : IFindeksCreditRateService 8 | { 9 | private readonly IFindeksCreditRateRepository _findeksCreditRateRepository; 10 | 11 | public FindeksCreditRateManager(IFindeksCreditRateRepository findeksCreditRateRepository) 12 | { 13 | _findeksCreditRateRepository = findeksCreditRateRepository; 14 | } 15 | 16 | public async Task GetFindeksCreditRateByCustomerId(int customerId) 17 | { 18 | FindeksCreditRate findeksCreditRate = await _findeksCreditRateRepository.GetAsync(f => f.CustomerId == customerId); 19 | if (findeksCreditRate == null) 20 | throw new BusinessException("Customer's findeks score do not exists."); 21 | return findeksCreditRate; 22 | } 23 | 24 | public async Task Add(FindeksCreditRate findeksCreditRate) 25 | { 26 | FindeksCreditRate addedFindeksCreditRate = await _findeksCreditRateRepository.AddAsync(findeksCreditRate); 27 | return addedFindeksCreditRate; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/FindeksCreditRateService/IFindeksCreditRateService.cs: -------------------------------------------------------------------------------- 1 | using Domain.Entities; 2 | 3 | namespace Application.Services.FindeksCreditRateService; 4 | 5 | public interface IFindeksCreditRateService 6 | { 7 | public Task GetFindeksCreditRateByCustomerId(int customerId); 8 | 9 | public Task Add(FindeksCreditRate findeksCreditRate); 10 | } 11 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/FindeksService/IFindeksService.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Services.FindeksService; 2 | 3 | public interface IFindeksService 4 | { 5 | short GetScore(string identityNumber); 6 | } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/ImageService/ImageServiceBase.cs: -------------------------------------------------------------------------------- 1 | using Core.CrossCuttingConcerns.Exceptions.Types; 2 | using Microsoft.AspNetCore.Http; 3 | 4 | namespace Application.Services.ImageService; 5 | 6 | public abstract class ImageServiceBase 7 | { 8 | public abstract Task UploadAsync(IFormFile formFile); 9 | 10 | public async Task UpdateAsync(IFormFile formFile, string imageUrl) 11 | { 12 | await FileMustBeInImageFormat(formFile); 13 | 14 | await DeleteAsync(imageUrl); 15 | return await UploadAsync(formFile); 16 | } 17 | 18 | public abstract Task DeleteAsync(string imageUrl); 19 | 20 | protected async Task FileMustBeInImageFormat(IFormFile formFile) 21 | { 22 | List extensions = new() { ".jpg", ".png", ".jpeg", ".webp" }; 23 | 24 | string extension = Path.GetExtension(formFile.FileName).ToLower(); 25 | if (!extensions.Contains(extension)) 26 | throw new BusinessException("Unsupported format"); 27 | await Task.CompletedTask; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/InvoiceService/IInvoiceService.cs: -------------------------------------------------------------------------------- 1 | using Domain.Entities; 2 | 3 | namespace Application.Services.InvoiceService; 4 | 5 | public interface IInvoiceService 6 | { 7 | public Task CreateInvoice(Rental rental, decimal dailyPrice); 8 | public Task Add(Invoice invoice); 9 | } 10 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/ModelService/IModelService.cs: -------------------------------------------------------------------------------- 1 | using Domain.Entities; 2 | 3 | namespace Application.Services.ModelService; 4 | 5 | public interface IModelService 6 | { 7 | public Task GetById(int id); 8 | } 9 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/ModelService/ModelManager.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Core.CrossCuttingConcerns.Exceptions.Types; 3 | using Domain.Entities; 4 | 5 | namespace Application.Services.ModelService; 6 | 7 | public class ModelManager : IModelService 8 | { 9 | private readonly IModelRepository _modelRepository; 10 | 11 | public ModelManager(IModelRepository modelRepository) 12 | { 13 | _modelRepository = modelRepository; 14 | } 15 | 16 | public async Task GetById(int id) 17 | { 18 | Model model = await _modelRepository.GetAsync(m => m.Id == id); 19 | if (model == null) 20 | throw new BusinessException("Model doesn't exist."); 21 | return model; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/POSService/IPOSService.cs: -------------------------------------------------------------------------------- 1 | namespace Application.Services.POSService; 2 | 3 | public interface IPOSService 4 | { 5 | Task Pay(string invoiceNo, decimal price); //todo: credit card etc. 6 | } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/RentalService/IRentalService.cs: -------------------------------------------------------------------------------- 1 | using Domain.Entities; 2 | 3 | namespace Application.Services.RentalService; 4 | 5 | public interface IRentalService 6 | { 7 | Task> GetAllByInDates(int carId, DateTime rentStartDate, DateTime rentEndDate); 8 | } 9 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/RentalService/RentalManager.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Domain.Entities; 3 | 4 | namespace Application.Services.RentalService; 5 | 6 | public class RentalManager : IRentalService 7 | { 8 | private readonly IRentalRepository _rentalRepository; 9 | 10 | public RentalManager(IRentalRepository rentalRepository) 11 | { 12 | _rentalRepository = rentalRepository; 13 | } 14 | 15 | public async Task> GetAllByInDates(int carId, DateTime rentStartDate, DateTime rentEndDate) 16 | { 17 | IList rentals = ( 18 | await _rentalRepository.GetListAsync(r => r.CarId == carId && r.RentEndDate >= rentStartDate && r.RentStartDate <= rentEndDate) 19 | ).Items; 20 | return rentals; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/RentalsIAdditionalServiceService/IRentalsAdditionalServiceService.cs: -------------------------------------------------------------------------------- 1 | using Domain.Entities; 2 | 3 | namespace Application.Services.RentalsIAdditionalServiceService; 4 | 5 | public interface IRentalsAdditionalServiceService 6 | { 7 | public Task> AddManyByRentalIdAndAdditionalServices( 8 | int rentalId, 9 | IList additionalServices 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/RentalsIAdditionalServiceService/RentalsAdditionalServiceManager.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Domain.Entities; 3 | 4 | namespace Application.Services.RentalsIAdditionalServiceService; 5 | 6 | public class RentalsAdditionalServiceManager : IRentalsAdditionalServiceService 7 | { 8 | private readonly IRentalsAdditionalServiceRepository _additionalServiceRepository; 9 | 10 | public RentalsAdditionalServiceManager(IRentalsAdditionalServiceRepository additionalServiceRepository) 11 | { 12 | _additionalServiceRepository = additionalServiceRepository; 13 | } 14 | 15 | public async Task> AddManyByRentalIdAndAdditionalServices( 16 | int rentalId, 17 | IList additionalServices 18 | ) 19 | { 20 | IList rentalsAdditionalServices = additionalServices 21 | .Select(a => new RentalsAdditionalService { RentalId = rentalId, AdditionalServiceId = a.Id }) 22 | .ToList(); 23 | 24 | foreach (RentalsAdditionalService rentalsAdditionalService in rentalsAdditionalServices) 25 | await _additionalServiceRepository.AddAsync(rentalsAdditionalService); 26 | 27 | return rentalsAdditionalServices; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/Repositories/IAdditionalServiceRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | using Domain.Entities; 3 | 4 | namespace Application.Services.Repositories; 5 | 6 | public interface IAdditionalServiceRepository : IAsyncRepository, IRepository { } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/Repositories/IBrandRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | using Domain.Entities; 3 | 4 | namespace Application.Services.Repositories; 5 | 6 | public interface IBrandRepository : IAsyncRepository, IRepository { } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/Repositories/ICarDamageRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | using Domain.Entities; 3 | 4 | namespace Application.Services.Repositories; 5 | 6 | public interface ICarDamageRepository : IAsyncRepository, IRepository { } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/Repositories/ICarRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | using Domain.Entities; 3 | 4 | namespace Application.Services.Repositories; 5 | 6 | public interface ICarRepository : IAsyncRepository, IRepository { } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/Repositories/IColorRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | using Domain.Entities; 3 | 4 | namespace Application.Services.Repositories; 5 | 6 | public interface IColorRepository : IAsyncRepository, IRepository { } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/Repositories/ICorporateCustomerRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | using Domain.Entities; 3 | 4 | namespace Application.Services.Repositories; 5 | 6 | public interface ICorporateCustomerRepository : IAsyncRepository, IRepository { } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/Repositories/ICustomerRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | using Domain.Entities; 3 | 4 | namespace Application.Services.Repositories; 5 | 6 | public interface ICustomerRepository : IAsyncRepository, IRepository { } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/Repositories/IEmailAuthenticatorRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | using Core.Security.Entities; 3 | 4 | namespace Application.Services.Repositories; 5 | 6 | public interface IEmailAuthenticatorRepository : IAsyncRepository, IRepository { } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/Repositories/IFindeksCreditRateRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | using Domain.Entities; 3 | 4 | namespace Application.Services.Repositories; 5 | 6 | public interface IFindeksCreditRateRepository : IAsyncRepository, IRepository { } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/Repositories/IFuelRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | using Domain.Entities; 3 | 4 | namespace Application.Services.Repositories; 5 | 6 | public interface IFuelRepository : IAsyncRepository, IRepository { } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/Repositories/IIndividualCustomerRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | using Domain.Entities; 3 | 4 | namespace Application.Services.Repositories; 5 | 6 | public interface IIndividualCustomerRepository : IAsyncRepository, IRepository { } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/Repositories/IInvoiceRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | using Domain.Entities; 3 | 4 | namespace Application.Services.Repositories; 5 | 6 | public interface IInvoiceRepository : IAsyncRepository, IRepository { } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/Repositories/IModelRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | using Domain.Entities; 3 | 4 | namespace Application.Services.Repositories; 5 | 6 | public interface IModelRepository : IAsyncRepository, IRepository { } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/Repositories/IOperationClaimRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | using Core.Security.Entities; 3 | 4 | namespace Application.Services.Repositories; 5 | 6 | public interface IOperationClaimRepository : IAsyncRepository, IRepository { } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/Repositories/IOtpAuthenticatorRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | using Core.Security.Entities; 3 | 4 | namespace Application.Services.Repositories; 5 | 6 | public interface IOtpAuthenticatorRepository : IAsyncRepository, IRepository { } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/Repositories/IRefreshTokenRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | using Core.Security.Entities; 3 | 4 | namespace Application.Services.Repositories; 5 | 6 | public interface IRefreshTokenRepository : IAsyncRepository, IRepository { } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/Repositories/IRentalBranchRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | using Domain.Entities; 3 | 4 | namespace Application.Services.Repositories; 5 | 6 | public interface IRentalBranchRepository : IAsyncRepository, IRepository { } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/Repositories/IRentalRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | using Domain.Entities; 3 | 4 | namespace Application.Services.Repositories; 5 | 6 | public interface IRentalRepository : IAsyncRepository, IRepository { } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/Repositories/IRentalsAdditionalServiceRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | using Domain.Entities; 3 | 4 | namespace Application.Services.Repositories; 5 | 6 | public interface IRentalsAdditionalServiceRepository : IAsyncRepository, IRepository { } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/Repositories/ITransmissionRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | using Domain.Entities; 3 | 4 | namespace Application.Services.Repositories; 5 | 6 | public interface ITransmissionRepository : IAsyncRepository, IRepository { } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/Repositories/IUserOperationClaimRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | using Core.Security.Entities; 3 | 4 | namespace Application.Services.Repositories; 5 | 6 | public interface IUserOperationClaimRepository : IAsyncRepository, IRepository { } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/Repositories/IUserRepository.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | using Core.Security.Entities; 3 | 4 | namespace Application.Services.Repositories; 5 | 6 | public interface IUserRepository : IAsyncRepository, IRepository { } 7 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/UserService/IUserService.cs: -------------------------------------------------------------------------------- 1 | using Core.Security.Entities; 2 | 3 | namespace Application.Services.UserService; 4 | 5 | public interface IUserService 6 | { 7 | public Task GetByEmail(string email); 8 | public Task GetById(int id); 9 | public Task Update(User user); 10 | } 11 | -------------------------------------------------------------------------------- /src/rentACar/Application/Services/UserService/UserManager.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Core.Security.Entities; 3 | 4 | namespace Application.Services.UserService; 5 | 6 | public class UserManager : IUserService 7 | { 8 | private readonly IUserRepository _userRepository; 9 | 10 | public UserManager(IUserRepository userRepository) 11 | { 12 | _userRepository = userRepository; 13 | } 14 | 15 | public async Task GetByEmail(string email) 16 | { 17 | User? user = await _userRepository.GetAsync(u => u.Email == email); 18 | return user; 19 | } 20 | 21 | public async Task GetById(int id) 22 | { 23 | User? user = await _userRepository.GetAsync(u => u.Id == id); 24 | return user; 25 | } 26 | 27 | public async Task Update(User user) 28 | { 29 | User updatedUser = await _userRepository.UpdateAsync(user); 30 | return updatedUser; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/rentACar/Domain/Domain.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net7.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/rentACar/Domain/Entities/AdditionalService.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | 3 | namespace Domain.Entities; 4 | 5 | public class AdditionalService : Entity 6 | { 7 | public string Name { get; set; } 8 | public decimal DailyPrice { get; set; } 9 | 10 | public AdditionalService() { } 11 | 12 | public AdditionalService(int id, string name, decimal dailyPrice) 13 | : base(id) 14 | { 15 | Name = name; 16 | DailyPrice = dailyPrice; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/rentACar/Domain/Entities/Brand.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | 3 | namespace Domain.Entities; 4 | 5 | public class Brand : Entity 6 | { 7 | public string Name { get; set; } 8 | 9 | public virtual ICollection Models { get; set; } 10 | 11 | public Brand() 12 | { 13 | Models = new HashSet(); 14 | } 15 | 16 | public Brand(int id, string name) 17 | : this() 18 | { 19 | Id = id; 20 | Name = name; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/rentACar/Domain/Entities/CarDamage.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | 3 | namespace Domain.Entities; 4 | 5 | public class CarDamage : Entity 6 | { 7 | public int CarId { get; set; } 8 | public string DamageDescription { get; set; } 9 | public bool IsFixed { get; set; } 10 | 11 | public virtual Car? Car { get; set; } 12 | 13 | public CarDamage() { } 14 | 15 | public CarDamage(int id, int carId, string damageDescription, bool isFixed) 16 | : base(id) 17 | { 18 | CarId = carId; 19 | DamageDescription = damageDescription; 20 | IsFixed = isFixed; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/rentACar/Domain/Entities/Color.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | 3 | namespace Domain.Entities; 4 | 5 | public class Color : Entity 6 | { 7 | public string Name { get; set; } 8 | 9 | public virtual ICollection Cars { get; set; } 10 | 11 | public Color() 12 | { 13 | Cars = new HashSet(); 14 | } 15 | 16 | public Color(int id, string name) 17 | : this() 18 | { 19 | Id = id; 20 | Name = name; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/rentACar/Domain/Entities/CorporateCustomer.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | 3 | namespace Domain.Entities; 4 | 5 | public class CorporateCustomer : Entity 6 | { 7 | public int CustomerId { get; set; } 8 | public string CompanyName { get; set; } 9 | public string TaxNo { get; set; } 10 | 11 | public virtual Customer Customer { get; set; } 12 | 13 | public CorporateCustomer() { } 14 | 15 | public CorporateCustomer(int id, int customerId, string companyName, string taxNo) 16 | : base(id) 17 | { 18 | CustomerId = customerId; 19 | CompanyName = companyName; 20 | TaxNo = taxNo; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/rentACar/Domain/Entities/Customer.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | using Core.Security.Entities; 3 | 4 | namespace Domain.Entities; 5 | 6 | public class Customer : Entity 7 | { 8 | public int UserId { get; set; } 9 | 10 | public virtual User User { get; set; } 11 | public virtual CorporateCustomer? CorporateCustomer { get; set; } 12 | public virtual FindeksCreditRate? FindeksCreditRate { get; set; } 13 | public virtual IndividualCustomer? IndividualCustomer { get; set; } 14 | public virtual ICollection Invoices { get; set; } 15 | public virtual ICollection Rentals { get; set; } 16 | 17 | public Customer() 18 | { 19 | Invoices = new HashSet(); 20 | Rentals = new HashSet(); 21 | } 22 | 23 | public Customer(int id, int userId) 24 | : this() 25 | { 26 | Id = id; 27 | UserId = userId; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/rentACar/Domain/Entities/FindeksCreditRate.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | 3 | namespace Domain.Entities; 4 | 5 | public class FindeksCreditRate : Entity 6 | { 7 | public int CustomerId { get; set; } 8 | public short Score { get; set; } 9 | 10 | public virtual Customer? Customer { get; set; } 11 | 12 | public FindeksCreditRate() { } 13 | 14 | public FindeksCreditRate(int id, int customerId, short score) 15 | : base(id) 16 | { 17 | CustomerId = customerId; 18 | Score = score; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/rentACar/Domain/Entities/Fuel.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | 3 | namespace Domain.Entities; 4 | 5 | public class Fuel : Entity 6 | { 7 | public string Name { get; set; } 8 | 9 | public virtual ICollection Models { get; set; } 10 | 11 | public Fuel() 12 | { 13 | Models = new HashSet(); 14 | } 15 | 16 | public Fuel(int id, string name) 17 | : this() 18 | { 19 | Id = id; 20 | Name = name; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/rentACar/Domain/Entities/IndividualCustomer.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | 3 | namespace Domain.Entities; 4 | 5 | public class IndividualCustomer : Entity 6 | { 7 | public int CustomerId { get; set; } 8 | public string FirstName { get; set; } 9 | public string LastName { get; set; } 10 | public string NationalIdentity { get; set; } 11 | 12 | public virtual Customer Customer { get; set; } 13 | 14 | public IndividualCustomer() { } 15 | 16 | public IndividualCustomer(int id, int customerId, string firstName, string lastName, string nationalIdentity) 17 | : base(id) 18 | { 19 | CustomerId = customerId; 20 | FirstName = firstName; 21 | LastName = lastName; 22 | NationalIdentity = nationalIdentity; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/rentACar/Domain/Entities/Invoice.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | 3 | namespace Domain.Entities; 4 | 5 | public class Invoice : Entity 6 | { 7 | public int CustomerId { get; set; } 8 | public string No { get; set; } 9 | public DateTime CreatedDate { get; set; } 10 | public DateTime RentalStartDate { get; set; } 11 | public DateTime RentalEndDate { get; set; } 12 | public short TotalRentalDate { get; set; } 13 | public decimal RentalPrice { get; set; } 14 | 15 | public virtual Customer? Customer { get; set; } 16 | 17 | public Invoice() { } 18 | 19 | public Invoice( 20 | int id, 21 | int customerId, 22 | string no, 23 | DateTime createdDate, 24 | DateTime rentalStartDate, 25 | DateTime rentalEndDate, 26 | short totalRentalDate, 27 | decimal rentalPrice 28 | ) 29 | : base(id) 30 | { 31 | CustomerId = customerId; 32 | No = no; 33 | CreatedDate = createdDate; 34 | RentalStartDate = rentalStartDate; 35 | RentalEndDate = rentalEndDate; 36 | TotalRentalDate = totalRentalDate; 37 | RentalPrice = rentalPrice; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/rentACar/Domain/Entities/Model.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | 3 | namespace Domain.Entities; 4 | 5 | public class Model : Entity 6 | { 7 | public int BrandId { get; set; } 8 | public int FuelId { get; set; } 9 | public int TransmissionId { get; set; } 10 | public string Name { get; set; } 11 | public decimal DailyPrice { get; set; } 12 | public string ImageUrl { get; set; } 13 | 14 | public virtual Brand? Brand { get; set; } 15 | public virtual ICollection Cars { get; set; } 16 | public virtual Fuel? Fuel { get; set; } 17 | public virtual Transmission? Transmission { get; set; } 18 | 19 | public Model() 20 | { 21 | Cars = new HashSet(); 22 | } 23 | 24 | public Model(int id, int brandId, int fuelId, int transmissionId, string name, decimal dailyPrice, string imageUrl) 25 | : this() 26 | { 27 | Id = id; 28 | BrandId = brandId; 29 | FuelId = fuelId; 30 | TransmissionId = transmissionId; 31 | Name = name; 32 | DailyPrice = dailyPrice; 33 | ImageUrl = imageUrl; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/rentACar/Domain/Entities/RentalBranch.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | using Domain.Enums; 3 | 4 | namespace Domain.Entities; 5 | 6 | public class RentalBranch : Entity 7 | { 8 | public City City { get; set; } 9 | 10 | public virtual ICollection Cars { get; set; } 11 | 12 | public RentalBranch() 13 | { 14 | Cars = new HashSet(); 15 | } 16 | 17 | public RentalBranch(int id, City city) 18 | : this() 19 | { 20 | Id = id; 21 | City = city; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/rentACar/Domain/Entities/RentalsAdditionalService.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | 3 | namespace Domain.Entities; 4 | 5 | public class RentalsAdditionalService : Entity 6 | { 7 | public int RentalId { get; set; } 8 | public int AdditionalServiceId { get; set; } 9 | 10 | public virtual Rental Rental { get; set; } 11 | public virtual AdditionalService AdditionalService { get; set; } 12 | 13 | public RentalsAdditionalService() { } 14 | 15 | public RentalsAdditionalService(int id, int rentalId, int additionalServiceId) 16 | : base(id) 17 | { 18 | RentalId = rentalId; 19 | AdditionalServiceId = additionalServiceId; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/rentACar/Domain/Entities/Transmission.cs: -------------------------------------------------------------------------------- 1 | using Core.Persistence.Repositories; 2 | 3 | namespace Domain.Entities; 4 | 5 | public class Transmission : Entity 6 | { 7 | public string Name { get; set; } 8 | 9 | public virtual ICollection Models { get; set; } 10 | 11 | public Transmission() 12 | { 13 | Models = new HashSet(); 14 | } 15 | 16 | public Transmission(int id, string name) 17 | : this() 18 | { 19 | Id = id; 20 | Name = name; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/rentACar/Domain/Enums/CarStates.cs: -------------------------------------------------------------------------------- 1 | namespace Domain.Enums; 2 | 3 | public enum CarState 4 | { 5 | Available = 1, 6 | Rented = 2, 7 | Maintenance = 3 8 | } 9 | -------------------------------------------------------------------------------- /src/rentACar/Domain/Enums/City.cs: -------------------------------------------------------------------------------- 1 | namespace Domain.Enums; 2 | 3 | public enum City 4 | { 5 | Ankara = 6, 6 | Antalya = 7 7 | } 8 | -------------------------------------------------------------------------------- /src/rentACar/Infrastructure/Adapters/FakeFindeksService/FakeFindeksServiceAdapter.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.FindeksService; 2 | 3 | namespace Infrastructure.Adapters.FakeFindeksService; 4 | 5 | public class FakeFindeksServiceAdapter : IFindeksService 6 | { 7 | public short GetScore(string identityNumber) 8 | { 9 | Random random = new(); 10 | short score = Convert.ToInt16(random.Next(1900)); 11 | return score; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/rentACar/Infrastructure/Adapters/FakePOSService/FakePOSServiceAdapter.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.POSService; 2 | using Core.CrossCuttingConcerns.Exceptions.Types; 3 | 4 | namespace Infrastructure.Adapters.FakePOSService; 5 | 6 | public class FakePOSServiceAdapter : IPOSService 7 | { 8 | public Task Pay(string invoiceNo, decimal price) 9 | { 10 | Random random = new(); 11 | bool result = Convert.ToBoolean(random.Next(2)); 12 | if (!result) 13 | throw new BusinessException("Payment is not successful."); 14 | return Task.CompletedTask; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/rentACar/Infrastructure/Infrastructure.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/rentACar/Infrastructure/InfrastructureServiceRegistration.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.FindeksService; 2 | using Application.Services.ImageService; 3 | using Application.Services.POSService; 4 | using Infrastructure.Adapters.FakeFindeksService; 5 | using Infrastructure.Adapters.FakePOSService; 6 | using Infrastructure.Adapters.ImageService; 7 | using Microsoft.Extensions.DependencyInjection; 8 | 9 | namespace Infrastructure; 10 | 11 | public static class InfrastructureServiceRegistration 12 | { 13 | public static IServiceCollection AddInfrastructureServices(this IServiceCollection services) 14 | { 15 | services.AddScoped(); 16 | services.AddScoped(); 17 | services.AddScoped(); 18 | return services; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/EntityConfigurations/AdditionalServiceConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Domain.Entities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 4 | 5 | namespace Persistence.EntityConfigurations; 6 | 7 | public class AdditionalServiceConfiguration : IEntityTypeConfiguration 8 | { 9 | public void Configure(EntityTypeBuilder builder) 10 | { 11 | builder.ToTable("AdditionalServices").HasKey(k => k.Id); 12 | builder.Property(p => p.Id).HasColumnName("Id"); 13 | builder.Property(p => p.Name).HasColumnName("Name"); 14 | builder.HasIndex(indexExpression: p => p.Name, name: "UK_AdditionalServices_Name").IsUnique(); 15 | builder.Property(p => p.DailyPrice).HasColumnName("DailyPrice"); 16 | 17 | AdditionalService[] additionalServiceSeeds = 18 | { 19 | new(id: 1, name: "Baby Seat", dailyPrice: 200), 20 | new(id: 2, name: "Scooter", dailyPrice: 300) 21 | }; 22 | builder.HasData(additionalServiceSeeds); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/EntityConfigurations/BrandConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Domain.Entities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 4 | 5 | namespace Persistence.EntityConfigurations; 6 | 7 | public class BrandConfiguration : IEntityTypeConfiguration 8 | { 9 | public void Configure(EntityTypeBuilder builder) 10 | { 11 | builder.ToTable("Brands").HasKey(k => k.Id); 12 | builder.Property(p => p.Id).HasColumnName("Id"); 13 | builder.Property(p => p.Name).HasColumnName("Name"); 14 | builder.HasIndex(indexExpression: p => p.Name, name: "UK_Brands_Name").IsUnique(); 15 | builder.HasMany(p => p.Models); 16 | 17 | Brand[] brandSeeds = { new(id: 1, name: "BMW"), new(id: 2, name: "Mercedes") }; 18 | builder.HasData(brandSeeds); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/EntityConfigurations/CarDamageConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Domain.Entities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 4 | 5 | namespace Persistence.EntityConfigurations; 6 | 7 | public class CarDamageConfiguration : IEntityTypeConfiguration 8 | { 9 | public void Configure(EntityTypeBuilder builder) 10 | { 11 | builder.ToTable("CarDamages").HasKey(k => k.Id); 12 | builder.Property(p => p.Id).HasColumnName("Id"); 13 | builder.Property(p => p.CarId).HasColumnName("CarId"); 14 | builder.Property(p => p.IsFixed).HasColumnName("IsFixed").HasDefaultValue(false); 15 | builder.HasOne(p => p.Car); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/EntityConfigurations/ColorConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Domain.Entities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 4 | 5 | namespace Persistence.EntityConfigurations; 6 | 7 | public class ColorConfiguration : IEntityTypeConfiguration 8 | { 9 | public void Configure(EntityTypeBuilder builder) 10 | { 11 | builder.ToTable("Colors").HasKey(k => k.Id); 12 | builder.Property(p => p.Id).HasColumnName("Id"); 13 | builder.Property(p => p.Name).HasColumnName("Name"); 14 | builder.HasIndex(indexExpression: p => p.Name, name: "UK_Colors_Name").IsUnique(); 15 | builder.HasMany(p => p.Cars); 16 | 17 | Color[] colorSeeds = { new(id: 1, name: "Red"), new(id: 2, name: "Blue") }; 18 | builder.HasData(colorSeeds); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/EntityConfigurations/CorporateCustomerConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Domain.Entities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 4 | 5 | namespace Persistence.EntityConfigurations; 6 | 7 | public class CorporateCustomerConfiguration : IEntityTypeConfiguration 8 | { 9 | public void Configure(EntityTypeBuilder builder) 10 | { 11 | builder.ToTable("CorporateCustomers").HasKey(c => c.Id); 12 | builder.Property(c => c.Id).HasColumnName("Id"); 13 | builder.Property(c => c.CustomerId).HasColumnName("CustomerId"); 14 | builder.HasIndex(indexExpression: c => c.CustomerId, name: "UK_CorporateCustomers_CustomerId").IsUnique(); 15 | builder.Property(c => c.CompanyName).HasColumnName("CompanyName"); 16 | builder.Property(c => c.TaxNo).HasColumnName("TaxNo"); 17 | builder.HasIndex(indexExpression: c => c.TaxNo, name: "UK_CorporateCustomers_TaxNo").IsUnique(); 18 | builder.HasOne(c => c.Customer); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/EntityConfigurations/CustomerConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Domain.Entities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 4 | 5 | namespace Persistence.EntityConfigurations; 6 | 7 | public class CustomerConfiguration : IEntityTypeConfiguration 8 | { 9 | public void Configure(EntityTypeBuilder builder) 10 | { 11 | builder.ToTable("Customers").HasKey(c => c.Id); 12 | builder.Property(c => c.Id).HasColumnName("Id"); 13 | builder.Property(c => c.UserId).HasColumnName("UserId"); 14 | builder.HasIndex(indexExpression: c => c.UserId, name: "UK_Customers_UserId").IsUnique(); 15 | builder.HasOne(c => c.User); 16 | builder.HasOne(c => c.CorporateCustomer); 17 | builder.HasOne(c => c.FindeksCreditRate); 18 | builder.HasOne(c => c.IndividualCustomer); 19 | builder.HasMany(c => c.Invoices); 20 | builder.HasMany(c => c.Rentals); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/EntityConfigurations/EmailAuthenticatorConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Core.Security.Entities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 4 | 5 | namespace Persistence.EntityConfigurations; 6 | 7 | public class EmailAuthenticatorConfiguration : IEntityTypeConfiguration 8 | { 9 | public void Configure(EntityTypeBuilder builder) 10 | { 11 | builder.ToTable("EmailAuthenticators").HasKey(e => e.Id); 12 | builder.Property(e => e.UserId).HasColumnName("UserId"); 13 | builder.Property(e => e.ActivationKey).HasColumnName("ActivationKey"); 14 | builder.Property(e => e.IsVerified).HasColumnName("IsVerified"); 15 | builder.HasOne(e => e.User); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/EntityConfigurations/FindeksCreditRateConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Domain.Entities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 4 | 5 | namespace Persistence.EntityConfigurations; 6 | 7 | public class FindeksCreditRateConfiguration : IEntityTypeConfiguration 8 | { 9 | public void Configure(EntityTypeBuilder builder) 10 | { 11 | builder.ToTable("FindeksCreditRates").HasKey(f => f.Id); 12 | builder.Property(f => f.Id).HasColumnName("Id"); 13 | builder.Property(f => f.CustomerId).HasColumnName("CustomerId"); 14 | builder.Property(f => f.Score).HasColumnName("Score"); 15 | builder.HasOne(f => f.Customer); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/EntityConfigurations/FuelConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Domain.Entities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 4 | 5 | namespace Persistence.EntityConfigurations; 6 | 7 | public class FuelConfiguration : IEntityTypeConfiguration 8 | { 9 | public void Configure(EntityTypeBuilder builder) 10 | { 11 | builder.ToTable("Fuels").HasKey(f => f.Id); 12 | builder.Property(f => f.Id).HasColumnName("Id"); 13 | builder.Property(f => f.Name).HasColumnName("Name"); 14 | builder.HasIndex(indexExpression: f => f.Name, name: "UK_Fuels_Name").IsUnique(); 15 | builder.HasMany(f => f.Models); 16 | 17 | Fuel[] fuelSeeds = { new(id: 1, name: "Diesel"), new(id: 2, name: "Electric") }; 18 | builder.HasData(fuelSeeds); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/EntityConfigurations/IndividualCustomerConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Domain.Entities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 4 | 5 | namespace Persistence.EntityConfigurations; 6 | 7 | public class IndividualCustomerConfiguration : IEntityTypeConfiguration 8 | { 9 | public void Configure(EntityTypeBuilder builder) 10 | { 11 | builder.ToTable("IndividualCustomers").HasKey(i => i.Id); 12 | builder.Property(i => i.Id).HasColumnName("Id"); 13 | builder.Property(i => i.CustomerId).HasColumnName("CustomerId"); 14 | builder.HasIndex(indexExpression: i => i.CustomerId, name: "UK_IndividualCustomers_CustomerId").IsUnique(); 15 | builder.Property(i => i.FirstName).HasColumnName("FirstName"); 16 | builder.Property(i => i.LastName).HasColumnName("LastName"); 17 | builder.Property(i => i.NationalIdentity).HasColumnName("NationalIdentity"); 18 | builder.HasIndex(indexExpression: i => i.NationalIdentity, name: "UK_IndividualCustomers_NationalIdentity").IsUnique(); 19 | builder.HasOne(i => i.Customer); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/EntityConfigurations/InvoiceConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Domain.Entities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 4 | 5 | namespace Persistence.EntityConfigurations; 6 | 7 | public class InvoiceConfiguration : IEntityTypeConfiguration 8 | { 9 | public void Configure(EntityTypeBuilder builder) 10 | { 11 | builder.ToTable("Invoices").HasKey(i => i.Id); 12 | builder.Property(i => i.Id).HasColumnName("Id"); 13 | builder.Property(i => i.CustomerId).HasColumnName("CustomerId"); 14 | builder.Property(i => i.No).HasColumnName("No"); 15 | builder.Property(i => i.CreatedDate).HasColumnName("CreatedDate").HasDefaultValue(DateTime.Now); 16 | builder.Property(i => i.RentalStartDate).HasColumnName("RentalStartDate"); 17 | builder.Property(i => i.RentalEndDate).HasColumnName("RentalEndDate"); 18 | builder.Property(i => i.TotalRentalDate).HasColumnName("TotalRentalDate"); 19 | builder.Property(i => i.RentalPrice).HasColumnName("RentalPrice"); 20 | builder.HasOne(i => i.Customer); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/EntityConfigurations/OperationClaimConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Application.Features.OperationClaims.Constants; 2 | using Core.Security.Entities; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 5 | 6 | namespace Persistence.EntityConfigurations; 7 | 8 | public class OperationClaimConfiguration : IEntityTypeConfiguration 9 | { 10 | public void Configure(EntityTypeBuilder builder) 11 | { 12 | builder.ToTable("OperationClaims").HasKey(o => o.Id); 13 | builder.Property(o => o.Id).HasColumnName("Id"); 14 | builder.Property(o => o.Name).HasColumnName("Name"); 15 | builder.HasIndex(indexExpression: o => o.Name, name: "UK_OperationClaims_Name").IsUnique(); 16 | 17 | builder.HasData(getSeeds()); 18 | } 19 | 20 | private HashSet getSeeds() 21 | { 22 | int id = 0; 23 | HashSet seeds = new(); 24 | 25 | seeds.Add(new OperationClaim { Id = ++id, Name = GeneralOperationClaims.Admin }); 26 | 27 | return seeds; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/EntityConfigurations/OtpAuthenticatorConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Core.Security.Entities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 4 | 5 | namespace Persistence.EntityConfigurations; 6 | 7 | public class OtpAuthenticatorConfiguration : IEntityTypeConfiguration 8 | { 9 | public void Configure(EntityTypeBuilder builder) 10 | { 11 | builder.ToTable("OtpAuthenticators").HasKey(e => e.Id); 12 | builder.Property(e => e.UserId).HasColumnName("UserId"); 13 | builder.Property(e => e.SecretKey).HasColumnName("SecretKey"); 14 | builder.Property(e => e.IsVerified).HasColumnName("IsVerified"); 15 | builder.HasOne(e => e.User); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/EntityConfigurations/RefreshTokenConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Core.Security.Entities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 4 | 5 | namespace Persistence.EntityConfigurations; 6 | 7 | public class RefreshTokenConfiguration : IEntityTypeConfiguration 8 | { 9 | public void Configure(EntityTypeBuilder builder) 10 | { 11 | builder.ToTable("RefreshTokens").HasKey(r => r.Id); 12 | builder.Property(r => r.Id).HasColumnName("Id"); 13 | builder.Property(r => r.UserId).HasColumnName("UserId"); 14 | builder.Property(r => r.Token).HasColumnName("Token"); 15 | builder.Property(r => r.Expires).HasColumnName("Expires"); 16 | builder.Property(r => r.Created).HasColumnName("Created"); 17 | builder.Property(r => r.CreatedByIp).HasColumnName("CreatedByIp"); 18 | builder.Property(r => r.Revoked).HasColumnName("Revoked"); 19 | builder.Property(r => r.RevokedByIp).HasColumnName("RevokedByIp"); 20 | builder.Property(r => r.ReplacedByToken).HasColumnName("ReplacedByToken"); 21 | builder.Property(r => r.ReasonRevoked).HasColumnName("ReasonRevoked"); 22 | builder.HasOne(r => r.User); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/EntityConfigurations/RentalBranchConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Domain.Entities; 2 | using Domain.Enums; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 5 | 6 | namespace Persistence.EntityConfigurations; 7 | 8 | public class RentalBranchConfiguration : IEntityTypeConfiguration 9 | { 10 | public void Configure(EntityTypeBuilder builder) 11 | { 12 | builder.ToTable("RentalBranches").HasKey(r => r.Id); 13 | builder.Property(r => r.Id).HasColumnName("Id"); 14 | builder.Property(r => r.City).HasColumnName("City"); 15 | builder.HasMany(r => r.Cars); 16 | 17 | RentalBranch[] rentalBranchSeeds = { new(id: 1, City.Ankara), new(id: 2, City.Antalya) }; 18 | builder.HasData(rentalBranchSeeds); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/EntityConfigurations/RentalsAdditionalServiceConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Domain.Entities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 4 | 5 | namespace Persistence.EntityConfigurations; 6 | 7 | public class RentalsAdditionalServiceConfiguration : IEntityTypeConfiguration 8 | { 9 | public void Configure(EntityTypeBuilder builder) 10 | { 11 | builder.ToTable("RentalsAdditionalServices").HasKey(r => r.Id); 12 | builder.Property(r => r.Id).HasColumnName("Id"); 13 | builder.Property(r => r.RentalId).HasColumnName("RentalId"); 14 | builder.Property(r => r.AdditionalServiceId).HasColumnName("AdditionalServiceId"); 15 | builder.HasOne(r => r.Rental); 16 | builder.HasOne(r => r.AdditionalService); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/EntityConfigurations/TransmissionConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Domain.Entities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 4 | 5 | namespace Persistence.EntityConfigurations; 6 | 7 | public class TransmissionConfiguration : IEntityTypeConfiguration 8 | { 9 | public void Configure(EntityTypeBuilder builder) 10 | { 11 | builder.ToTable("Transmissions").HasKey(k => k.Id); 12 | builder.Property(p => p.Id).HasColumnName("Id"); 13 | builder.Property(p => p.Name).HasColumnName("Name"); 14 | builder.HasIndex(indexExpression: p => p.Name, name: "UK_Transmissions_Name").IsUnique(); 15 | builder.HasMany(p => p.Models); 16 | 17 | Transmission[] transmissionsSeeds = { new(id: 1, name: "Manuel"), new(id: 2, name: "Automatic") }; 18 | builder.HasData(transmissionsSeeds); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/EntityConfigurations/UserConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Core.Security.Entities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 4 | 5 | namespace Persistence.EntityConfigurations; 6 | 7 | public class UserConfiguration : IEntityTypeConfiguration 8 | { 9 | public void Configure(EntityTypeBuilder builder) 10 | { 11 | builder.ToTable("Users").HasKey(u => u.Id); 12 | builder.Property(u => u.Id).HasColumnName("Id"); 13 | builder.Property(u => u.FirstName).HasColumnName("FirstName"); 14 | builder.Property(u => u.LastName).HasColumnName("LastName"); 15 | builder.Property(u => u.Email).HasColumnName("Email"); 16 | builder.HasIndex(indexExpression: u => u.Email, name: "UK_Users_Email").IsUnique(); 17 | builder.Property(u => u.PasswordSalt).HasColumnName("PasswordSalt"); 18 | builder.Property(u => u.PasswordHash).HasColumnName("PasswordHash"); 19 | builder.Property(u => u.Status).HasColumnName("Status").HasDefaultValue(true); 20 | builder.Property(u => u.AuthenticatorType).HasColumnName("AuthenticatorType"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/EntityConfigurations/UserOperationClaimConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Core.Security.Entities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Metadata.Builders; 4 | 5 | namespace Persistence.EntityConfigurations; 6 | 7 | public class UserOperationClaimConfiguration : IEntityTypeConfiguration 8 | { 9 | public void Configure(EntityTypeBuilder builder) 10 | { 11 | builder.ToTable("UserOperationClaims").HasKey(u => u.Id); 12 | builder.Property(u => u.Id).HasColumnName("Id"); 13 | builder.Property(u => u.UserId).HasColumnName("UserId"); 14 | builder.Property(u => u.OperationClaimId).HasColumnName("OperationClaimId"); 15 | builder 16 | .HasIndex(indexExpression: u => new { u.UserId, u.OperationClaimId }, name: "UK_UserOperationClaims_UserId_OperationClaimId") 17 | .IsUnique(); 18 | builder.HasOne(u => u.User); 19 | builder.HasOne(u => u.OperationClaim); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/Persistence.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/Repositories/AdditionalServiceRepository.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Core.Persistence.Repositories; 3 | using Domain.Entities; 4 | using Persistence.Contexts; 5 | 6 | namespace Persistence.Repositories; 7 | 8 | public class AdditionalServiceRepository : EfRepositoryBase, IAdditionalServiceRepository 9 | { 10 | public AdditionalServiceRepository(BaseDbContext context) 11 | : base(context) { } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/Repositories/BrandRepository.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Core.Persistence.Repositories; 3 | using Domain.Entities; 4 | using Persistence.Contexts; 5 | 6 | namespace Persistence.Repositories; 7 | 8 | public class BrandRepository : EfRepositoryBase, IBrandRepository 9 | { 10 | public BrandRepository(BaseDbContext context) 11 | : base(context) { } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/Repositories/CarDamageRepository.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Core.Persistence.Repositories; 3 | using Domain.Entities; 4 | using Persistence.Contexts; 5 | 6 | namespace Persistence.Repositories; 7 | 8 | public class CarDamageRepository : EfRepositoryBase, ICarDamageRepository 9 | { 10 | public CarDamageRepository(BaseDbContext context) 11 | : base(context) { } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/Repositories/CarRepository.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Core.Persistence.Repositories; 3 | using Domain.Entities; 4 | using Persistence.Contexts; 5 | 6 | namespace Persistence.Repositories; 7 | 8 | public class CarRepository : EfRepositoryBase, ICarRepository 9 | { 10 | public CarRepository(BaseDbContext context) 11 | : base(context) { } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/Repositories/ColorRepository.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Core.Persistence.Repositories; 3 | using Domain.Entities; 4 | using Persistence.Contexts; 5 | 6 | namespace Persistence.Repositories; 7 | 8 | public class ColorRepository : EfRepositoryBase, IColorRepository 9 | { 10 | public ColorRepository(BaseDbContext context) 11 | : base(context) { } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/Repositories/CorporateCustomerRepository.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Core.Persistence.Repositories; 3 | using Domain.Entities; 4 | using Persistence.Contexts; 5 | 6 | namespace Persistence.Repositories; 7 | 8 | public class CorporateCustomerRepository : EfRepositoryBase, ICorporateCustomerRepository 9 | { 10 | public CorporateCustomerRepository(BaseDbContext context) 11 | : base(context) { } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/Repositories/CustomerRepository.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Core.Persistence.Repositories; 3 | using Domain.Entities; 4 | using Persistence.Contexts; 5 | 6 | namespace Persistence.Repositories; 7 | 8 | public class CustomerRepository : EfRepositoryBase, ICustomerRepository 9 | { 10 | public CustomerRepository(BaseDbContext context) 11 | : base(context) { } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/Repositories/EmailAuthenticatorRepository.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Core.Persistence.Repositories; 3 | using Core.Security.Entities; 4 | using Persistence.Contexts; 5 | 6 | namespace Persistence.Repositories; 7 | 8 | public class EmailAuthenticatorRepository : EfRepositoryBase, IEmailAuthenticatorRepository 9 | { 10 | public EmailAuthenticatorRepository(BaseDbContext context) 11 | : base(context) { } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/Repositories/FindeksCreditRateRepository.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Core.Persistence.Repositories; 3 | using Domain.Entities; 4 | using Persistence.Contexts; 5 | 6 | namespace Persistence.Repositories; 7 | 8 | public class FindeksCreditRateRepository : EfRepositoryBase, IFindeksCreditRateRepository 9 | { 10 | public FindeksCreditRateRepository(BaseDbContext context) 11 | : base(context) { } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/Repositories/FuelRepository.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Core.Persistence.Repositories; 3 | using Domain.Entities; 4 | using Persistence.Contexts; 5 | 6 | namespace Persistence.Repositories; 7 | 8 | public class FuelRepository : EfRepositoryBase, IFuelRepository 9 | { 10 | public FuelRepository(BaseDbContext context) 11 | : base(context) { } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/Repositories/IndividualCustomerRepository.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Core.Persistence.Repositories; 3 | using Domain.Entities; 4 | using Persistence.Contexts; 5 | 6 | namespace Persistence.Repositories; 7 | 8 | public class IndividualCustomerRepository : EfRepositoryBase, IIndividualCustomerRepository 9 | { 10 | public IndividualCustomerRepository(BaseDbContext context) 11 | : base(context) { } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/Repositories/InvoiceRepository.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Core.Persistence.Repositories; 3 | using Domain.Entities; 4 | using Persistence.Contexts; 5 | 6 | namespace Persistence.Repositories; 7 | 8 | public class InvoiceRepository : EfRepositoryBase, IInvoiceRepository 9 | { 10 | public InvoiceRepository(BaseDbContext context) 11 | : base(context) { } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/Repositories/ModelRepository.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Core.Persistence.Repositories; 3 | using Domain.Entities; 4 | using Persistence.Contexts; 5 | 6 | namespace Persistence.Repositories; 7 | 8 | public class ModelRepository : EfRepositoryBase, IModelRepository 9 | { 10 | public ModelRepository(BaseDbContext context) 11 | : base(context) { } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/Repositories/OperationClaimRepository.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Core.Persistence.Repositories; 3 | using Core.Security.Entities; 4 | using Persistence.Contexts; 5 | 6 | namespace Persistence.Repositories; 7 | 8 | public class OperationClaimRepository : EfRepositoryBase, IOperationClaimRepository 9 | { 10 | public OperationClaimRepository(BaseDbContext context) 11 | : base(context) { } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/Repositories/OtpAuthenticatorRepository.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Core.Persistence.Repositories; 3 | using Core.Security.Entities; 4 | using Persistence.Contexts; 5 | 6 | namespace Persistence.Repositories; 7 | 8 | public class OtpAuthenticatorRepository : EfRepositoryBase, IOtpAuthenticatorRepository 9 | { 10 | public OtpAuthenticatorRepository(BaseDbContext context) 11 | : base(context) { } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/Repositories/RefreshTokenRepository.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Core.Persistence.Repositories; 3 | using Core.Security.Entities; 4 | using Persistence.Contexts; 5 | 6 | namespace Persistence.Repositories; 7 | 8 | public class RefreshTokenRepository : EfRepositoryBase, IRefreshTokenRepository 9 | { 10 | public RefreshTokenRepository(BaseDbContext context) 11 | : base(context) { } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/Repositories/RentalBranchRepository.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Core.Persistence.Repositories; 3 | using Domain.Entities; 4 | using Persistence.Contexts; 5 | 6 | namespace Persistence.Repositories; 7 | 8 | public class RentalBranchRepository : EfRepositoryBase, IRentalBranchRepository 9 | { 10 | public RentalBranchRepository(BaseDbContext context) 11 | : base(context) { } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/Repositories/RentalRepository.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Core.Persistence.Repositories; 3 | using Domain.Entities; 4 | using Persistence.Contexts; 5 | 6 | namespace Persistence.Repositories; 7 | 8 | public class RentalRepository : EfRepositoryBase, IRentalRepository 9 | { 10 | public RentalRepository(BaseDbContext context) 11 | : base(context) { } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/Repositories/RentalsAdditionalServiceRepository.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Core.Persistence.Repositories; 3 | using Domain.Entities; 4 | using Persistence.Contexts; 5 | 6 | namespace Persistence.Repositories; 7 | 8 | public class RentalsAdditionalServiceRepository 9 | : EfRepositoryBase, 10 | IRentalsAdditionalServiceRepository 11 | { 12 | public RentalsAdditionalServiceRepository(BaseDbContext context) 13 | : base(context) { } 14 | } 15 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/Repositories/TransmissionRepository.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Core.Persistence.Repositories; 3 | using Domain.Entities; 4 | using Persistence.Contexts; 5 | 6 | namespace Persistence.Repositories; 7 | 8 | public class TransmissionRepository : EfRepositoryBase, ITransmissionRepository 9 | { 10 | public TransmissionRepository(BaseDbContext context) 11 | : base(context) { } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/Repositories/UserOperationClaimRepository.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Core.Persistence.Repositories; 3 | using Core.Security.Entities; 4 | using Persistence.Contexts; 5 | 6 | namespace Persistence.Repositories; 7 | 8 | public class UserOperationClaimRepository : EfRepositoryBase, IUserOperationClaimRepository 9 | { 10 | public UserOperationClaimRepository(BaseDbContext context) 11 | : base(context) { } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/Persistence/Repositories/UserRepository.cs: -------------------------------------------------------------------------------- 1 | using Application.Services.Repositories; 2 | using Core.Persistence.Repositories; 3 | using Core.Security.Entities; 4 | using Persistence.Contexts; 5 | 6 | namespace Persistence.Repositories; 7 | 8 | public class UserRepository : EfRepositoryBase, IUserRepository 9 | { 10 | public UserRepository(BaseDbContext context) 11 | : base(context) { } 12 | } 13 | -------------------------------------------------------------------------------- /src/rentACar/WebAPI/Controllers/BaseController.cs: -------------------------------------------------------------------------------- 1 | using Core.Security.Extensions; 2 | using MediatR; 3 | using Microsoft.AspNetCore.Mvc; 4 | 5 | namespace WebAPI.Controllers; 6 | 7 | public class BaseController : ControllerBase 8 | { 9 | protected IMediator? Mediator => _mediator ??= HttpContext.RequestServices.GetService(); 10 | private IMediator? _mediator; 11 | 12 | protected string? getIpAddress() 13 | { 14 | if (Request.Headers.ContainsKey("X-Forwarded-For")) 15 | return Request.Headers["X-Forwarded-For"]; 16 | return HttpContext.Connection.RemoteIpAddress?.MapToIPv4().ToString(); 17 | } 18 | 19 | protected int getUserIdFromRequest() //todo authentication behavior? 20 | { 21 | int userId = HttpContext.User.GetUserId(); 22 | return userId; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/rentACar/WebAPI/Controllers/Dtos/UpdateByAuthFromServiceRequestDto.cs: -------------------------------------------------------------------------------- 1 | namespace WebAPI.Controllers.Dtos; 2 | 3 | public class UpdateByAuthFromServiceRequestDto 4 | { 5 | public string IdentityNumber { get; set; } 6 | } 7 | -------------------------------------------------------------------------------- /src/rentACar/WebAPI/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:60805", 7 | "sslPort": 0 8 | }, 9 | "windowsAuthentication": false 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "swagger", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "WebAPI": { 21 | "applicationUrl": "http://localhost:5278", 22 | "commandName": "Project", 23 | "dotnetRunMessages": true, 24 | "environmentVariables": { 25 | "ASPNETCORE_ENVIRONMENT": "Development" 26 | }, 27 | "launchBrowser": true, 28 | "launchUrl": "swagger" 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/rentACar/WebAPI/WebAPIConfiguration.cs: -------------------------------------------------------------------------------- 1 | namespace WebAPI; 2 | 3 | public class WebAPIConfiguration 4 | { 5 | public string APIDomain { get; set; } 6 | public string[] AllowedOrigins { get; set; } 7 | } 8 | -------------------------------------------------------------------------------- /src/rentACar/WebAPI/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/Application.Tests/DependencyResolvers/BrandServiceRegistration.cs: -------------------------------------------------------------------------------- 1 | using Application.Features.Brands.Commands.Create; 2 | using Application.Features.Brands.Commands.Delete; 3 | using Application.Features.Brands.Commands.Update; 4 | using Application.Features.Brands.Queries.GetById; 5 | using Application.Features.Brands.Queries.GetList; 6 | using Application.Tests.Mocks.FakeData; 7 | using Microsoft.Extensions.DependencyInjection; 8 | 9 | namespace Application.Tests.DependencyResolvers; 10 | 11 | public static class BrandServiceRegistration 12 | { 13 | public static void AddBrandServices(this IServiceCollection services) 14 | { 15 | services.AddTransient(); 16 | services.AddTransient(); 17 | services.AddTransient(); 18 | services.AddTransient(); 19 | services.AddTransient(); 20 | services.AddTransient(); 21 | services.AddSingleton(); 22 | services.AddSingleton(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tests/Application.Tests/DependencyResolvers/ColorServiceRegistration.cs: -------------------------------------------------------------------------------- 1 | using Application.Features.Colors.Commands.Create; 2 | using Application.Features.Colors.Commands.Delete; 3 | using Application.Features.Colors.Commands.Update; 4 | using Application.Features.Colors.Queries.GetById; 5 | using Application.Features.Colors.Queries.GetList; 6 | using Application.Tests.Mocks.FakeData; 7 | using Microsoft.Extensions.DependencyInjection; 8 | 9 | namespace Application.Tests.DependencyResolvers; 10 | 11 | public static class ColorServiceRegistration 12 | { 13 | public static void AddColorServices(this IServiceCollection services) 14 | { 15 | services.AddTransient(); 16 | services.AddTransient(); 17 | services.AddTransient(); 18 | services.AddTransient(); 19 | services.AddTransient(); 20 | services.AddTransient(); 21 | services.AddSingleton(); 22 | services.AddSingleton(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tests/Application.Tests/Features/Brands/Queries/GetListBrand/GetListBrandTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | using Application.Features.Brands.Queries.GetList; 4 | using Application.Tests.Mocks.FakeData; 5 | using Application.Tests.Mocks.Repositories; 6 | using Core.Application.Requests; 7 | using Core.Application.Responses; 8 | using Core.Persistence.Paging; 9 | using Xunit; 10 | using static Application.Features.Brands.Queries.GetList.GetListBrandQuery; 11 | 12 | namespace Application.Tests.Features.Brands.Queries.GetListBrand; 13 | 14 | public class GetListBrandTests : BrandMockRepository 15 | { 16 | private readonly GetListBrandQuery _query; 17 | private readonly GetListBrandQueryHandler _handler; 18 | 19 | public GetListBrandTests(BrandFakeData fakeData, GetListBrandQuery query) 20 | : base(fakeData) 21 | { 22 | _query = query; 23 | _handler = new GetListBrandQueryHandler(MockRepository.Object, Mapper); 24 | } 25 | 26 | [Fact] 27 | public async Task GetAllBrandsShouldSuccessfuly() 28 | { 29 | _query.PageRequest = new PageRequest { Page = 0, PageSize = 3 }; 30 | GetListResponse result = await _handler.Handle(_query, CancellationToken.None); 31 | Assert.Equal(expected: 2, result.Items.Count); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tests/Application.Tests/Features/Colors/Queries/GetListColor/GetListColorTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | using Application.Features.Colors.Queries.GetList; 4 | using Application.Tests.Mocks.FakeData; 5 | using Application.Tests.Mocks.Repositories; 6 | using Core.Application.Requests; 7 | using Core.Application.Responses; 8 | using Core.Persistence.Paging; 9 | using Xunit; 10 | using static Application.Features.Colors.Queries.GetList.GetListColorQuery; 11 | 12 | namespace Application.Tests.Features.Colors.Queries.GetListColor; 13 | 14 | public class GetListColorTests : ColorMockRepository 15 | { 16 | private readonly GetListColorQuery _query; 17 | private readonly GetListColorQueryHandler _handler; 18 | 19 | public GetListColorTests(ColorFakeData fakeData, GetListColorQuery query) 20 | : base(fakeData) 21 | { 22 | _query = query; 23 | _handler = new GetListColorQueryHandler(MockRepository.Object, Mapper); 24 | } 25 | 26 | [Fact] 27 | public async Task GetAllColorsShouldSuccessfuly() 28 | { 29 | _query.PageRequest = new PageRequest { Page = 0, PageSize = 3 }; 30 | GetListResponse result = await _handler.Handle(_query, CancellationToken.None); 31 | Assert.Equal(expected: 2, result.Items.Count); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tests/Application.Tests/Mocks/FakeData/BrandFakeData.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Core.Test.Application.FakeData; 3 | using Domain.Entities; 4 | 5 | namespace Application.Tests.Mocks.FakeData; 6 | 7 | public class BrandFakeData : BaseFakeData 8 | { 9 | public override List CreateFakeData() 10 | { 11 | var data = new List 12 | { 13 | new() { Id = 1, Name = "Mercedes" }, 14 | new() { Id = 2, Name = "BMW" } 15 | }; 16 | return data; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/Application.Tests/Mocks/FakeData/ColorFakeData.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Core.Test.Application.FakeData; 3 | using Domain.Entities; 4 | 5 | namespace Application.Tests.Mocks.FakeData; 6 | 7 | public class ColorFakeData : BaseFakeData 8 | { 9 | public override List CreateFakeData() 10 | { 11 | var data = new List 12 | { 13 | new() { Id = 1, Name = "Red" }, 14 | new() { Id = 2, Name = "Blue" } 15 | }; 16 | return data; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/Application.Tests/Mocks/Repositories/BrandMockRepository.cs: -------------------------------------------------------------------------------- 1 | using Application.Features.Brands.Profiles; 2 | using Application.Features.Brands.Rules; 3 | using Application.Services.Repositories; 4 | using Application.Tests.Mocks.FakeData; 5 | using Core.Test.Application.Repositories; 6 | using Domain.Entities; 7 | 8 | namespace Application.Tests.Mocks.Repositories; 9 | 10 | public class BrandMockRepository : BaseMockRepository 11 | { 12 | public BrandMockRepository(BrandFakeData fakeData) 13 | : base(fakeData) { } 14 | } 15 | -------------------------------------------------------------------------------- /tests/Application.Tests/Mocks/Repositories/ColorMockRepository.cs: -------------------------------------------------------------------------------- 1 | using Application.Features.Colors.Profiles; 2 | using Application.Features.Colors.Rules; 3 | using Application.Services.Repositories; 4 | using Application.Tests.Mocks.FakeData; 5 | using Core.Test.Application.Repositories; 6 | using Domain.Entities; 7 | 8 | namespace Application.Tests.Mocks.Repositories; 9 | 10 | public class ColorMockRepository : BaseMockRepository 11 | { 12 | public ColorMockRepository(ColorFakeData fakeData) 13 | : base(fakeData) { } 14 | } 15 | -------------------------------------------------------------------------------- /tests/Application.Tests/Startup.cs: -------------------------------------------------------------------------------- 1 | using Application.Tests.DependencyResolvers; 2 | using Microsoft.Extensions.DependencyInjection; 3 | 4 | namespace Application.Tests; 5 | 6 | public sealed class Startup 7 | { 8 | public void ConfigureServices(IServiceCollection services) 9 | { 10 | services.AddBrandServices(); 11 | services.AddColorServices(); 12 | } 13 | } 14 | --------------------------------------------------------------------------------