Пример #1
0
        internal static IEnumerable <Expression <Func <Inventory, PickableInventoryItemReturn> > > SplitSelectPickableInventorySummary(IInventoryUnitOfWork inventoryUnitOfWork, DateTime currentDate,
                                                                                                                                       IEnumerable <Expression <Func <Inventory, bool> > > validForPicking, bool includeAllowances)
        {
            if (inventoryUnitOfWork == null)
            {
                throw new ArgumentNullException("inventoryUnitOfWork");
            }

            var selectValidForPicking = validForPicking.Aggregate(PredicateBuilder.True <Inventory>(), (c, n) => c.And(n)).ExpandAll();

            var projectors = SplitSelectInventorySummary(inventoryUnitOfWork, currentDate)
                             .Select(p => p.Merge(Projector <Inventory> .To(n => new PickableInventoryItemReturn {
            })))
                             .ToAppendedList(Projector <Inventory> .To(n => new PickableInventoryItemReturn
            {
                ValidForPicking = selectValidForPicking.Invoke(n)
            }));

            if (includeAllowances)
            {
                var contractAllowance      = LotContractAllowanceProjectors.SelectContractKey();
                var customerOrderAllowance = LotCustomerOrderAllowanceProjectors.SelectCustomerOrderKey();
                var customerAllowance      = LotCustomerAllowanceProjectors.SelectCustomerKey();

                projectors = projectors.ToAppendedList(Projector <Inventory> .To(i => new PickableInventoryItemReturn
                {
                    ContractAllowances      = i.Lot.ContractAllowances.Select(a => contractAllowance.Invoke(a)),
                    CustomerOrderAllowances = i.Lot.SalesOrderAllowances.Select(a => customerOrderAllowance.Invoke(a)),
                    CustomerAllowances      = i.Lot.CustomerAllowances.Select(a => customerAllowance.Invoke(a))
                }));
            }

            return(projectors);
        }
Пример #2
0
        internal static IEnumerable <Expression <Func <Lot, LotQualitySummaryReturn> > > SplitSelectLotQualitySummary(ILotUnitOfWork lotUnitOfWork, DateTime currentDate)
        {
            if (lotUnitOfWork == null)
            {
                throw new ArgumentNullException("lotUnitOfWork");
            }

            var customerAllowance      = LotCustomerAllowanceProjectors.Select();
            var customerOrderAllowance = LotCustomerOrderAllowanceProjectors.Select();
            var contractAllowance      = LotContractAllowanceProjectors.Select();

            return(SplitSelectLotSummary(lotUnitOfWork, currentDate)
                   .Select(e => e.Merge(l => new LotQualitySummaryReturn {
            }).ExpandAll())
                   .ToListWithModifiedElement(0, e => e.Merge(l => new LotQualitySummaryReturn
            {
                ProductSpecComplete = l.ProductSpecComplete,
                ProductSpecOutOfRange = l.ProductSpecOutOfRange,
            }).ExpandAll())
                   .Concat(new[]
            {
                Projector <Lot> .To(l => new LotQualitySummaryReturn
                {
                    CustomerAllowances = l.CustomerAllowances.Select(a => customerAllowance.Invoke(a)),
                    CustomerOrderAllowances = l.SalesOrderAllowances.Select(a => customerOrderAllowance.Invoke(a)),
                    ContractAllowances = l.ContractAllowances.Select(a => contractAllowance.Invoke(a))
                })
            }));
        }