public ActionResult Edit(UserViewModel input) { try { users.First(x => x.Id == input.Id).FirstName = input.FirstName; users.First(x => x.Id == input.Id).LastName = input.LastName; users.First(x => x.Id == input.Id).Email = input.Email; var viewModel = users.First(x => x.Id == input.Id); var updateSucced = new { html = RenderPartialViewToString("_Details", viewModel), message = "User details has been updated" }; return Json(updateSucced); } catch { var updateFailed = new { messageError = "update item failed" }; return Json(updateFailed); } }
public UserController() { if (users == null) { users = new List<UserViewModel>(); var user1 = new UserViewModel(); user1.Id = Guid.NewGuid(); user1.FirstName = "David"; user1.LastName = "Beckham"; user1.Email = "*****@*****.**"; var user2 = new UserViewModel(); user2.Id = Guid.NewGuid(); user2.FirstName = "Eric"; user2.LastName = "Cantona"; user2.Email = "*****@*****.**"; users.Add(user1); users.Add(user2); } }