public async Task <IActionResult> Register([FromBody] EventRegistration reg) { var response = new SingleModelResponse <EventRegistration>() as ISingleModelResponse <EventRegistration>; try { if (reg == null) { throw new Exception("Model is null"); } response.Model = await Task.Run(() => { EventRegistration rreg = _context.Register(reg); return(rreg); }); } catch (Exception ex) { response.DidError = true; response.ErrorMessage = ex.Message; } return(response.ToHttpResponse()); }
public IActionResult Register(EventRegistration reg) { if (ModelState.IsValid) { _context.Register(reg); _context.SaveEventRegistration(); return(Ok(reg.RegistrationId)); } else { return(BadRequest(ModelState)); } }