public ShipmentTrackingViewModel(ShipmentTracking shipmentTracking)
        {
            if (shipmentTracking == null)
            {
                return;
            }

            //this.ShipmentTrackingID = shipmentTracking.ShipmentTrackingID;
            this.ProductQuoteID   = shipmentTracking.ProductQuoteID;
            this.ProductQuoteCode = shipmentTracking.ProductQuote.ProductQuoteCode;

            //Quoted
            this.QuotedEstimatedDate = shipmentTracking.QuotedEstimatedDate;
            this.QuotedRealDate      = shipmentTracking.QuotedRealDate;
            this.QuotedCompleted     = shipmentTracking.QuotedCompleted;

            //CustomerOrder
            this.CustomerOrderEstimatedDate = shipmentTracking.CustomerOrderEstimatedDate;
            this.CustomerOrderRealDate      = shipmentTracking.CustomerOrderRealDate;
            this.CustomerOrderCompleted     = shipmentTracking.CustomerOrderCompleted;

            //Approved
            this.ApprovedEstimatedDate = shipmentTracking.ApprovedEstimatedDate;
            this.ApprovedRealDate      = shipmentTracking.ApprovedRealDate;
            this.ApprovedCompleted     = shipmentTracking.ApprovedCompleted;

            //InProduction
            this.InProductionEstimatedDate = shipmentTracking.InProductionEstimatedDate;
            this.InProductionRealDate      = shipmentTracking.InProductionRealDate;
            this.InProductionCompleted     = shipmentTracking.InProductionCompleted;

            //EstimatedTimeOfDeparture
            this.ETDEstimatedDate = shipmentTracking.ETDEstimatedDate;
            this.ETDRealDate      = shipmentTracking.ETDRealDate;
            this.ETDCompleted     = shipmentTracking.ETDCompleted;

            //EstimatedTimeOfArrival
            this.ETAEstimatedDate = shipmentTracking.ETAEstimatedDate;
            this.ETARealDate      = shipmentTracking.ETARealDate;
            this.ETACompleted     = shipmentTracking.ETACompleted;

            //Nationalized
            this.NationalizedEstimatedDate = shipmentTracking.NationalizedEstimatedDate;
            this.NationalizedRealDate      = shipmentTracking.NationalizedRealDate;
            this.NationalizedCompleted     = shipmentTracking.NationalizedCompleted;

            //Delivered
            this.DeliveredEstimatedDate = shipmentTracking.DeliveredEstimatedDate;
            this.DeliveredRealDate      = shipmentTracking.DeliveredRealDate;
            this.DeliveredCompleted     = shipmentTracking.DeliveredCompleted;


            this.InProductionEnabled = shipmentTracking.InProductionEnabled;
            this.ETDEnabled          = shipmentTracking.ETDEnabled;
            this.ETAEnabled          = shipmentTracking.ETAEnabled;
            this.NationalizedEnabled = shipmentTracking.NationalizedEnabled;
        }
Beispiel #2
0
        public async Task <ActionResult> Edit(int pq, int customerID, [Bind(Include = "ProductQuoteID, QuotedEstimatedDate, QuotedRealDate, QuotedCompleted, CustomerOrderEstimatedDate, CustomerOrderRealDate, CustomerOrderCompleted, ApprovedEstimatedDate, ApprovedRealDate, ApprovedCompleted, InProductionEstimatedDate, InProductionRealDate, InProductionCompleted, ETDEstimatedDate, ETDRealDate, ETDCompleted, ETAEstimatedDate, ETARealDate, ETACompleted, NationalizedEstimatedDate, NationalizedRealDate, NationalizedCompleted, DeliveredEstimatedDate, DeliveredRealDate, DeliveredCompleted, InProductionEnabled, ETDEnabled, ETAEnabled, NationalizedEnabled, DeliveredEnabled")] ShipmentTracking shipmentTracking)
        {
            if (ModelState.IsValid)
            {
                await shipmentTrackingRepository.UpdateAsync(shipmentTracking);

                return(RedirectToAction("../ProductQuote", new { pq = pq, customerID = customerID }));
            }

            return(View(shipmentTracking));
        }
Beispiel #3
0
        public ActionResult Edit(int pq, int customerID, int id)
        {
            ShipmentTracking shipmentTracking = shipmentTrackingRepository.FindShipmentTrackingByProductQuoteID(id);

            ViewBag.Pq         = pq;
            ViewBag.CustomerID = customerID;

            if (shipmentTracking == null)
            {
                return(HttpNotFound());
            }

            return(View(shipmentTracking));
        }
