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()); }
public IActionResult GetAthleteRegistrations(int athleteId) { if (ModelState.IsValid) { return(Json(_context.GetAthleteRegistrations(athleteId))); } else { return(BadRequest(ModelState)); } }