public Result <PlayedGameDataSourcesDto> GetPlayedGameDataSources() { Result <PlayedGameDataSourcesDto> result = new Result <PlayedGameDataSourcesDto>(); try { var resultsDataSourceList = this.GetResultsDataSource(); var teamsDataSourceResult = this.GetFootballTeamsDataSource(); if (teamsDataSourceResult.IsError) { result.SetError(teamsDataSourceResult.Message); return(result); } PlayedGameDataSourcesDto dataSourceDto = new PlayedGameDataSourcesDto { Teams = teamsDataSourceResult.Data.ToDictionary(t => t.ID, t => t), Results = resultsDataSourceList.ToDictionary(r => r.ID, r => r) }; return(result.SetData(dataSourceDto)); } catch (Exception ex) { result.SetError(ex.Message); return(result); } }
private PlayedGameDto FillGameAdditionalData(PlayedGameDataSourcesDto dataSources, PlayedGameDto gameDto) { gameDto.HomeTeamName = dataSources.Teams[gameDto.HomeTeamId].Name; gameDto.AwayTeamName = dataSources.Teams[gameDto.AwayTeamId].Name; gameDto.ResultName = dataSources.Results[(int)gameDto.Result].Name; return(gameDto); }
private PlayedGameDataSourcesViewModel MapPlayedGamesDataSources(PlayedGameDataSourcesDto data) { PlayedGameDataSourcesViewModel dataSourceViewModel = new PlayedGameDataSourcesViewModel() { Teams = new Dictionary <int, DataSourceViewModel>(), Results = new Dictionary <int, DataSourceViewModel>() }; foreach (var teamItem in data.Teams) { DataSourceViewModel sourceViewModel = Mapper.Map <DataSourceDto, DataSourceViewModel>(teamItem.Value); dataSourceViewModel.Teams.Add(teamItem.Key, sourceViewModel); } foreach (var resultItem in data.Results) { DataSourceViewModel sourceViewModel = Mapper.Map <DataSourceDto, DataSourceViewModel>(resultItem.Value); dataSourceViewModel.Results.Add(resultItem.Key, sourceViewModel); } return(dataSourceViewModel); }