コード例 #1
0
        public async Task <IActionResult> GetAll([FromRoute] string regionId)
        {
            if (string.IsNullOrWhiteSpace(regionId))
            {
                return(BadRequest());
            }

            var genders = await _genderDbSet.ToListAsync();

            if (genders == null || genders.Count == 0)
            {
                return(NotFound());
            }

            return(Ok(genders.OfType <Gender>().Select(g => GenderV1.Translate(g))));
        }
コード例 #2
0
        public async Task <IActionResult> Get([FromRoute] string regionId, int id)
        {
            if (id == 0)
            {
                return(BadRequest());
            }

            var gender = await _genderDbSet.FindAsync(id);

            var newBornIds = await _newBornDbSet.Where(n => n.Region.Id == regionId && n.Gender.Id == id).Select(n => n.Year).ToListAsync();

            if (gender == null || newBornIds == null || newBornIds.Count == 0)
            {
                return(NotFound(gender));
            }

            return(Ok(GenderV1.Translate(gender, newBornIds)));
        }