public async Task <IActionResult> GetRegistration([FromQuery] int regId) { var response = new SingleModelResponse <EventRegistration>() as ISingleModelResponse <EventRegistration>; try { if (regId < 1) { throw new Exception("Registration Id is null"); } response.Model = await Task.Run(() => { EventRegistration regs = _context.GetEventRegByID(regId); if (regs == null) { throw new Exception("No registrations"); } return(regs); }); } catch (Exception ex) { response.DidError = true; response.ErrorMessage = ex.Message; } return(response.ToHttpResponse()); }
public IActionResult GetRegistration(int regId) { if (ModelState.IsValid) { EventRegistration reg = _context.GetEventRegByID(regId); if (reg == null) { return(NotFound()); } return(Json(reg)); } else { return(BadRequest(ModelState)); } }