Exemplo n.º 1
0
        public async Task <List <Model.OrderAppointment> > ToListAsync(OrderAppointmentQuery query)
        {
            List <Entities.OrderAppointment> l = new List <OrderAppointment>();

            var transactionOptions = new System.Transactions.TransactionOptions();

            transactionOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted;

            using (var t = new TransactionScope(TransactionScopeOption.Required, transactionOptions, TransactionScopeAsyncFlowOption.Enabled))
            {
                l = await OrderAppointment_BuildQuery(query)
                    .AsNoTracking()
                    .ToListAsync();

                t.Complete();
                t.Dispose();
            }



            var result = l.Select(x => new Model.OrderAppointment
            {
                BillOfLading       = x.BillOfLading,
                BoxesCount         = x.BoxesCount,
                BoxSize            = x.BoxSize,
                ConfirmationNumber = x.ConfirmationNumber,
                CustomerId         = x.CustomerId,
                DivisionId         = x.DivisionId,
                EndDate            = x.EndDate,
                Notes               = x.Notes,
                PickTicketId        = x.PickTicketId,
                Pieces              = x.Pieces,
                PtBulk              = x.PtBulk,
                PurchaseOrderId     = x.PurchaseOrderId,
                ScacCode            = x.ScacCode,
                ShipFor             = x.ShipFor,
                ShipTo              = x.ShipTo,
                Size                = x.Size,
                StartDate           = x.StartDate,
                Status              = x.Status,
                Weigth              = x.Weigth,
                CustomerName        = x.Customer != null ? x.Customer.CompanyName : string.Empty,
                DivisionName        = x.Division != null ? x.Division.Description : string.Empty,
                DeliveryTypeId      = string.IsNullOrEmpty(x.Delivery) ? default(short?) : x.Delivery == "P" ? (short)1 : (short)2,
                Shipping            = GetShippingDescription(x.Shipping),
                PathPOD             = x.PathPOD,
                ExternalBol         = x.ExternalBol,
                ShippingDateChanged = x.ShippingDateChanged,
                MasterBillOfLading  = x.MasterBillOfLading
            });

            return(result.ToList());
        }
 public IList <Model.OrderAppointment> ToList(OrderAppointmentQuery query)
 {
     return(Repository.ToList(query));
 }
 public async Task <IList <Model.OrderAppointment> > ToListAsync(OrderAppointmentQuery query)
 {
     return(await Repository.ToListAsync(query));
 }
Exemplo n.º 4
0
        private IQueryable <GSLogistics.Entities.OrderAppointment> OrderAppointment_BuildQuery(OrderAppointmentQuery query)
        {
            var q = context.OrderAppointments.Where(x => true)
                    .Include("Customer")
                    .Include("Division");

            if (!string.IsNullOrEmpty(query.CustomerId))
            {
                q = q.Where(x => x.CustomerId == query.CustomerId);
            }

            if (query.DivisionId.HasValue && query.DivisionId != 0)
            {
                q = q.Where(x => x.DivisionId == query.DivisionId);
            }

            if (query.CancelDateStartDate.HasValue)
            {
                q = q.Where(x => x.StartDate >= query.CancelDateStartDate.Value);
            }
            if (query.CancelDateEndDate.HasValue)
            {
                q = q.Where(x => x.StartDate <= query.CancelDateEndDate.Value);
            }

            if (query.ShipFor.HasValue)
            {
                q = q.Where(x => x.ShipFor.HasValue && (x.ShipFor.Value.Year == query.ShipFor.Value.Year && x.ShipFor.Value.Month == query.ShipFor.Value.Month && x.ShipFor.Value.Day == query.ShipFor.Value.Day));
            }

            if (query.Status.HasValue)
            {
                q = q.Where(x => x.Status == query.Status);
            }

            if (!string.IsNullOrEmpty(query.PurchaseOrder))
            {
                q = q.Where(x => x.PurchaseOrderId == query.PurchaseOrder);
            }
            if (!string.IsNullOrEmpty(query.BillOfLading))
            {
                q = q.Where(x => x.BillOfLading == query.BillOfLading);
            }
            else if (query.EmptyBol)
            {
                q = q.Where(x => string.IsNullOrEmpty(x.BillOfLading));
            }

            if (!string.IsNullOrEmpty(query.MasterBillOfLading))
            {
                q = q.Where(x => x.MasterBillOfLading == query.MasterBillOfLading);
            }

            if (!string.IsNullOrEmpty(query.PickTicketId))
            {
                q = q.Where(x => x.PickTicketId == query.PickTicketId);
            }

            if (!string.IsNullOrEmpty(query.PtBulk))
            {
                q = q.Where(x => x.PtBulk == query.PtBulk);
            }

            return(q);
        }