Beispiel #4
0
        public void When_ApprovedRealDate_LessThan_CustomerOrderRealDate_And_ApprovedRealDateNotNull_Then_ThrowValidationError()
        {
            // Arrange
            ShipmentTracking shipmentTracking = new ShipmentTracking
            {
                ApprovedRealDate      = DateTime.Now.AddDays(-1),
                CustomerOrderRealDate = DateTime.Now
            };

            // Act
            ValidationResult result = ShipmentTrackingRules.ValidateShipmentTracking(shipmentTracking, null);

            // Assert
            Assert.AreEqual("La Fecha Real de 'Aprobado' no puede ser menor a la Fecha Real de la la Etapa anterior", result.ErrorMessage);
        }
Beispiel #5
0
        public void When_ApprovedCompleted_And_NotCustomerOrderCompleted_Then_ThrowValidationError()
        {
            // Arrange
            ShipmentTracking shipmentTracking = new ShipmentTracking
            {
                ApprovedCompleted      = true,
                CustomerOrderCompleted = false
            };

            // Act
            ValidationResult result = ShipmentTrackingRules.ValidateShipmentTracking(shipmentTracking, null);

            // Assert
            Assert.AreEqual("La Etapa 'Aprobado' no puede estar completada si aun no está completada la Etapa anterior", result.ErrorMessage);
        }
Beispiel #6
0
        public void When_InProductionEnabled_And_InProductionRealDateNotNull_And_ApprovedRealDateIsNll_Then_ThrowValidationError()
        {
            // Arrange
            ShipmentTracking shipmentTracking = new ShipmentTracking
            {
                InProductionEnabled  = true,
                InProductionRealDate = DateTime.Now,
                ApprovedRealDate     = null
            };

            // Act
            ValidationResult result = ShipmentTrackingRules.ValidateShipmentTracking(shipmentTracking, null);

            // Assert
            Assert.AreEqual("La Fecha Real de 'En Px' no puede ser menor a la Fecha Real de la Etapa anterior", result.ErrorMessage);
        }
Beispiel #7
0
        public void When_DeliveredEstimatedDate_LessThan_InProductionEstimatedDate_And_InProductionEnabled_Then_ThrowValidationError()
        {
            // Arrange
            ShipmentTracking shipmentTracking = new ShipmentTracking
            {
                DeliveredEstimatedDate    = DateTime.Now.AddDays(-1),
                InProductionEstimatedDate = DateTime.Now,
                InProductionEnabled       = true
            };

            // Act
            ValidationResult result = ShipmentTrackingRules.ValidateShipmentTracking(shipmentTracking, null);

            // Assert
            Assert.AreEqual("La Fecha Estimada de 'Entregado' no puede ser menor a la Fecha Estimada de la Etapa anterior", result.ErrorMessage);
        }
Beispiel #8
0
        public void When_ETAEnabled_And_ETAEstimatedDate_LessThan_ApprovedEstimatedDate_Then_ThrowValidationError()
        {
            // Arrange
            ShipmentTracking shipmentTracking = new ShipmentTracking
            {
                ETAEnabled            = true,
                ETAEstimatedDate      = DateTime.Now.AddDays(-1),
                ApprovedEstimatedDate = DateTime.Now
            };

            // Act
            ValidationResult result = ShipmentTrackingRules.ValidateShipmentTracking(shipmentTracking, null);

            // Assert
            Assert.AreEqual("La Fecha Estimada de 'Puerto ETA' no puede ser menor a la Fecha Estimada de la Etapa anterior", result.ErrorMessage);
        }
Beispiel #9
0
        public void When_InProductionEnabled_And_InProductionCompleted_And_NotApprovedCompleted_Then_ThrowValidationError()
        {
            // Arrange
            ShipmentTracking shipmentTracking = new ShipmentTracking
            {
                InProductionEnabled   = true,
                InProductionCompleted = true,
                ApprovedCompleted     = false
            };

            // Act
            ValidationResult result = ShipmentTrackingRules.ValidateShipmentTracking(shipmentTracking, null);

            // Assert
            Assert.AreEqual("La Etapa 'En Px' no puede estar completada si aun no está completada la Etapa anterior", result.ErrorMessage);
        }
Beispiel #10
0
        public void When_DeliveredCompleted_And_ETDEnabled_And_NotETDCompleted_Then_ThrowValidationError()
        {
            // Arrange
            ShipmentTracking shipmentTracking = new ShipmentTracking
            {
                DeliveredCompleted = true,
                ETDEnabled         = true,
                ETDCompleted       = false
            };

            // Act
            ValidationResult result = ShipmentTrackingRules.ValidateShipmentTracking(shipmentTracking, null);

            // Assert
            Assert.AreEqual("La Etapa 'Entregado' no puede estar completada si aun no está completada la Etapa anterior", result.ErrorMessage);
        }
