public async Task <List <ConfirmArrivalResultDtos> > ConvertToResultAsync(List <Container> containers)
        {
            List <ConfirmArrivalResultDtos> result = new List <ConfirmArrivalResultDtos>();

            foreach (var item in containers)
            {
                ConfirmArrivalResultDtos output = new ConfirmArrivalResultDtos();
                Booking booking = await _bookingDataProvider.GetByIdAsync((item.Manifests.ToList())[0].BookingId);

                Order order = await _orderDataProvider.GetByIdAsync(booking.OrderId);

                List <CA> confirmArrival = await _confirmArrivalRepository.Query(x => x.ContainerId == item.Id, false).SelectAsync();

                List <ArriveOfDespatch> arriveOfDespatch = await _arriveOfDespatchRepository.Query(x => x.ContainerId == item.Id, false).SelectAsync();

                //output.DestinationPort = booking.PortOfDelivery;
                output.DestinationPort = arriveOfDespatch[0].DestinationPort;
                output.Origin          = order.Origin;
                output.Mode            = item.Loading;
                //output.Carrier = booking.Carrier;
                output.Carrier = arriveOfDespatch[0].Carrier;
                output.ETD     = booking.ETD;

                output.Vendor    = order.Vendor;
                output.Container = item.Name;
                output.Status    = item.Status;

                if (output.Status == ContainerStatus.Despatch)
                {
                    output.ArrivalDate = booking.ETA;
                }
                else
                {
                    output.ArrivalDate = confirmArrival[0].ArrivalDate;
                }

                output.Id = item.Id;

                var test = typeof(ConfirmArrivalResultDtos).GetProperties()[0].GetValue(output);


                result.Add(output);
            }

            result = result.OrderBy(p => p.DestinationPort).ThenBy(p => p.Origin).ThenBy(p => p.Mode).ThenBy(p => p.Carrier).ThenBy(p => p.ArrivalDate).ThenBy(p => p.Container).ToList();

            return(result);
        }
        public async Task <PagedListResult <DCBookingDtos> > ListDCBookingDtosAsync(int pageIndex = 1, int pageSize = 10, string DestinationPort = null, string bookingref = null, DateTime?bookingdatefrom = null, DateTime?bookingdateto = null, string DC = null, DateTime?arrivaldatefrom = null, DateTime?arrivaldateto = null, string Status = null, string Container = null)
        {
            PagedListResult <DCBookingDtos>      pagedListResult = new PagedListResult <DCBookingDtos>();
            Expression <Func <Container, bool> > All             = c => c.Id > 0;
            Expression <Func <Container, bool> > filter1         = x => x.Status != ContainerStatus.Delivered;

            All = All.And(filter1);
            if (DestinationPort != null)
            {
                Expression <Func <Container, bool> > filter = x => x.ArriveOfDespatch.DestinationPort == DestinationPort;
                All = All.And(filter);
            }
            if (DC != null)
            {
                Expression <Func <Container, bool> > filter = x => x.DCBooking.DistributionCenter == DC;
                All = All.And(filter);
            }
            if (bookingref != null)
            {
                Expression <Func <Container, bool> > filter = x => x.DCBooking.BookingRef == bookingref;
                All = All.And(filter);
            }
            if (bookingdatefrom != null)
            {
                Expression <Func <Container, bool> > filter = x => x.DCBooking.BookingDate.CompareTo(bookingdatefrom) > 0;
                All = All.And(filter);
            }
            if (bookingdateto != null)
            {
                Expression <Func <Container, bool> > filter = x => x.DCBooking.BookingDate.CompareTo(bookingdateto) < 0;
                All = All.And(filter);
            }
            if (arrivaldatefrom != null)
            {
                Expression <Func <Container, bool> > filter = x => x.CA.ArrivalDate.CompareTo(arrivaldatefrom) > 0;
                All = All.And(filter);
            }
            if (arrivaldateto != null)
            {
                Expression <Func <Container, bool> > filter = x => x.CA.ArrivalDate.CompareTo(arrivaldateto) < 0;
                All = All.And(filter);
            }
            if (Status != null)
            {
                Expression <Func <Container, bool> > filter = x => x.Status.GetDescription <ContainerStatus>() == Status;
                All = All.And(filter);
            }
            if (Container != null)
            {
                Expression <Func <Container, bool> > filter = x => x.Name.Contains(Container);
                All = All.And(filter);
            }
            var listContainer = await _containerDataProvider.ListAsync(All, "Status", true, pageIndex, pageSize);

            List <Container>     containers    = listContainer.Items;
            List <DCBookingDtos> dCBookingDtos = new List <DCBookingDtos>();

            foreach (var container in containers)
            {
                var confirmArrival = await _confirmArrivalRepository.Query(x => x.ContainerId == container.Id, false).SelectAsync();

                var arriveOfDispatch = await _arriveOfDespatchRepository.Query(x => x.ContainerId == container.Id, false).SelectAsync();

                var dcBooking = await _dcBookingRepository.Query(x => x.ContainerId == container.Id, false).SelectAsync();

                if (confirmArrival.Count() > 0 && arriveOfDispatch.Count() > 0)
                {
                    DCBookingDtos dCBookingDto = new DCBookingDtos()
                    {
                        ContainerId = container.Id,
                        Name        = container.Name,
                        DestPort    = arriveOfDispatch[0].DestinationPort,
                        ArrivalDate = confirmArrival[0].ArrivalDate,
                        Status      = container.Status.GetDescription <ContainerStatus>(),
                        BookingDate = confirmArrival[0].ArrivalDate.AddDays(1)
                    };
                    foreach (var manifest in container.Manifests)
                    {
                        dCBookingDto.ShipCarton   += manifest.Quantity * (decimal)manifest.Cartons;
                        dCBookingDto.ShipCube     += manifest.Quantity * (decimal)manifest.Cube;
                        dCBookingDto.ShipQuantity += manifest.Quantity;
                    }
                    if (dcBooking.Count > 0)
                    {
                        dCBookingDto.Id = dcBooking[0].Id;
                        dCBookingDto.DistributionCenter = dcBooking[0].DistributionCenter;
                        dCBookingDto.Haulier            = dcBooking[0].Haulier;
                        dCBookingDto.Client             = dcBooking[0].Client;
                        dCBookingDto.BookingDate        = dcBooking[0].BookingDate;
                        dCBookingDto.BookingRef         = dcBooking[0].BookingRef;
                        dCBookingDto.BookingTime        = dcBooking[0].BookingTime;
                    }
                    dCBookingDtos.Add(dCBookingDto);
                }
            }
            pagedListResult.Items      = dCBookingDtos.OrderBy(p => p.Status).ThenBy(x => x.Container).ToList();
            pagedListResult.TotalCount = listContainer.TotalCount;
            pagedListResult.PageCount  = listContainer.PageCount;
            return(pagedListResult);
        }