public ActionResult AccountInfo() { var accountInformation = _db.Set <AccountInformation>().FirstOrDefault(ec => ec.EducationalCenterId == _siteId); var accountInformationDto = new AccountInformationDto { Banks = _db.Set <Bank>().ToList().Select(b => new SelectListItem { Text = b.Name, Value = b.Id.ToString() }) }; if (accountInformation == null) { return(View(accountInformationDto)); } accountInformationDto.AccountOwnerFirstName = accountInformation.AccountOwnerFirstName; accountInformationDto.AccountOwnerLastName = accountInformation.AccountOwnerLastName; accountInformationDto.BrancheName = accountInformation.BrancheName; accountInformationDto.BrancheCode = accountInformation.BrancheCode; accountInformationDto.AccountNumber = accountInformation.AccountNumber; accountInformationDto.IdPay = accountInformation.IdPay; accountInformationDto.BankId = accountInformation.BankId; return(View(accountInformationDto)); }
public ActionResult AccountInfo(AccountInformationDto model) { var accountInformation = new AccountInformation { EducationalCenterId = _siteId, AccountOwnerFirstName = model.AccountOwnerFirstName, AccountOwnerLastName = model.AccountOwnerLastName, BankId = model.BankId, BrancheCode = model.BrancheCode.Value, BrancheName = model.BrancheName, AccountNumber = model.AccountNumber, IdPay = model.IdPay, IdPayNumbers = model.IdPay.Replace("-", "").Replace("IR", ""), }; _db.Set <AccountInformation>().AddOrUpdate(m => m.EducationalCenterId, accountInformation); _db.SaveChanges(); TempData["Message"] = "با موفقیت ثبت گردید"; return(RedirectToAction("AccountInfo")); }