Beispiel #11
0
        public void When_NationalizedEnabled_And_NationalizedEstimatedDate_LessThan_ETDEstimatedDate_And_ETDEnabled_Then_ThrowValidationError()
        {
            // Arrange
            ShipmentTracking shipmentTracking = new ShipmentTracking
            {
                NationalizedEnabled       = true,
                NationalizedEstimatedDate = DateTime.Now.AddDays(-1),
                ETDEstimatedDate          = DateTime.Now,
                ETDEnabled = true
            };

            // Act
            ValidationResult result = ShipmentTrackingRules.ValidateShipmentTracking(shipmentTracking, null);

            // Assert
            Assert.AreEqual("La Fecha Estimada de 'Nacionalizado' no puede ser menor a la Fecha Estimada de la Etapa anterior", result.ErrorMessage);
        }
Beispiel #12
0
        public void When_ETDEnabled_And_ETDRealDateNotNull_And_InProductionRealDate_LessThan_ApprovedRealDate_And_InProductionEnabled_And_ETDRealDate_GreatherThan_InProductionRealDate_Then_ThrowValidationError()
        {
            // Arrange
            ShipmentTracking shipmentTracking = new ShipmentTracking
            {
                ETDEnabled           = true,
                ETDRealDate          = DateTime.Now,
                ApprovedRealDate     = DateTime.Now,
                InProductionRealDate = DateTime.Now.AddDays(-1),
                InProductionEnabled  = true
            };

            // Act
            ValidationResult result = ShipmentTrackingRules.ValidateShipmentTracking(shipmentTracking, null);

            // Assert
            Assert.AreEqual("La Fecha Real de 'Embarcado ETD' no puede ser menor a la Fecha Real de la Etapa anterior", result.ErrorMessage);
        }
Beispiel #13
0
        public ActionResult Approve(int pq, int customerID, int productQuoteID)
        {
            ViewBag.Pq         = pq;
            ViewBag.CustomerID = customerID;

            if ((productQuoteID == 0) || (productQuoteID.ToString().Length == 0))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            customerOrderRepository.Approve(productQuoteID);

            ShipmentTracking shipmentTracking = shipmentTrackingRepository.FindShipmentTrackingByProductQuoteID(productQuoteID);

            shipmentTracking.ApprovedRealDate      = DateTime.Now;
            shipmentTracking.ApprovedEstimatedDate = DateTime.Now;
            shipmentTracking.ApprovedCompleted     = true;

            shipmentTrackingRepository.Update(shipmentTracking);

            return(RedirectToAction("../ProductQuote", new { pq = ViewBag.Pq, customerID = ViewBag.CustomerID }));
        }
Beispiel #14
0
        public async Task <ActionResult> Create(int pq, int customerID, [Bind(Include = "ProductQuoteID,DateOrder")] CustomerOrder customerOrder)
        {
            ViewBag.Pq         = pq;
            ViewBag.CustomerID = customerID;

            if (ModelState.IsValid)
            {
                if (!IsValidProductQuote(customerOrder.ProductQuoteID))
                {
                    ModelState.AddModelError("", "La Cotización esta fuera de término");
                    return(View(customerOrder));
                }

                await customerOrderRepository.CreateAsync(customerOrder);

                ShipmentTracking shipmentTracking = shipmentTrackingRepository.FindShipmentTrackingByProductQuoteID(customerOrder.ProductQuoteID);

                shipmentTracking.CustomerOrderEstimatedDate = customerOrder.DateOrder;
                shipmentTracking.CustomerOrderRealDate      = customerOrder.DateOrder;
                shipmentTracking.CustomerOrderCompleted     = true;

                //Si no es un usuario Cliente, se crea la OC directamente como APROBADA
                if (User.IsInRole("SellerUser"))
                {
                    shipmentTracking.ApprovedEstimatedDate = customerOrder.DateOrder;
                    shipmentTracking.ApprovedRealDate      = customerOrder.DateOrder;
                    shipmentTracking.ApprovedCompleted     = true;
                }

                await shipmentTrackingRepository.UpdateAsync(shipmentTracking);


                return(RedirectToAction("../ProductQuote", new { pq = ViewBag.Pq, customerID = ViewBag.CustomerID }));
            }

            return(View(customerOrder));
        }
        public String GetShipmentTracking(int Id)
        {
            ShipmentTracking result = shipmentTrackingRepository.FindShipmentTrackingByProductQuoteID(Id);

            return(JsonConvert.SerializeObject(new ShipmentTrackingViewModel(result)));
        }