コード例 #1
0
        public IResult <IInventoryTransactionsByLotReturn> GetLotInputTransactions(string lotKey)
        {
            var lotKeyResult = KeyParserHelper.ParseResult <ILotKey>(lotKey);

            if (!lotKeyResult.Success)
            {
                return(lotKeyResult.ConvertTo <IInventoryTransactionsByLotReturn>());
            }
            var parsedLotKey = lotKeyResult.ResultingObject.ToLotKey();

            var product = _inventoryUnitOfWork.LotRepository.FilterByKey(parsedLotKey)
                          .Select(LotProjectors.SelectDerivedProduct())
                          .FirstOrDefault();

            var predicate = InventoryTransactionPredicates.ByDestinationLot(parsedLotKey);
            var select    = InventoryTransactionProjectors.Select(_inventoryUnitOfWork);

            var query = _inventoryUnitOfWork.InventoryTransactionsRepository.Filter(predicate).Select(select).ToList();

            var batchPredicate = ProductionBatchPredicates.ByLotKey(parsedLotKey);
            var pickedSelect   = PickedInventoryItemProjectors.SelectTransaction(_inventoryUnitOfWork);
            var pickedResults  = _inventoryUnitOfWork.ProductionBatchRepository
                                 .Filter(batchPredicate.And(b => new[] { b.Production.Results }.All(r => r == null)))
                                 .AsExpandable()
                                 .SelectMany(b => b.Production.PickedInventory.Items.Select(i => pickedSelect.Invoke(i, b)));

            var results = query.ToList <IInventoryTransactionReturn>().Concat(pickedResults).AsQueryable();

            return(new SuccessResult <IInventoryTransactionsByLotReturn>(new InventoryTransactionsByLotReturn
            {
                Product = product,
                InputItems = results
            }));
        }
コード例 #2
0
        public IResult <IQueryable <IInventoryTransactionReturn> > GetInventoryTransactions(string lotKey)
        {
            var lotKeyResult = KeyParserHelper.ParseResult <ILotKey>(lotKey);

            if (!lotKeyResult.Success)
            {
                return(lotKeyResult.ConvertTo <IQueryable <IInventoryTransactionReturn> >());
            }
            var parsedLotKey = lotKeyResult.ResultingObject.ToLotKey();

            var predicate = InventoryTransactionPredicates.BySourceLot(parsedLotKey);
            var select    = InventoryTransactionProjectors.Select(_inventoryUnitOfWork);

            var query = _inventoryUnitOfWork.InventoryTransactionsRepository.Filter(predicate).Select(select);

            var pickedPredicate = PickedInventoryItemPredicates.FilterByLotKey(parsedLotKey);
            var pickedSelect    = PickedInventoryItemProjectors.SelectTransaction(_inventoryUnitOfWork);
            var pickedResults   = _inventoryUnitOfWork.ProductionBatchRepository
                                  .Filter(b => new[] { b.Production.Results }.All(r => r == null))
                                  .AsExpandable()
                                  .SelectMany(b => b.Production.PickedInventory.Items
                                              .Where(i => pickedPredicate.Invoke(i))
                                              .Select(i => pickedSelect.Invoke(i, b)));

            var results = query.ToList <IInventoryTransactionReturn>().Concat(pickedResults).AsQueryable();

            return(new SuccessResult <IQueryable <IInventoryTransactionReturn> >(results));
        }