private void ParseFormDataAndUpdateDataAccessObject(EditData ed) { var id = new AccountId(int.Parse(txtAccId.Text)); var email = new DAL.Email(txtEmail.Text); var phone = new Phone(txtPhone.Text); var add1 = txtAddress1.Text; var add2 = txtAddress2.Text; var cty = txtCity.Text; var ctry = cbxCounty.Text; var details = new EditAccountDetails(id, email, phone, add1, add2, cty, ctry); ed.UpdateAccount(details); }
public ActionResult EditAccount(int accountId, int customerId) { var accounts = _accountService.GetAccountsForACustomer(customerId); if (!accounts.Any(x => x.Id == accountId)) { return(RedirectToAction("CustomerAccounts", new { customerId = customerId })); } var account = accounts.Single(x => x.Id == accountId); var model = new EditAccountDetails(); model.CustomerId = customerId; model.AccountId = accountId; model.AccountName = account.Name; model.AccountOverdraft = account.Overdraft; return(View(model)); }
public ActionResult EditAccount(EditAccountDetails model) { if (!ModelState.IsValid || !_customerService.CustomerExist(model.CustomerId)) { return(View(model)); } var accounts = _accountService.GetAccountsForACustomer(model.CustomerId); if (!accounts.Any(x => x.Id == model.AccountId)) { return(RedirectToAction("CustomerAccounts", new { customerId = model.CustomerId })); } _accountService.UpdateAccount(new AccountBO { Id = model.AccountId, Name = model.AccountName, Overdraft = model.AccountOverdraft }); return(RedirectToAction("CustomerAccounts", new { customerId = model.CustomerId })); }