Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public async Task <List <ShipmentResultDtos> > ConvertToResultAsync(List <OrderDetailDTO> input)
        {
            List <ShipmentResultDtos> result = new List <ShipmentResultDtos>();

            foreach (var item in input)
            {
                //map OrderDetailDTO to ShipmentResult
                ShipmentResultDtos output = new ShipmentResultDtos();
                int OrderId = item.OrderId;
                PagedListResult <Order> order = await _orderDataProvider.ListAsync(x => x.Id == OrderId, null, false);

                List <Booking> booking = await _bookingRepository.Query(x => x.ItemNumber == item.ItemNumber, false).SelectAsync();

                List <ProgressCheck> progressCheck = await _progressCheckRepository.Query(x => x.OrderId == order.Items[0].Id, false).SelectAsync();

                //get info from Order
                output.PONumber   = order.Items[0].PONumber;
                output.Vendor     = order.Items[0].Vendor;
                output.POShipDate = order.Items[0].ShipDate;
                //output.POShipDate = progressCheck[0].IntendedShipDate;
                output.DeliveryDate = order.Items[0].DeliveryDate;

                //get info from OrderDetail
                output.ItemNumber        = item.ItemNumber;
                output.Quantity          = item.Quantity;
                output.BookingQuantity   = item.ReviseQuantity;
                output.Status            = item.Status;
                output.StatusDescription = item.Status.GetDescription <OrderStatus>();
                output.OrderId           = item.OrderId;
                output.Cartons           = item.Cartons;
                output.Cube = item.Cube;

                //get info from Booking
                if (booking.Count > 0)
                {
                    output.ShipmentID = booking[0].ShipmentID;
                }

                //add item to result
                result.Add(output);
            }

            return(result.OrderBy(p => p.ShipmentID).ThenBy(p => p.PONumber).ThenBy(p => p.ItemNumber).ToList());
        }