Exemple #1
0
    public async Task <ClubStatsViewModel> GetClubStats(string clubInitials)
    {
        var seasonStats = await _coreClubService.GetClubStats(clubInitials);

        var firstSeason = seasonStats.FirstOrDefault();
        var club        = await _coreClubService.GetMinimalClub(clubInitials);

        ClubStatsViewModel returnObj;

        if (seasonStats != null && firstSeason != null)
        {
            returnObj = new ClubStatsViewModel
            {
                Initials = firstSeason.ClubInitials,
                Name     = firstSeason.ClubName,
                StatisticsDescription = club.StatisticsDescription,
                SeasonStats           = _mapper.Map <IEnumerable <ClubSeasonStatsViewModel> >(seasonStats)
            };
        }
        else
        {
            returnObj = new ClubStatsViewModel
            {
                Initials = club.Initials,
                Name     = club.Name,
                StatisticsDescription = club.StatisticsDescription,
                SeasonStats           = new List <ClubSeasonStatsViewModel>()
            };
        }
        return(returnObj);
    }