public bool CreateBlitz(BlitzCreate model) { var entity = new Blitz() { Name = model.Name, Location = model.Location, Date = model.Date, CreatedUtc = model.CreatedUtc }; using (var ctx = new ApplicationDbContext()) { ctx.Blitzes.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(BlitzCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateBlitzService(); if (service.CreateBlitz(model)) { TempData["SaveResult"] = "Your Blitz was created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Blitz could not be created."); return(View(model)); }