public ActionResult Edit(int id, JournalEdit journal)
        {
            if (!ModelState.IsValid)
            {
                return(View(journal));
            }

            if (journal.JournalId != id)
            {
                ModelState.AddModelError("", "Id mismatch.");
                return(View(journal));
            }

            var service   = new JournalService(GetGuid());
            var journalId = service.GetJournalById(id);

            if (service.UpdateJournalEntry(journal))
            {
                TempData["SaveResult"] = "Your character has been updated.";
                return(RedirectToAction("Index", "Journal", new { id = journalId.CharacterId }));
            }

            ModelState.AddModelError("", "Your character could not be updated.");
            return(View());
        }
Example #2
0
        public bool UpdateJournalEntry(JournalEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.Journals.Single(e => e.JournalId == model.JournalId && e.OwnerId == _ownerId);

                entity.Title       = model.Title;
                entity.Content     = model.Content;
                entity.ModifiedUtc = DateTimeOffset.Now;

                return(ctx.SaveChanges() == 1);
            }
        }
Example #3
0
        public ActionResult Edit(int id)
        {
            var service = CreateJournalService();
            var detail  = service.GetJournalById(id);
            var model   = new JournalEdit
            {
                JournalId = detail.JournalId,
                LoggerId  = detail.LoggerId,
                Title     = detail.Title,
                Content   = detail.Content,
            };

            return(View(model));
        }
        public ActionResult Edit(int id)
        {
            var service = new JournalService(GetGuid()).GetJournalById(id);

            var model = new JournalEdit
            {
                JournalId   = service.JournalId,
                CharacterId = service.CharacterId,
                Title       = service.Title,
                Content     = service.Content,
                ModifiedUtc = DateTimeOffset.Now
            };

            return(View(model));
        }
Example #5
0
        public ActionResult Edit(int id, JournalEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.JournalId != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = CreateJournalService();

            if (service.UpdateJournal(model))
            {
                TempData["SaveResult"] = "Your journal was updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your journal could not be updated.");
            return(View(model));
        }