public async Task <IActionResult> GetFull(string id) { if (string.IsNullOrWhiteSpace(id)) { return(BadRequest()); } var region = await _regionDbSet.FindAsync(id); var genders = await _genderDbSet.ToListAsync(); var newBorns = await _newBornDbSet.Where(n => n.Region.Id == region.Id).ToListAsync(); if (region == null) { return(NotFound(region)); } if (genders == null || genders.Count == 0) { return(NotFound(genders)); } if (newBorns == null || newBorns.Count == 0) { return(NotFound(newBorns)); } var newBornsV1 = newBorns.Select(n => NewBornV1.Translate(n)); var gendersV1 = genders.Select(g => GenderFullV1.Translate(g, newBorns.Where(n => n.Gender.Id == g.Id).Select(n => NewBornV1.Translate(n)).ToList().OrderBy(n => n.Year))); return(Ok(RegionFullV1.Translate(region, gendersV1))); }
public async Task <IActionResult> Get([FromRoute] string regionId, [FromRoute] int genderId, int year) { if (string.IsNullOrWhiteSpace(regionId) || genderId == 0 || year == 0) { return(BadRequest()); } var newBorn = await _newBornDbSet.Where(n => n.Year == year).FirstAsync(); if (newBorn == null) { return(NotFound(newBorn)); } return(Ok(NewBornV1.Translate(newBorn))); }