예제 #1
0
 public async Task CreateBankAccount(CreatureBankAccountDTO creatureBankAccountDTO)
 {
     try
     {
         BankAccount existingNumberBankAccount;
         string      formedNumberBankAccount;
         do
         {
             existingNumberBankAccount = null;
             formedNumberBankAccount   = MethodsBankAccount.FormNumberAccount();
             existingNumberBankAccount = await database.BankAccounts
                                         .FindAsync(p => p.NumberAccount == formedNumberBankAccount);
         }while (existingNumberBankAccount != null);
         BankAccount bankAccount = new BankAccount()
         {
             NumberCard        = creatureBankAccountDTO.NumberCard,
             Name              = creatureBankAccountDTO.Name,
             Balance           = 20000,
             ApplicationUserId = creatureBankAccountDTO.ApplicationUserId,
             LockoutEnabled    = false,
             RequestUnblock    = false,
             NumberAccount     = formedNumberBankAccount
         };
         database.BankAccounts.Create(bankAccount);
         await database.SaveAsync();
     }
     catch (Exception exception)
     {
         logger.Error($"{exception.Message} {exception.StackTrace}");
     }
 }
예제 #2
0
        public async Task <ActionResult> CreateBankAccount(CreatureBankAccountModel model)
        {
            if (ModelState.IsValid)
            {
                CreatureBankAccountDTO creatureBankAccountDTO = new CreatureBankAccountDTO(model.ApplicationUserId,
                                                                                           model.NumberCard, model.Name);

                await bankAccountService.CreateBankAccount(creatureBankAccountDTO);

                logger.Info("Клиент {0} создал новый банковский счет", model.ApplicationUserId);

                return(RedirectToAction("BankAccountsData", "BankAccount"));
            }
            return(View(model));
        }