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); }
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)); }
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)); } }