Esempio n. 1
0
        public IActionResult GetAthlete(int athleteId)
        {
            Athlete athlete = _context.GetAthlete(athleteId);

            if (athlete == null)
            {
                return(NotFound());
            }
            return(Json(athlete));
        }
Esempio n. 2
0
        public async Task <IActionResult> GetAthlete([FromQuery] int athleteId)
        {
            var response = new SingleModelResponse <Athlete>()
                           as ISingleModelResponse <Athlete>;

            try
            {
                if (athleteId < 1)
                {
                    throw new Exception("Athlete Id is null");
                }
                response.Model = await Task.Run(() =>
                {
                    Athlete athlete = _context.GetAthlete(athleteId);
                    if (athlete == null)
                    {
                        throw new Exception("Athlete does not Exist");
                    }
                    return(athlete);
                });
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }
            return(response.ToHttpResponse());
        }