public ActionResult Details(int id) { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new JournalEntryServices(userId); var model = service.GetEntryById(id); return(View(model)); }
// GET: JournalEntry public ActionResult Index() { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new JournalEntryServices(userId); var model = service.GetEntries(); return(View(model)); }
public ActionResult DeletePost(int id) { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new JournalEntryServices(userId); if (service.DeleteEntry(id)) { TempData["SaveResult"] = "Your journal entry was deleted."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your entry could not be deleted."); return(View()); }
public ActionResult Edit(int id) { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new JournalEntryServices(userId); var detail = service.GetEntryById(id); var model = new JournalEntryEdit { JournalEntryId = detail.JournalEntryId, Content = detail.Content, PhotoUrl = detail.PhotoUrl, PublicOrPrivate = detail.PublicOrPrivate, Tag = detail.Tag }; return(View(model)); }
public ActionResult Create(JournalEntryCreate model) { if (!ModelState.IsValid) { return(View(model)); } var userId = Guid.Parse(User.Identity.GetUserId()); var service = new JournalEntryServices(userId); if (service.CreateEntry(model)) { TempData["SaveResult"] = "Your entry was created."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Resource could not be created."); return(View(model)); //GetPrompt(); }
public ActionResult Edit(int id, JournalEntryEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.JournalEntryId != id) { ModelState.AddModelError("", "Sorry, looks like we didn't find a Journal Entry with that Id."); return(View(model)); } var userId = Guid.Parse(User.Identity.GetUserId()); var service = new JournalEntryServices(userId); if (service.UpdateEntry(model)) { TempData["SaveResult"] = "Your journal entry was updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your entry could not be updated."); return(View(model)); }