Exemple #1
0
        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);
        }
Exemple #2
0
        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));
            }
        }
Exemple #3
0
        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));
            }
        }
Exemple #4
0
 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));
     }
 }
Exemple #5
0
        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));
            }
        }
Exemple #6
0
        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;
            }
        }
Exemple #7
0
        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;
            }
        }
Exemple #8
0
        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;
            }
        }
Exemple #9
0
        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;
            }
        }
Exemple #10
0
 public shipments updateShipments(shipments ship)
 {
     return(shipment.updateShipment(ship));
 }
Exemple #11
0
 public shipments saveShipment(shipments ship)
 {
     return(shipment.saveShipment(ship));
 }