示例#1
0
        public ModelStateDictionary ValidateBankEditing(EditBankViewModel model, ModelStateDictionary ModelState)
        {
            Bank bank = bankService.GetBankBik(model.BankInfo.BIK);

            if (bank != null && bank.Id != model.Bank.Id)
            {
                ModelState.AddModelError("BankInfo.BIK", "Такой БИК уже существует");
            }
            return(ModelState);
        }
示例#2
0
        public IActionResult Edit(int bankId)
        {
            Bank bank = bankService.GetBank(bankId);
            EditBankViewModel model = new EditBankViewModel {
                Bank = bank, BankInfo = new CreateBankViewModel {
                    BIK = bank.BIK, Email = bank.BankInfo.Email, BankName = bank.BankInfo.BankName
                }
            };

            return(View(model));
        }
示例#3
0
        public IActionResult Edit(EditBankViewModel model)
        {
            validationService.ValidateBankEditing(model, ModelState);

            if (ModelState.IsValid)
            {
                bankService.EditBankInfo(model.Bank.BankInfo, model.BankInfo);
                bankService.EditBank(model.Bank.Id, model.BankInfo);
                return(RedirectToAction("Index", "Bank"));
            }
            else
            {
                return(View(model));
            }
        }