public bool CreateTwistPrompt(TwistPromptCreate model) { var entity = new TwistPrompt() { AdminId = _userId, Twist = model.Twist, CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.TwistPrompts.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(TwistPromptCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateTwistPromptService(); if (service.CreateTwistPrompt(model)) { TempData["Saveresult"] = "Your plot twist was created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Your plot twist could not be created."); return(View(model)); }