public ActionResult List() { User loggedUser = Session["LoggedUser"] as User; var notes = _uow.NoteManager.ListAll(x => x.IsActive && x.UserId == loggedUser.UserId).OrderByDescending(x => x.CreateDate).ToList(); List <VMNote> vmNote = VMNote.Parse(notes); return(View(vmNote)); }
public PartialViewResult GetQuickViewSideBarPartial() { User loggedUser = Session["LoggedUser"] as User; List <Note> notes = _uow.NoteManager.ListAll(x => x.IsActive && x.UserId == loggedUser.UserId).OrderByDescending(x => x.CreateDate).ToList(); ViewBag.Notes = VMNote.Parse(notes); return(PartialView("_QuickViewSideBarPartial")); }
public ActionResult Edit(int id) { User loggedUser = Session["LoggedUser"] as User; Session["SelectedNoteId"] = id; // Created to capture in post method when data is sent. Note note = _uow.NoteManager.Get(x => x.NoteId == id && x.UserId == loggedUser.UserId); if (note == null) { TempData["ProcessResult"] = "There was an error while viewing the note."; TempData["AlertType"] = "danger"; return(RedirectToAction("List")); } VMNote vmNote = VMNote.Parse(note); return(View(vmNote)); }
public ActionResult Edit(VMNote model) { User loggedUser = Session["LoggedUser"] as User; int selectedNoteId = Convert.ToInt32(Session["SelectedNoteId"]); Note note = _uow.NoteManager.Get(x => x.NoteId == selectedNoteId && x.UserId == loggedUser.UserId); note.Title = model.Title; note.Body = model.Body; note.UpdateDate = DateTime.Now; var result = _uow.NoteManager.Update(note); Session.Remove("SelectedNoteId"); if (!_uow.SaveChanges()) { TempData["ProcessResult"] = "An enexpected error occurred while updating the note."; TempData["AlertType"] = "danger"; } TempData["ProcessResult"] = "Note updated successfully."; TempData["AlertType"] = "success"; return(RedirectToAction("List")); }