public ActionResult Create(int eventid) { Announcement model = new Announcement(); model.EventID = eventid; model.PublishDate = DateTime.Today; return View(model); }
public ActionResult Create(Announcement announcement) { try { service.CreateAnnouncement(new CodeCampService.Announcement { EventID = announcement.EventID, Title = announcement.Title, Content = announcement.Content, PublishDate = announcement.PublishDate }); return RedirectToAction("Index"); } catch { // TODO: show the error return View(announcement); } }
public ActionResult Delete(int id) { try { service.DeleteAnnouncement(id); return RedirectToAction("Index"); } catch { var announcement = service.GetAnnouncement(id); Announcement model = new Announcement() { ID = announcement.ID, EventID = announcement.EventID, Title = announcement.Title, Content = announcement.Content, PublishDate = announcement.PublishDate }; return View("Details", model); } }
// // GET: /Announcement/Details/5 public ActionResult Details(int id) { var announcement = service.GetAnnouncement(id); Announcement model = new Announcement() { ID = announcement.ID, EventID = announcement.EventID, Title = announcement.Title, Content = announcement.Content, PublishDate = announcement.PublishDate }; return View(model); }
public ActionResult Edit(Announcement announcement) { try { service.UpdateAnnouncement(new CodeCampService.Announcement { ID = announcement.ID, EventID = announcement.EventID, Title = announcement.Title, Content = announcement.Content, PublishDate = announcement.PublishDate }); return RedirectToAction("Index"); } catch { return View(); } }