public Task <HttpResponseMessage> Import([FromBody] ExternalStandard externalStandard) { CsetLogManager.Instance.LogInfoMessage("SetsController.Import() - \n{0}", JsonConvert.SerializeObject(externalStandard)); var response = default(HttpResponseMessage); try { if (ModelState.IsValid) { var id = BackgroundJob.Enqueue(() => HangfireExecutor.SaveImport(externalStandard, null)); response = Request.CreateResponse(new { id }); } else { response = Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } } catch (Exception ex) { response = Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message); } return(Task.FromResult(response)); }
/// <summary> /// Import new standards into CSET /// </summary> public async Task <HttpResponseMessage> Post([FromBody] ExternalStandard externalStandard) { return(await Task.Run(() => { try { if (ModelState.IsValid) { var id = BackgroundJob.Enqueue(() => HangfireExecutor.SaveImport(externalStandard, null)); return Request.CreateResponse(new { id }); } else { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } } catch (Exception) { return Request.CreateResponse(); } })); }
public Task <HttpResponseMessage> Import([FromBody] ExternalStandard externalStandard) { var response = default(HttpResponseMessage); try { if (ModelState.IsValid) { var id = BackgroundJob.Enqueue(() => HangfireExecutor.SaveImport(externalStandard, null)); response = Request.CreateResponse(new { id }); } else { response = Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } } catch (Exception ex) { response = Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message); } return(Task.FromResult(response)); }