示例#1
0
 public ActionResult EditGet(int Id)
 {
     var noteService = new NoteService();
     var userId = Guid.Parse(User.Identity.GetUserId());
     var note = (noteService.GetById(Id, userId));
     return View(note);
 }
示例#2
0
 public ActionResult Details(int Id)
 {
     var noteService = new NoteService();
         var userId = Guid.Parse(User.Identity.GetUserId());
         var result = noteService.GetById(Id, userId);
     return View(result);
 }
 public ActionResult DetailsGet(int id)
 {
     var noteService = new NoteService();
     var userId = Guid.Parse(User.Identity.GetUserId());
     var note = noteService.GetById(id, userId);
     return View(note);
 }
        public ActionResult DeleteGet(int id)
        {
            var svc = new NoteService();
            var note = svc.GetById(id, _userId.Value);

            return View(note);
        }
        ///Gets all notes for current user
        public IHttpActionResult GetNotes()
        {
            var service = new NoteService();
            var userId = User.Identity.GetUserId();
            var notes = service.GetAllForUser(Guid.Parse(userId));

            return Ok(notes);
        }
 public ActionResult DeletePost(int id)
 {
     var noteService = new NoteService();
     var userId = Guid.Parse(User.Identity.GetUserId());
     var result = noteService.Delete(id, userId);
     TempData.Add("Result", result ? "Note deleted." : "Note not deleted.");
     return RedirectToAction("Index");
 }
示例#7
0
        public List<NotesController> GetNotes()
        {
            var service = new NoteService();
            var userId = User.Identity.GetUserId();
            var notes = service.GetAllForUser(Guid.Parse(userId)).ToList();

            return Ok(notes);
        }
        // PUT api/<controller>/5
        public IHttpActionResult Put(int id)
        {
            var svc = new NoteService();

            var note = svc.GetById(id, _userId.Value);
            note.IsFavorite = true;

            var result = svc.Update(note, _userId.Value);

            return Ok(result);
        }
 public ActionResult CreatePost(NoteEditViewModel model)
 {
     if (ModelState.IsValid)
     {
         var noteService = new NoteService();
         var userId = Guid.Parse(User.Identity.GetUserId());
         var result = noteService.Create(model, userId);
         TempData.Add("Result", result ? "Note added." : "Note not added.");
         return RedirectToAction("Index");
     }
     return View();
 }
示例#10
0
        public ActionResult Index()
        {
            if (TempData["Result"] != null)
            {
                ViewBag.Success = TempData["Result"];
                TempData.Remove("Result");
            }

            var noteService = new ElevenNote.Services.NoteService();
            var notes       = noteService.GetAllForUser(Guid.Parse(User.Identity.GetUserId()));

            return(View(notes));
        }
        public ActionResult DeletePost(int id)
        {
            var svc = new NoteService();
            var result = svc.Delete(id, _userId.Value);

            TempData.Add(
                "Result",
                result
                    ? "Note deleted"
                    : "Note not deleted");

            return RedirectToAction("Index");
        }
        public ActionResult CreatePost(NoteDetailViewModel vm)
        {
            if (!ModelState.IsValid) return View(vm);

            var svc = new NoteService();

            var result = svc.Create(vm, _userId.Value);

            TempData.Add(
                "Result",
                result
                    ? "Note added"
                    : "Note not added");

            return RedirectToAction("Index");
        }
 // GET: Notes
 public ActionResult Index()
 {
     if (TempData["Result"] != null)
     {
         ViewBag.Success = TempData["Result"];
         TempData.Remove("Result");
     }
     var noteService = new NoteService();
     var notes = noteService.GetAllForUser(Guid.Parse(User.Identity.GetUserId()));
     return View(notes);
 }
 public ActionResult ToggleFavorite(int id)
 {
     var noteService = new NoteService();
     var userId = Guid.Parse(User.Identity.GetUserId());
     noteService.ToggleFavorite(id, userId);
     return RedirectToAction("Index");
 }
        public ActionResult Index()
        {
            var svc = new NoteService();
            var notes = svc.GetAllForUser(_userId.Value);

            return View(notes);
        }