// GET: Details public ActionResult Details(int id) { var svc = new AudiobookService(); var model = svc.GetAudiobookById(id); return(View(model)); }
// GET: Audiobook public ActionResult Index() { var service = new AudiobookService(); var model = service.GetAudiobooks(); return(View(model)); }
private static AudiobookDetail GetAudiobookService(int id) { var service = new AudiobookService(); var detail = service.GetAudiobookById(id); return(detail); }
public ActionResult DeletePost(int id) { var service = new AudiobookService(); service.DeleteAudiobook(id); TempData["SaveResult"] = "Your audiobook was deleted"; return(RedirectToAction("Index")); }
public ActionResult Create(AudiobookCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = new AudiobookService(); if (service.CreateAudiobook(model)) { TempData["SaveResult"] = "Your audiobook was created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Audiobook could not be created."); return(View(model)); }
public ActionResult Edit(int id, AudiobookEdit audiobookToBeEdited) { if (!ModelState.IsValid) { return(View(audiobookToBeEdited)); } if (audiobookToBeEdited.AudiobookId != id) { ModelState.AddModelError("", "ID does not match an existing item, please try again."); return(View(audiobookToBeEdited)); } var service = new AudiobookService(); if (service.UpdateAudiobook(audiobookToBeEdited)) { TempData["SaveResult"] = "Your audiobook was updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your audiobook could not be updated."); return(View(audiobookToBeEdited)); }