public async Task <List <CheckDTO> > GetAll(bool?simpleStatus) { var checks = await _checks.GetAll().ToListAsync(); var dtos = _mapper.Map <List <CheckDTO> >(checks); foreach (var check in dtos) { await SetLastResultStatus(check, simpleStatus ?? false); } return(dtos); }
public async Task <List <CheckDTO> > GetAllAsync() { var checks = await _checks.GetAll().ToListAsync(); var dtos = _mapper.Map <List <CheckDTO> >(checks); var lastResultStatuses = await _lastResultStatuses.GetAll() .Where(x => dtos.Select(y => y.ID).Contains(x.CheckID)) .ToListAsync(); foreach (var dto in dtos) { SetLastResultStatus(dto, lastResultStatuses.FirstOrDefault(x => x.CheckID == dto.ID)); } return(dtos); }