public HttpResponseMessage CreateBatch(BatchViewModel batchViewModel) { var batch = Mapper.BatchMapper.Attach(batchViewModel); _batchService.Add(batch); _batchService.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); }
public async Task <IActionResult> Post([FromBody] BatchDto dto) { try { await BatchService.Add(dto); return(NoContent()); } catch (Exception ex) { Log.Error($"Error posting batch."); throw; } }
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)); } }