예제 #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);
        }
예제 #2
0
        public async Task <List <ShipmentBookingDtos> > CreateOrUpdateBookingAsync(ShipmentBookingDtos booking)
        {
            List <Booking> result = new List <Booking>();

            List <ShipmentBookingDtos> bookings = ConvertToBookingList(booking);

            PagedListResult <Booking> bookingDb = await _bookingDataProvider.ListAsync();

            foreach (var item in bookings)
            {
                Booking entity = new Booking();
                if (item.Status == OrderStatus.BookingMade)
                {
                    foreach (var detail in bookingDb.Items)
                    {
                        if (detail.ItemNumber == item.ItemNumber)
                        {
                            entity = detail;
                            break;
                        }
                    }

                    item.Id = entity.Id;
                    var temp = entity.RowVersion;
                    entity            = Mapper.Map(item, entity);
                    entity.RowVersion = temp;

                    _bookingRepository.Update(entity);
                    result.Add(entity);
                }
                else
                {
                    item.Status = OrderStatus.BookingMade;
                    entity      = Mapper.Map <Booking>(item);

                    result.Add(entity);
                    _bookingRepository.Insert(entity);
                }
            }

            //await UnitOfWork.SaveChangesAsync();

            var rs = Mapper.Map <List <ShipmentBookingDtos> >(result);

            return(rs);
        }