public ActionResult Create(TheaterProductionCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateTheaterProductionService(); if (service.CreateTheaterProduction(model)) { TempData["SaveResult"] = "Your theater production was added."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Theater production could not be added."); return(View(model)); }
public bool CreateTheaterProduction(TheaterProductionCreate model) { var entity = new TheaterProduction() { OwnerID = _userID, Title = model.Title, MainCast = model.MainCast, Description = model.Description, YearReleased = model.YearReleased, DateWatched = model.DateWatched, IsRecommended = model.IsRecommended, CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.TheaterProductions.Add(entity); return(ctx.SaveChanges() == 1); } }