Exemple #1
0
        public async Task <IActionResult> GetAllRuns([FromQuery] int athleteId)
        {
            var response = new ListModelResponse <Run>()
                           as IListModelResponse <Run>;

            try
            {
                if (athleteId < 1)
                {
                    throw new Exception("Athlete Id is missing");
                }
                response.Model = await Task.Run(() =>
                {
                    IEnumerable <Run> run = _context.GetAllRuns(athleteId);
                    if (run == null)
                    {
                        throw new Exception("Run does not exist");
                    }
                    return(run);
                });
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }
            return(response.ToHttpResponse());
        }
Exemple #2
0
        public IActionResult GetAllRuns(int athleteId)
        {
            IEnumerable <Run> runs = _runRepo.GetAllRuns(athleteId);

            if (runs == null)
            {
                return(NoContent());
            }
            return(Json(runs));
        }