Exemple #1
0
        public ActionResult AddGame()
        {
            var boardgameViewModel = new BoardgameViewModel
            {
                Title          = "Add new Game",
                AddButtonTitle = "Add",
                RedirectUrl    = Url.Action("Index", "BoardGame")
            };

            return(View(boardgameViewModel));
        }
Exemple #2
0
        public async Task <ActionResult> EditGame(int id)
        {
            var boardgame = await _boardService.GetGameAsync(id);

            var studentViewModel = new BoardgameViewModel
            {
                Title          = "Edit Game",
                AddButtonTitle = "Save",
                RedirectUrl    = Url.Action("Index", "BoardGame"),
                Name           = boardgame.ProductName,
                Id             = boardgame.ProductId
            };

            return(View(studentViewModel));
        }
Exemple #3
0
        public async Task <ActionResult> AddNewGame(BoardgameViewModel boardViewModel, string redirectUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(boardViewModel));
            }

            var boardgame = new Boardgame
            {
                ProductName = boardViewModel.Name,
                Coast       = boardViewModel.Coast,
                Rang        = boardViewModel.Rang,
                Description = boardViewModel.Description,
                Count       = boardViewModel.Count
            };

            await _boardService.AddGamesAsync(boardgame);

            return(RedirectToLocal(redirectUrl));
        }
Exemple #4
0
        public async Task <ActionResult> SaveGame(BoardgameViewModel boardgameViewModel, string redirectUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(boardgameViewModel));
            }

            var boardgame = await _boardService.GetGameAsync(boardgameViewModel.Id);

            if (boardgame != null)
            {
                boardgame.ProductName = boardgameViewModel.Name;
                boardgame.Description = boardgameViewModel.Description;
                boardgame.ProductName = boardgameViewModel.ProductName;
                boardgame.Coast       = boardgameViewModel.Coast;
                boardgame.Count       = boardgameViewModel.Count;
                await _boardService.UpdategameAsync(boardgame);
            }

            return(RedirectToLocal(redirectUrl));
        }