Esempio n. 1
0
        public async Task <IActionResult> GetRouteRuns([FromQuery] int routeId)
        {
            var response = new ListModelResponse <Run>()
                           as IListModelResponse <Run>;

            try
            {
                if (routeId < 1)
                {
                    throw new Exception("Route Id is missing");
                }
                response.Model = await Task.Run(() =>
                {
                    IEnumerable <Run> run = _context.GetRouteRuns(routeId);
                    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());
        }
Esempio n. 2
0
        public IActionResult GetRouteRuns(int routeId)
        {
            IEnumerable <Run> runs = _runRepo.GetRouteRuns(routeId);

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