public ActionResult AddPlayedGame(AddPlayedGameViewModel viewModel) { if (!ModelState.IsValid) { return(View(viewModel)); } // Generate the token and send it AddPlayedGameDto gameToAdd = Mapper.Map <AddPlayedGameViewModel, AddPlayedGameDto>(viewModel); Result <PlayedGameDto> result = this.service.AddPlayedGame(gameToAdd); if (result.IsError) { ModelState.AddModelError("", $"Error: { result.Message }"); } return(RedirectToAction("PlayedGames", "PlayedGame")); }
public ActionResult AddPlayedGame() { AddPlayedGameViewModel viewModel = new AddPlayedGameViewModel(); var teamsDataSourceResult = this.dataSourceService.GetFootballTeamsDataSource(); if (teamsDataSourceResult.IsError) { ModelState.AddModelError("", $"Error: { teamsDataSourceResult.Message }"); return(View(viewModel)); } 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)); }