Exemple #1
0
        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));
        }
Exemple #2
0
        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));
        }
Exemple #3
0
        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();
        }
Exemple #4
0
        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));
        }
Exemple #5
0
        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"));
        }
Exemple #6
0
 public void EditBoardgame(BoardgameModel model)
 {
     db.Entry(model).State = System.Data.Entity.EntityState.Modified;
     db.SaveChanges();
 }
Exemple #7
0
 public void AddBoardgame(BoardgameModel model)
 {
     db.Boardgames.Add(model);
     db.SaveChanges();
 }