public ActionResult GameDetails(int?boardgameID) { if (boardgameID == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BoardgameModel boardgame = repo.GetBoardgameByID(boardgameID); if (boardgame == null) { return(HttpNotFound()); } BoardgameDisplayModel newDisplay = new BoardgameDisplayModel { BoardgameID = boardgame.ID, DisplayDate = DateTime.Now, Source = DisplaySource.WWW }; repo.AddNewDisplay(newDisplay); List <BoardgameDisplayModel> gameDisplaysList = repo.GetLast10GameDisplays(boardgame.ID); var model = new GameDetailsViewModel { Boardgame = boardgame, GameDisplaysList = gameDisplaysList }; return(View(model)); }
public ActionResult EditGame([Bind(Include = "ID,BoardgameName,MinPlayers,MaxPlayers,MinAge")] BoardgameModel model) { if (ModelState.IsValid) { repo.EditBoardgame(model); return(RedirectToAction("Index", "Home")); } return(View(model)); }
public void DeleteBoardgame(BoardgameModel model) { var gameDisplays = db.BoardgameDisplays.Where(display => display.BoardgameID == model.ID); foreach (var display in gameDisplays) { db.BoardgameDisplays.Remove(display); } db.Boardgames.Remove(model); db.SaveChanges(); }
public ActionResult DeleteGame(int?boardgameID) { if (boardgameID == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BoardgameModel boardgame = repo.GetBoardgameByID(boardgameID); if (boardgame == null) { return(HttpNotFound()); } return(View(boardgame)); }
public ActionResult DeleteConfirmation(int?boardgameID) { if (boardgameID == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BoardgameModel boardgame = repo.GetBoardgameByID(boardgameID); if (boardgame == null) { return(HttpNotFound()); } repo.DeleteBoardgame(boardgame); return(RedirectToAction("Index", "Home")); }
public void EditBoardgame(BoardgameModel model) { db.Entry(model).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); }
public void AddBoardgame(BoardgameModel model) { db.Boardgames.Add(model); db.SaveChanges(); }