示例#1
0
        public async Task <ActionResult <Trainer> > GetById(int id)
        {
            var result = await _trainersService.GetById(id);

            if (result == null)
            {
                return(NotFound());
            }
            return(Ok(result));
        }
示例#2
0
        public async Task <ActionResult> GetById(Guid id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessages()));
            }


            var result = await _trainerService.GetById(id);

            if (!result.Success)
            {
                return(BadRequest(result.Message));
            }

            var trainerResource = _mapper.Map <Trainer, TrainerResource>(result.Trainer);

            return(Ok(trainerResource));
        }