public ActionResult Edit(int id, TitleEdit model) { if (!ModelState.IsValid) { var wrestlerList = new WrestlerRepo(); model.Wrestlers = wrestlerList.GetWrestlers(); return(View(model)); } if (model.TitleId != id) { ModelState.AddModelError("", "ID Mismatch"); return(View(model)); } var service = CreateTitleService(); if (service.UpdateTitle(model)) { TempData["SaveResult"] = "The title has been updated!"; return(RedirectToAction("Index")); } ModelState.AddModelError("", "The title could not be updated."); return(View(model)); }
//GET: Create public ActionResult Create() { var model = new TitleCreate(); var promotionList = new PromotionRepo(); var wrestlerList = new WrestlerRepo(); model.Promotions = promotionList.GetPromotions(); model.Wrestlers = wrestlerList.GetWrestlers(); return(View(model)); }
//GET: Edit public ActionResult Edit(int id) { var service = CreateTitleService(); var detail = service.GetTitleById(id); var wrestlerList = new WrestlerRepo(); var model = new TitleEdit { TitleId = detail.TitleId, TitleName = detail.TitleName, //IsStarred = detail.IsStarred, DateEstablished = detail.DateEstablished, WrestlerId = detail.WrestlerId }; model.Wrestlers = wrestlerList.GetWrestlers(); return(View(model)); }
public ActionResult Create(TitleCreate model) { if (!ModelState.IsValid) { var promotionList = new PromotionRepo(); var wrestlerList = new WrestlerRepo(); model.Promotions = promotionList.GetPromotions(); model.Wrestlers = wrestlerList.GetWrestlers(); return(View(model)); } var service = CreateTitleService(); if (service.CreateTitle(model)) { TempData["SaveResult"] = "Your title has been created!"; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Title could not be created."); return(View(model)); }