public bool BossAdd(BossAdd model) { var entity = new Boss() { VideoGameID = model.VideoGameID, BossName = model.BossName, BossNotes = model.BossNotes, BossBeaten = model.BossBeaten }; using (var ctx = new ApplicationDbContext()) { ctx.Bosses.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult BossCreate(BossAdd model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateBossService(); if (service.BossAdd(model)) { TempData["SaveResult"] = "Your Boss was created successfully."; return(RedirectToAction("Index", "VideoGames")); } ModelState.AddModelError("", "Boss could not be created."); return(View(model)); }