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

            try
            {
                if (athleteId < 1)
                {
                    throw new Exception("Athlete Id is null");
                }
                response.Model = await Task.Run(() =>
                {
                    IEnumerable <EventRegistration> regs = _context.GetAthleteRegistrations(athleteId);
                    if (regs == null)
                    {
                        throw new Exception("No registrations");
                    }
                    _context.SaveEventRegistration();
                    return(regs);
                });
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }
            return(response.ToHttpResponse());
        }
Esempio n. 2
0
 public IActionResult GetAthleteRegistrations(int athleteId)
 {
     if (ModelState.IsValid)
     {
         return(Json(_context.GetAthleteRegistrations(athleteId)));
     }
     else
     {
         return(BadRequest(ModelState));
     }
 }