Esempio n. 1
0
        public ActionResult UpdatePlayedGame(UpdatePlayedGameViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            UpdatePlayedGameDto gameToUpdate = Mapper.Map <UpdatePlayedGameViewModel, UpdatePlayedGameDto>(viewModel);
            Result result = this.service.UpdateGame(gameToUpdate);

            if (result.IsError)
            {
                ModelState.AddModelError("", $"Error: { result.Message }");
            }

            return(RedirectToAction("PlayedGames", "PlayedGame"));
        }
Esempio n. 2
0
        public ActionResult UpdatePlayedGame(int gameId)
        {
            Result <PlayedGameDto> result = this.service.GetGame(gameId);

            if (result.IsError)
            {
                ModelState.AddModelError("", $"Error: { result.Message }");

                return(View());
            }

            UpdatePlayedGameViewModel viewModel = Mapper.Map <PlayedGameDto, UpdatePlayedGameViewModel>(result.Data);
            var dataSourcesResult = this.dataSourceService.GetPlayedGameDataSources();

            if (dataSourcesResult.IsError)
            {
                ModelState.AddModelError("", $"Error: { dataSourcesResult.Message }");

                return(View(viewModel));
            }
            viewModel.DataSources = this.MapPlayedGamesDataSources(dataSourcesResult.Data);

            return(View(viewModel));
        }