コード例 #1
0
        public ActionResult Create(int id)
        {
            var model = new JournalCreate
            {
                CharacterId = id,
                OwnerId     = GetGuid()
            };

            return(View(model));
        }
コード例 #2
0
        public bool CreateJournal(JournalCreate model)
        {
            var entity = new Journal()
            {
                OwnerId    = _userId,
                LoggerId   = model.LoggerId,
                Title      = model.Title,
                Content    = model.Content,
                CreatedUtc = DateTimeOffset.Now
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Journals.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #3
0
        public ActionResult Create(JournalCreate journal)
        {
            if (!ModelState.IsValid)
            {
                return(View(journal));
            }

            var service = CreateJournalService(journal);

            if (service.CreateJournalEntry(journal))
            {
                TempData["SaveResult"] = "Your journal entry was created.";
                return(RedirectToAction("Index", "Journal", new { id = journal.CharacterId }));
            }

            ModelState.AddModelError("", "Journal entry could not be created.");

            return(View(journal));
        }
コード例 #4
0
        public ActionResult Create(JournalCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateJournalService();

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

            ModelState.AddModelError("", "Journal could not be created.");

            return(View(model));
        }
コード例 #5
0
        private JournalService CreateJournalService(JournalCreate journal)
        {
            var service = new JournalService(GetGuid(), journal.CharacterId);

            return(service);
        }