public async Task <HttpResponseMessage> GetSpecific(string shipperID) { try { if (shipperID != null) { OrdenEntregaModel model = new OrdenEntregaModel(); List <GetDetailsOrdenEntrega> data = await model.GetSpecific(shipperID); if (data.Count > 0) { return(Request.CreateResponse(HttpStatusCode.OK, data)); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "No fueron encontradas órdenes de compra")); } } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Parámetro nulo")); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public async Task <HttpResponseMessage> Get(Int64?idCliente) { try { if (idCliente != null) { OrdenEntregaModel model = new OrdenEntregaModel(); List <OrdenEntrega> data = await model.Get(idCliente); if (data.Count > 0) { return(Request.CreateResponse(HttpStatusCode.OK, data)); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "No fueron encontradas órdenes de compra")); } } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Parámetro nulo")); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public async Task <HttpResponseMessage> Insert([FromUri] string shipperID) { try { if (shipperID != null) { var result = await Request.Content.ReadAsMultipartAsync(); var requestJson = await result.Contents[0].ReadAsStringAsync(); var data = JsonConvert.DeserializeObject <HistorialEntregas>(requestJson); if (data != null) { HistorialEntregasModel model = new HistorialEntregasModel(); OrdenEntregaModel ordenEntrega = new OrdenEntregaModel(); data.idOrdenEntrega = await ordenEntrega.GetID(shipperID); Int64?idHistorialEntrega = await model.Insert(data); if (data.fotos.Count > 0) { await model.GuardarFotos(new Images(idHistorialEntrega, data.fotos)); } if (data.firmas.Count > 0) { await model.GuardarFirmas(new Images(idHistorialEntrega, data.firmas)); } return(Request.CreateResponse(HttpStatusCode.Created)); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Parámetro nulo")); } } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Parámetro nulo")); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public async Task <HttpResponseMessage> PostDetails([FromBody] List <InsertDetailsOrdenEntrega> data, [FromUri] Int64?idCliente) { try { if (idCliente == null || data == null) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Parámetro nulo")); } else { OrdenEntregaModel model = new OrdenEntregaModel(); await model.InsertDetails(data); return(Request.CreateResponse(HttpStatusCode.Created, data)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public async Task <HttpResponseMessage> Post([FromBody] OrdenEntrega data, [FromUri] Int64?idCliente) { try { if (data == null || idCliente == null) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Parámetro nulo")); } else { OrdenEntregaModel model = new OrdenEntregaModel(); data.idCliente = idCliente; data.idOrdenEntrega = await model.Insert(data); //return IDOrdenEntrega return(Request.CreateResponse(HttpStatusCode.Created, data)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }