public ActionResult delete(int id) { MessageTemplateRepository m_rep = new MessageTemplateRepository(); MessageTemplate m = new MessageTemplate(); //GET Committee try { m = m_rep.getById(id); } catch (Exception exception) { //IF THERE IS A MESS UP, RETURN ERROR TO FRONT TempData["flash"] = "Unable to retrieve message: " + exception.Message; return RedirectToAction("Index"); } //DELETE Committee try { m_rep.delete(m); TempData["flash"] = "Deleted message."; return RedirectToAction("Index"); } catch (Exception exception) { TempData["flash"] = "Unable to delete message: " + exception.Message; return RedirectToAction("Index"); } }
public ActionResult Detail(int id) { IMessageTemplateRepository model = new MessageTemplateRepository(); ViewData.Model = model.getById(id); return View(); }
public ActionResult edit(FormCollection collection) { //Generate new Committee object for form if error MessageTemplateRepository message_rep = new MessageTemplateRepository(); MessageTemplate message = new MessageTemplate(); //GET Committee try { message = message_rep.getById(Int32.Parse(collection["message_id"])); TempData["message"] = message; } catch (Exception exception) { //IF THERE IS A MESS UP, RETURN ERROR TO FRONT TempData["flash"] = "Unable to retrieve message: " + exception.Message; return RedirectToAction("edit", new { controller = "MessageTemplate", id = collection["message_id"] }); } //UPDATE Committee try { return messageTemplateFormProcess(message, message_rep, collection); } catch (Exception exception) { //IF THERE IS A MESS UP, RETURN ERROR TO FRONT TempData["flash"] = "Unable to update message: " + exception.Message; return RedirectToAction("edit", new { controller = "MessageTemplate", id = collection["message_id"] }); } }
public ActionResult edit(int id) { MessageTemplateRepository message_rep = new MessageTemplateRepository(); ViewData["message_id"] = id.ToString(); ViewData.Model = message_rep.getById(id); ViewData["edit"] = true; return View(); }