Show episode count for each season

This commit is contained in:
2020-03-12 22:24:44 +01:00
parent 62d98b054b
commit 7bd44091cf
5 changed files with 10 additions and 4 deletions

View File

@@ -8,7 +8,8 @@ namespace EstusShots.Server.Mapping
{
public Profiles()
{
CreateMap<Season, Shared.Dto.Season>();
CreateMap<Season, Shared.Dto.Season>()
.ForMember(x => x.EpisodeCount, y => y.MapFrom(z => z.Episodes.Count));
CreateMap<Shared.Dto.Season, Season>();
CreateMap<Episode, Shared.Dto.Episode>();

View File

@@ -27,7 +27,9 @@ namespace EstusShots.Server.Services
public async Task<ApiResponse<GetSeasonsResponse>> GetSeasons(GetSeasonsParameter parameter)
{
var seasons = await _context.Seasons.ToListAsync();
var seasons = await _context.Seasons
.Include(season => season.Episodes)
.ToListAsync();
var dtos = _mapper.Map<List<Dto.Season>>(seasons);
return new ApiResponse<GetSeasonsResponse>(new GetSeasonsResponse(dtos));
}