internal IResult <PickableInventoryReturn> Execute(InventoryPredicateBuilder.PredicateBuilderFilters filters, DateTime currentDate, IInventoryValidator validator, bool includeAllowances) { var splitProjectors = InventoryProjectors.SplitSelectPickableInventorySummary(_inventoryUnitOfWork, currentDate, validator.ValidForPickingPredicates, includeAllowances); var predicateResult = InventoryPredicateBuilder.BuildPredicate(_inventoryUnitOfWork, filters, validator.InventoryFilters); if (!predicateResult.Success) { return(predicateResult.ConvertTo <PickableInventoryReturn>()); } return(new SuccessResult <PickableInventoryReturn>(new PickableInventoryReturn { Items = _inventoryUnitOfWork.InventoryRepository .Filter(predicateResult.ResultingObject) .SplitSelect(splitProjectors) })); }
internal IResult <IInventoryReturn> Execute(InventoryPredicateBuilder.PredicateBuilderFilters filters, DateTime currentDate) { var predicateResult = InventoryPredicateBuilder.BuildPredicate(_inventoryUnitOfWork, filters); if (!predicateResult.Success) { return(predicateResult.ConvertTo <IInventoryReturn>()); } var attributes = AttributeNameProjectors.SelectActiveAttributeNames(_inventoryUnitOfWork); var inventory = _inventoryUnitOfWork.InventoryRepository .Filter(predicateResult.ResultingObject) .SplitSelect(InventoryProjectors.SplitSelectInventorySummary(_inventoryUnitOfWork, currentDate)); var inventoryReturn = new InventoryReturn { AttributeNamesAndTypes = attributes.ExpandAll().Invoke(), Inventory = inventory }; if (!inventoryReturn.Inventory.Any()) { if (filters != null && filters.LotKey != null) { var lotKey = new LotKey(filters.LotKey); if (!_inventoryUnitOfWork.OptimizeForReadonly().LotRepository .All() .AsExpandable() .AsNoTracking() .Any(lotKey.FindByPredicate)) { return(new InvalidResult <IInventoryReturn>(null, string.Format(UserMessages.LotNotFound, lotKey.KeyValue))); } } } return(new SuccessResult <IInventoryReturn>(inventoryReturn)); }