public ActionResult Edit(int id, Driver contact) { if ((id > 0) && (contact != null) && (ModelState.IsValid)) { Ddao.UpdateDriver(contact); return(RedirectToAction("Index")); } else { return(View("Edit")); } }
public ActionResult SaveEdition() { DriverDAO dao = new DriverDAO(); String username = Request.Form["txtUsername"]; try { int phonenumber = int.Parse(Request.Form["txtPhonenumber"]); String fullname = Request.Form["txtFullname"]; if (fullname.Trim().Length != 0 && phonenumber > 0) { ParkinglotOnline.Models.Driver driver = new ParkinglotOnline.Models.Driver { Username = username, Fullname = fullname, PhoneNumber = phonenumber, }; dao.UpdateDriver(driver); ViewBag.Status = "Update \"" + username + "\" successfully !!!"; } else { ViewBag.Status = "Phone must be number and can't be blank any field"; } } catch (Exception) { ViewBag.Status = "Phone must be number and can't be blank any field"; } //search after edit DriverManageModel model = new DriverManageModel(); model.ListDriver = dao.SearchByNameOrId(username, 1, 4); ViewData["lastSearch"] = username; MultipleAdmin modelMulti = new MultipleAdmin(); modelMulti.Divermanager = model; return(View("Index", modelMulti)); }