コード例 #1
0
        public HttpResponseMessage CreateBatch(BatchViewModel batchViewModel)
        {
            var batch = Mapper.BatchMapper.Attach(batchViewModel);

            _batchService.Add(batch);
            _batchService.SaveChanges();

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
コード例 #2
0
        public async Task <IActionResult> Post([FromBody] BatchDto dto)
        {
            try
            {
                await BatchService.Add(dto);

                return(NoContent());
            }
            catch (Exception ex)
            {
                Log.Error($"Error posting batch.");
                throw;
            }
        }
コード例 #3
0
        public IHttpActionResult PostBatch(Batch batch)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            string token = "";

            if (Request.Headers.Contains("oauth_token"))
            {
                token = Request.Headers.GetValues("oauth_token").First();
            }
            try
            {
                batchService.Add(token, batch);
                return(Ok("lote creado con exito"));
            }
            catch (Exception e)
            {
                return(Content(HttpStatusCode.ExpectationFailed, e.Message));
            }
        }