// GET: MyAccount public async Task <IActionResult> Index() { var customer = await ecommerceContext.CurrentCustomer(); var customerModel = new CustomerAccountViewModel { Email = customer.Email, Name = customer.Name }; return(View(customerModel)); }
public async Task <IActionResult> Edit([Bind("Name,Email")] CustomerAccountViewModel customerModel) { if (ModelState.IsValid) { var customer = await ecommerceContext.CurrentCustomer(); customer.Email = customerModel.Email; customer.Name = customerModel.Name; await repository.UpdateCustomer(customer); return(RedirectToAction(nameof(Index))); } return(View(customerModel)); }