示例#1
0
        public async Task <IActionResult> GetRegistrations([FromQuery] int eventId)
        {
            var response = new ListModelResponse <EventRegistration>()
                           as IListModelResponse <EventRegistration>;

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