Ejemplo n.º 1
0
        public void CheckForTopLoadLimit()
        {
            //Arrange
            Slot slot = new Slot(0, 0); //write high value to height limit because we assert the top load value in this function.
            ISeaContainer sContainer1 = new SeaContainer(_defaultWeight, ContainerType.Standard);
            ISeaContainer sContainer2 = new SeaContainer(_defaultWeight, ContainerType.Standard);
            ISeaContainer sContainer3 = new SeaContainer(_defaultWeight, ContainerType.Standard);
            ISeaContainer sContainer4 = new SeaContainer(_defaultWeight, ContainerType.Standard);
            ISeaContainer sContainer5 = new SeaContainer(_defaultWeight, ContainerType.Standard);
            ISeaContainer sContainer6 = new SeaContainer(_defaultWeight, ContainerType.Standard);



            //Act
            slot.PlaceAtBottom(sContainer1);
            slot.PlaceAtBottom(sContainer2);
            slot.PlaceAtBottom(sContainer3);
            slot.PlaceAtBottom(sContainer4);

            //Assert
            Assert.Multiple(() =>
            {
                Assert.IsTrue(slot.CanBePlacedAtBottom(sContainer5));
                slot.PlaceAtBottom(sContainer5);
                Assert.IsFalse(slot.CanBePlacedAtBottom(sContainer6));
            });

        }
Ejemplo n.º 2
0
 public SeaContainer UpdateObject(SeaContainer seacontainer)
 {
     if (!isValid(_validator.VUpdateObject(seacontainer, this)))
     {
         seacontainer = _repository.UpdateObject(seacontainer);
     }
     return(seacontainer);
 }
Ejemplo n.º 3
0
 public SeaContainer CreateObject(SeaContainer seacontainer)
 {
     seacontainer.Errors = new Dictionary <String, String>();
     if (!isValid(_validator.VCreateObject(seacontainer, this)))
     {
         seacontainer = _repository.CreateObject(seacontainer);
     }
     return(seacontainer);
 }
Ejemplo n.º 4
0
        public SeaContainer UpdateContainerInfo(SeaContainer seacontainer, IShipmentOrderService _shipmentorderService)
        {
            ShipmentOrder shipment = _shipmentorderService.GetObjectById(seacontainer.ShipmentOrderId);

            if (shipment != null)
            {
                if (shipment.SubJobNumber > 0)
                {
                    IList <ShipmentOrder> shipmentList = _shipmentorderService.GetQueryable().Where(x => x.JobId == shipment.JobId &&
                                                                                                    x.OfficeId == shipment.OfficeId && x.JobNumber == shipment.JobNumber).ToList();
                    ShipmentOrder        mainshipment = shipmentList.Where(x => x.SubJobNumber == 0).FirstOrDefault();
                    IList <SeaContainer> containerListMainShipment = GetQueryable().Where(x => x.ShipmentOrderId == mainshipment.Id).ToList();

                    foreach (var clms in containerListMainShipment)
                    {
                        decimal cbm         = 0;
                        decimal grossWeight = 0;
                        decimal netWeight   = 0;

                        // Get Total CBM, GrossWeight, NetWeight
                        foreach (var item in shipmentList)
                        {
                            if (item.SubJobNumber > 0)
                            {
                                var container = GetQueryable().Where(x => x.ShipmentOrderId == item.Id && x.ContainerNo == clms.ContainerNo).FirstOrDefault();
                                if (container != null)
                                {
                                    var subContainer = GetObjectById(container.Id);
                                    cbm         += subContainer.CBM.HasValue ? subContainer.CBM.Value : 0;
                                    netWeight   += subContainer.NetWeight.HasValue ? subContainer.NetWeight.Value : 0;
                                    grossWeight += subContainer.GrossWeight.HasValue ? subContainer.GrossWeight.Value : 0;
                                }
                            }
                        }

                        // Update Main Container
                        var mainContainer = GetObjectById(clms.Id);
                        if (mainContainer != null)
                        {
                            mainContainer.CBM         = cbm;
                            mainContainer.NetWeight   = netWeight;
                            mainContainer.GrossWeight = grossWeight;

                            UpdateObject(mainContainer);
                        }
                    }
                }
            }
            return(seacontainer);
        }
Ejemplo n.º 5
0
        public SeaContainer CreateUpdateObject(SeaContainer seacontainer)
        {
            SeaContainer newseacontainer = this.GetObjectByShipmentOrderId(seacontainer.ShipmentOrderId);

            if (newseacontainer == null)
            {
                seacontainer = this.CreateObject(seacontainer);
            }
            else
            {
                seacontainer = this.UpdateObject(seacontainer);
            }
            return(seacontainer);
        }
Ejemplo n.º 6
0
        public void CoolContainerOnlyInFrontRow()
        {
            //Arrange
            ISeaContainer        coolContainer = new SeaContainer(_containerWeight, ContainerType.Cool);
            Ship                 ship          = new Ship(1, 2);
            List <ISeaContainer> containers    = new List <ISeaContainer>()
            {
                new SeaContainer(_containerWeight, ContainerType.Standard),
                new SeaContainer(_containerWeight, ContainerType.Standard),
                new SeaContainer(_containerWeight, ContainerType.Standard),
                new SeaContainer(_containerWeight, ContainerType.Standard),
                new SeaContainer(_containerWeight, ContainerType.Standard),
                coolContainer
            };

            //Act
            ship.Load(containers);
            ISlot slotContainingCoolContainer = ship.Layout.First(slot => slot.SeaContainers.Any(c => c.Type == ContainerType.Cool));

            //Assert
            Assert.IsTrue(slotContainingCoolContainer.YPosition == 0);
        }
Ejemplo n.º 7
0
        public bool isValid(SeaContainer obj)
        {
            bool isValid = !obj.Errors.Any();

            return(isValid);
        }
Ejemplo n.º 8
0
 public SeaContainer VUpdateObject(SeaContainer seacontainer, ISeaContainerService _seacontainerService)
 {
     return(seacontainer);
 }
Ejemplo n.º 9
0
 public SeaContainer SoftDeleteObject(SeaContainer seacontainer)
 {
     seacontainer = _repository.SoftDeleteObject(seacontainer);
     return(seacontainer);
 }