public ActionResult Delete(int id) { var service = new RepService(); var model = service.GetRepByID(id); return(View(model)); }
public ActionResult Index() { var service = new RepService(); var model = service.GetReps(); return(View(model)); }
public ActionResult DeletePost(int id) { var service = new RepService(); service.DeleteRep(id); TempData["SaveResult"] = "Your rep was deleted"; return(RedirectToAction("Index")); }
public ActionResult Create(RepCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = new RepService(); service.CreateRep(model); return(RedirectToAction("Index")); }
public ActionResult Edit(int id) { var service = new RepService(); var detail = service.GetRepByID(id); var model = new RepDetail { ID = detail.ID, Name = detail.Name, Email = detail.Email, }; return(View(model)); }
public ActionResult Edit(int id, RepDetail model) { if (!ModelState.IsValid) { return(View(model)); } if (model.ID != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var service = new RepService(); if (service.UpdateRep(model)) { TempData["SaveResult"] = "Rep Details Successfully Updated"; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Failed to Update Rep"); return(View(model)); }