public async Task<ActionResult> ChangeBirthdate([Bind("Email, NewBirthdate")] ChangeBirthdateViewModel cbvm) { if (User.Identity.Name != cbvm.Email) { return View("Error", new String[] { "There was a problem editing this customer. Try again!" }); } AppUser userLoggedIn = await _userManager.FindByNameAsync(User.Identity.Name); if (ModelState.IsValid == false) { return View(cbvm); } try { //find the record in the database AppUser dbUsers = _context.Users.Where(u => u.Email == cbvm.Email).FirstOrDefault(); //update the notes dbUsers.Birthdate = cbvm.NewBirthdate; _context.Update(dbUsers); await _context.SaveChangesAsync(); } catch (Exception ex) { return View("Error", new String[] { "There was an error updating this order!", ex.Message }); } //send the user to the Account Index page. return RedirectToAction(nameof(Index)); }
public ActionResult ChangeBirthdate(string email) { ChangeBirthdateViewModel newcbvm = new ChangeBirthdateViewModel(); { newcbvm.Email = email; }; return View(newcbvm); }