예제 #1
0
        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));
        }
예제 #2
0
 /// <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();
         }
     }));
 }
예제 #3
0
        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));
        }