public ActionResult Create(SpellCreate spell) { if (!ModelState.IsValid) { return(View(spell)); } var userId = Guid.Parse(User.Identity.GetUserId()); var service = new SpellService(userId); service.CreateSpell(spell); return(RedirectToAction("Index")); }
public bool CreateSpell(SpellCreate model) { var entity = new Spell() { Level = model.Level, SpellName = model.SpellName, CastTime = model.CastTime, CastDuration = model.CastDuration, Range = model.Range, DamageType = model.DamageType, School = model.School, Damage = model.Damage, Components = model.Components }; using (var ctx = new ApplicationDbContext()) { ctx.Spells.Add(entity); return(ctx.SaveChanges() == 1); } }