public bool CreateSpellbook(CreateSpellbookModel model) { var entity = new Data.Spellbook() { SpellbookName = model.SpellbookName, UserId = _userId }; using (var ctx = new ApplicationDbContext()) { ctx.Spellbooks.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(CreateSpellbookModel model) { if (!ModelState.IsValid) { return(View(model)); } if (!GetSpellbookService().CreateSpellbook(model)) { ModelState.AddModelError("", "Unable to create spellbook"); return(View(model)); } TempData["SaveResult"] = "Your spellbook was created"; return(RedirectToAction("Index")); }
public ActionResult Create() { var model = new CreateSpellbookModel(); return(View(model)); }