Esempio n. 1
0
        internal static IEnumerable <Expression <Func <ProductionBatch, ProductionBatchDetailReturn> > > SplitSelectDetail(Data.Interfaces.UnitsOfWork.IProductionUnitOfWork productionUnitOfWork, DateTime currentDate)
        {
            if (productionUnitOfWork == null)
            {
                throw new ArgumentNullException("productionUnitOfWork");
            }

            var packScheduleKey      = PackScheduleProjectors.SelectKey();
            var productKey           = ProductProjectors.SelectProductKey();
            var chileProduct         = ProductProjectors.SelectChileProductWithIngredients();
            var workType             = WorkTypeProjectors.Select();
            var notebook             = NotebookProjectors.Select();
            var pickedChile          = PickedInventoryProjectors.SelectPickedChileInventoryItem(productionUnitOfWork);
            var pickedPackaging      = PickedInventoryProjectors.SelectPickedPackagingInventoryItem(productionUnitOfWork);
            var pickedAdditve        = PickedInventoryProjectors.SelectPickedAdditiveInventoryItem(productionUnitOfWork);
            var pickedItemProjectors = PickedInventoryItemProjectors.SplitSelect(productionUnitOfWork, currentDate);

            return(new[]
            {
                SelectSummary().Merge(b => new ProductionBatchDetailReturn
                {
                    HasProductionBeenCompleted = b.ProductionHasBeenCompleted,
                }).ExpandAll(),
                Projector <ProductionBatch> .To(b => new ProductionBatchDetailReturn
                {
                    PackScheduleKeyReturn = packScheduleKey.Invoke(b.PackSchedule),
                    ChileProductKeyReturn = productKey.Invoke(b.Production.ResultingChileLot.ChileProduct.Product),
                    ChileProductName = b.Production.ResultingChileLot.ChileProduct.Product.Name,
                    ChileProductWithIngredients = chileProduct.Invoke(b.Production.ResultingChileLot.ChileProduct)
                }),
                Projector <ProductionBatch> .To(b => new ProductionBatchDetailReturn
                {
                    WorkType = workType.Invoke(b.PackSchedule.WorkType),
                    InstructionsNotebook = notebook.Invoke(b.InstructionNotebook)
                }),
                Projector <ProductionBatch> .To(b => new ProductionBatchDetailReturn
                {
                    PickedChileItems = pickedChile.Invoke(b.Production.PickedInventory),
                    PickedPackagingItems = pickedPackaging.Invoke(b.Production.PickedInventory),
                    PickedAdditiveItems = pickedAdditve.Invoke(b.Production.PickedInventory)
                })
            }.ToAppendedList(pickedItemProjectors.Select(p => Projector <ProductionBatch> .To(b => new ProductionBatchDetailReturn
            {
                PickedInventoryItems = b.Production.PickedInventory.Items.Select(i => p.Invoke(i))
            }))));
        }