Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        // GET: JournalEntry
        public ActionResult Index()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new JournalEntryServices(userId);

            var model = service.GetEntries();

            return(View(model));
        }
Ejemplo n.º 3
0
        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());
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
0
        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();
        }
Ejemplo n.º 6
0
        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));
        }