public ActionResult Create(int id) { var model = new JournalCreate { CharacterId = id, OwnerId = GetGuid() }; return(View(model)); }
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); } }
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)); }
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)); }
private JournalService CreateJournalService(JournalCreate journal) { var service = new JournalService(GetGuid(), journal.CharacterId); return(service); }