Exemple #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());
        }
Exemple #2
0
 public IActionResult Register(EventRegistration reg)
 {
     if (ModelState.IsValid)
     {
         _context.Register(reg);
         _context.SaveEventRegistration();
         return(Ok(reg.RegistrationId));
     }
     else
     {
         return(BadRequest(ModelState));
     }
 }