Example #1
0
        public async Task <ShipmentManifestsDtos> CreateOrUpdateContainerAsync(ShipmentManifestsDtos rq)
        {
            Container container = new Container();

            container.Name     = rq.Name;
            container.Size     = rq.Size;
            container.Loading  = rq.Loading;
            container.PackType = rq.PackType;
            container.Status   = ContainerStatus.Pending;
            List <Manifest> manifests = new List <Manifest>();

            foreach (var item in rq.Manifests)
            {
                Manifest entity = new Manifest();
                if (item.selectedItem == true)
                {
                    var orderDeatail = await _orderDetailRepository.Query(p => p.ItemNumber == item.ItemNumber, false).SelectAsync();

                    var booking = await _shipmentBookingRepository.Query(p => p.Id == item.BookingId, false).SelectAsync();

                    entity.Quantity     = item.ShipQuantity;
                    entity.Container    = container;
                    entity.Loading      = container.Loading;
                    entity.PackType     = container.PackType;
                    entity.Size         = container.Size;
                    entity.BookingId    = item.BookingId;
                    entity.Cartons      = orderDeatail[0].Cartons;
                    entity.Cube         = orderDeatail[0].Cube;
                    entity.FreightTerms = item.FreightTerms;
                    entity.KGS          = orderDeatail[0].KGS;
                    if (item.ShipQuantity == item.OpenQuantity)
                    {
                        booking[0].Status      = OrderStatus.Manifested;
                        orderDeatail[0].Status = OrderStatus.Manifested;
                    }
                    if (item.ShipQuantity > 0 && item.ShipQuantity < item.OpenQuantity)
                    {
                        booking[0].Status      = OrderStatus.PartlyManifested;
                        orderDeatail[0].Status = OrderStatus.PartlyManifested;
                    }
                    entity.Booking = booking[0];

                    manifests.Add(entity);
                    _orderDetailRepository.Update(orderDeatail[0]);
                    _shipmentBookingRepository.Update(booking[0]);
                }
            }
            if (manifests.Count > 0)
            {
                container.Manifests = manifests;
                _containerRepository.Insert(container);
            }
            await UnitOfWork.SaveChangesAsync();

            var rs = Mapper.Map <ShipmentManifestsDtos>(container);

            return(rs);
        }
Example #2
0
 public bool Insert(string ContainerNumber, int OwnerId, int SSLineId, double TareWeight, double GrossMaxWeight, int ContainerSizeId, string StressLevel,
                    int YardLocationId)
 {
     return(repository.Insert(ContainerNumber, OwnerId, SSLineId, TareWeight, GrossMaxWeight, ContainerSizeId, StressLevel,
                              YardLocationId));
 }