public void Configure( IApplicationBuilder app, IWebHostEnvironment env, BankInformationSystemDbContext context) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseCors(DefaultCorsPolicy); app.UseHttpsRedirection(); // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), // specifying the Swagger JSON endpoint. app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Bank Information System API V1"); }); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); context.Database.EnsureCreated(); }
public ProgramContractValidatorBase( BankInformationSystemDbContext context, ICurrentDateTimeProvider currentDateTimeProvider) { Context = context; CurrentDateTimeProvider = currentDateTimeProvider; RuleFor(x => x.ContractNumber) .MustAsync(BeUniqueContractNumberAsync) .WithMessage("Contract with specified id already exists."); RuleFor(x => x.ProgramStartDate) .Must(BeTodayDateOrLater) .WithMessage("'{PropertyName}' must be a today or a later date."); RuleFor(x => x.ProgramEndDate) .GreaterThanOrEqualTo(x => x.ProgramStartDate.AddDays(30).Date) .WithMessage("Program term must be at least 30 days."); RuleFor(x => x.ContractValidUntil) .GreaterThanOrEqualTo(x => x.ProgramEndDate.Date) .WithMessage("'{PropertyName}' must be a program end date or a later date."); RuleFor(x => x.CustomerId) .MustAsync(BeIdOfExistingCustomerAsync) .WithMessage("Specified customer does not exist."); }
public CustomerService( BankInformationSystemDbContext context, IValidator <CustomerCreateModel> customerCreateModelValidator, IValidator <CustomerUpdateModel> customerUpdateModelValidator, IMapper mapper) { _context = context; _customerCreateModelValidator = customerCreateModelValidator; _customerUpdateModelValidator = customerUpdateModelValidator; _mapper = mapper; }
public CustomerUpdateModelValidator(BankInformationSystemDbContext context) : base(context) { RuleFor(x => x) .MustAsync(async(customer, passport, token) => await HaveUniqueNameAsync(passport, customer.Id, token)) .WithMessage("Customer with specified name already exists."); RuleFor(x => x.Passport) .MustAsync(async(customer, passport, token) => await HaveUniqueFullPassportNumberAsync(passport, customer.Id, token)) .WithMessage("Customer with specified passport already exists."); RuleFor(x => x.Passport) .MustAsync(async(customer, passport, token) => await HaveUniqueIdNumberAsync(passport, customer.Id, token)) .WithMessage("Customer with specified id number already exists."); }
public BankMetaOperationsService( BankInformationSystemDbContext context, IMapper mapper, ICurrentDateTimeProvider currentDateTimeProvider, IVirtualDateTimeManager virtualDateTimeManager, IConfiguration configuration) { _context = context; _mapper = mapper; _currentDateTimeProvider = currentDateTimeProvider; _virtualDateTimeManager = virtualDateTimeManager; _configuration = configuration; }
public DepositService( BankInformationSystemDbContext context, IMapper mapper, IAccountService accountService, ICurrentDateTimeProvider currentDateTimeProvider, IValidator <DepositCreateModel> depositCreateModelValidator) { _context = context; _mapper = mapper; _accountService = accountService; _currentDateTimeProvider = currentDateTimeProvider; _depositCreateModelValidator = depositCreateModelValidator; }
public DepositCreateModelValidator( BankInformationSystemDbContext context, ICurrentDateTimeProvider currentDateTimeProvider) : base(context, currentDateTimeProvider) { RuleFor(x => x.Amount) .GreaterThanOrEqualTo(MinimalDepositAmount) .WithMessage($"'{{PropertyName}}' must be at least {MinimalDepositAmount} currency units."); RuleFor(x => x.Rate) .ExclusiveBetween(0, MaximalDepositRate) .WithMessage($"'{{PropertyName}}' must be a positive number less than {MaximalDepositRate}."); }
public LoanCreateModelValidator( BankInformationSystemDbContext context, ICurrentDateTimeProvider currentDateTimeProvider, IConfiguration configuration) : base(context, currentDateTimeProvider) { _configuration = configuration; RuleFor(x => x.Amount) .GreaterThanOrEqualTo(MinimalLoanAmount) .WithMessage($"'{{PropertyName}}' must be at least {MinimalLoanAmount} currency units."); RuleFor(x => x.Rate) .GreaterThanOrEqualTo(MinimalLoanRate) .WithMessage($"'{{PropertyName}}' must be greater than or equal to {MinimalLoanRate}."); RuleFor(x => x.ProgramEndDate) .Must(BeNDaysLaterThanProgramStartDateWhereNIsMultipleOfLoanTermDays) .WithMessage($"Difference between program end and start dates must be a multiple of {_configuration.GetValue<int>("LoanTermDays")}."); }
public VirtualDateTimeProvider(BankInformationSystemDbContext context) { _context = context; }
public CustomerFullInfoBaseModelValidator(BankInformationSystemDbContext context) { _context = context; RuleFor(x => x.FirstName) .NotEmpty() .Matches(ValidationConstants.NameRegex); RuleFor(x => x.LastName) .NotEmpty() .Matches(ValidationConstants.NameRegex); RuleFor(x => x.MiddleName) .NotEmpty() .Matches(ValidationConstants.NameRegex); RuleFor(x => x.Passport) .NotNull(); RuleFor(x => x.Passport.Series) .NotEmpty(); RuleFor(x => x.Passport.IdNumber) .NotEmpty(); RuleFor(x => x.Passport.IssuingAuthority) .NotEmpty(); RuleFor(x => x.Passport.PassportNumber) .NotEmpty(); RuleFor(x => x.BirthInfo) .NotNull(); RuleFor(x => x.BirthInfo.PlaceOfBirth) .NotEmpty(); RuleFor(x => x.PlaceOfLiving) .NotNull(); RuleFor(x => x.PlaceOfLiving.Address) .NotEmpty(); RuleFor(x => x.PlaceOfRegistration) .NotNull(); RuleFor(x => x.PlaceOfRegistration.Address) .NotEmpty(); RuleFor(x => x.Contacts) .NotNull(); RuleFor(x => x.Contacts.Email) .EmailAddress().When(x => x.Contacts?.Email != null); RuleFor(x => x.Contacts.HomePhoneNumber) .Matches(ValidationConstants.PhoneNumberRegex) .When(x => x.Contacts?.HomePhoneNumber != null); RuleFor(x => x.Contacts.MobilePhoneNumber) .Matches(ValidationConstants.PhoneNumberRegex) .When(x => x.Contacts?.MobilePhoneNumber != null); RuleFor(x => x.IncomePerMonth.Amount) .GreaterThanOrEqualTo(0) .When(x => x.IncomePerMonth != null); RuleFor(x => x.WorkInfo.Company) .NotEmpty() .When(x => x.WorkInfo != null); RuleFor(x => x.WorkInfo.Position) .NotEmpty() .When(x => x.WorkInfo != null); }
public AuthorizationService(BankInformationSystemDbContext context) { _context = context; }