public string deleteShipment(int id) { string rpta; shipments shipment = new shipments(); try { using (var ctx = new transshipEntities()) { shipment = ctx.shipments.FirstOrDefault(x => x.shipmentId == id); if (shipment != null) { ctx.Entry(shipment).State = EntityState.Deleted; ctx.SaveChanges(); rpta = "ok"; } else { rpta = "fail"; } } } catch (Exception e) { LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty)); throw e; } return(rpta); }
public HttpResponseMessage GetByPO(int customerId, string PO) { try { BOShipments shipment = new BOShipments(); var Shipments = new shipments(); Shipments = shipment.getShipmentByPO(customerId, PO); return(Request.CreateResponse(HttpStatusCode.OK, Shipments)); } catch (Exception e) { ErrorMessage mensaje = new ErrorMessage("2.1", "Exception to get shipments - " + e.GetBaseException().Message, e.ToString()); return(Request.CreateResponse(HttpStatusCode.InternalServerError, mensaje)); } }
public HttpResponseMessage GetOne(int shipmentId) { try { BOShipments Shipment = new BOShipments(); var shipment = new shipments(); shipment = Shipment.getOneShipment(shipmentId); return(Request.CreateResponse(HttpStatusCode.OK, shipment)); } catch (Exception e) { ErrorMessage mensaje = new ErrorMessage("2.1", "Exception to get shipment - " + e.GetBaseException().Message, e.ToString()); return(Request.CreateResponse(HttpStatusCode.InternalServerError, mensaje)); } }
public HttpResponseMessage SetStatus(int shipmentId, string status) { try { BOShipments shipment = new BOShipments(); shipments ship = shipment.getOneShipment(shipmentId); ship.status = status; ship = shipment.updateShipments(ship); return(Request.CreateResponse(HttpStatusCode.OK, 1)); } catch (Exception e) { ErrorMessage mensaje = new ErrorMessage("2.1", "Exception to update shipments - " + e.GetBaseException().Message, e.ToString()); return(Request.CreateResponse(HttpStatusCode.InternalServerError, mensaje)); } }
public HttpResponseMessage Put(shipments model) { try { BOShipments shipment = new BOShipments(); shipments ship; ship = shipment.updateShipments(model); return(Request.CreateResponse(HttpStatusCode.OK, ship)); } catch (Exception e) { ErrorMessage mensaje = new ErrorMessage("2.1", "Exception to update shipments - " + e.GetBaseException().Message, e.ToString()); return(Request.CreateResponse(HttpStatusCode.InternalServerError, mensaje)); } }
public shipments getShipmentsByPO(int customerId, string PO) { var shipment = new shipments(); try { using (var ctx = new transshipEntities()) { ctx.Configuration.LazyLoadingEnabled = false; shipment = ctx.shipments.Where(x => x.customerId == customerId && x.purcharse_order == PO).FirstOrDefault(); return(shipment); } } catch (Exception e) { LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty)); throw e; } }
public shipments getOneShipment(int shipmentId) { var shipment = new shipments(); try { using (var ctx = new transshipEntities()) { ctx.Configuration.LazyLoadingEnabled = false; shipment = ctx.shipments.Where(x => x.shipmentId == shipmentId).SingleOrDefault(); return(shipment); } } catch (Exception e) { LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty)); throw e; } }
public shipments updateShipment(shipments model) { shipments shipment = new shipments(); shipment = model; try { using (var ctx = new transshipEntities()) { ctx.Entry(shipment).State = EntityState.Modified; ctx.SaveChanges(); return(shipment); } } catch (Exception e) { LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty)); throw e; } }
public shipments saveShipment(shipments model) { model.tnc_accepted = "N"; model.status = "N"; var shipment = new shipments(); try { using (var ctx = new transshipEntities()) { shipment = ctx.shipments.Add(model); ctx.SaveChanges(); return(shipment); } } catch (Exception e) { LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty)); throw e; } }
public shipments updateShipments(shipments ship) { return(shipment.updateShipment(ship)); }
public shipments saveShipment(shipments ship) { return(shipment.saveShipment(ship)); }