public ActionResult Edit(User user) { if (ModelState.IsValid) { UserBusinessLayer userBusinessLayer = new UserBusinessLayer(); userBusinessLayer.SaveUser(user); return(RedirectToAction("Index", new { id = user.UserId })); } return(View(user)); }
public ActionResult SaveUser(User user, string BtnSubmit) { switch (BtnSubmit) { case "Save User": if (ModelState.IsValid) { var userBal = new UserBusinessLayer(); userBal.SaveUser(user); return(this.RedirectToAction("Index")); //return Content(string.Concat(user.FirstName, "|", user.LastName)); } else { var vm = new CreateUserViewModel(); vm.FirstName = user.FirstName; if (!string.IsNullOrEmpty(user.LastName)) { vm.LastName = user.LastName; } else { vm.LastName = ModelState["LastName"].Value.AttemptedValue; } return(View("CreateUser", vm)); //return View("CreateUser"); } case "Cancel": return(this.RedirectToAction("Index")); default: break; } return(new EmptyResult()); }