public ActionResult QuestCreate(QuestAdd model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateQuestService(); if (service.QuestAdd(model)) { TempData["SaveResult"] = "Your Quest was created successfully."; return(RedirectToAction("Index", "VideoGames")); } ModelState.AddModelError("", "Quest could not be created."); return(View(model)); }
public bool QuestAdd(QuestAdd model) { var entity = new Quest() { VideoGameID = model.VideoGameID, VideoGame = model.VideoGame, QuestName = model.QuestName, QuestNotes = model.QuestNotes, MainQuest = model.MainQuest, QuestComplete = model.QuestComplete }; using (var ctx = new ApplicationDbContext()) { ctx.Quests.Add(entity); return(ctx.SaveChanges() == 1); } }