示例#1
0
        public IResult <IChileProductDetailReturn> GetChileProductDetail(string keyValue)
        {
            if (keyValue == null)
            {
                throw new ArgumentNullException("keyValue");
            }

            var chileProductKeyResult = KeyParserHelper.ParseResult <IChileProductKey>(keyValue);

            if (!chileProductKeyResult.Success)
            {
                return(chileProductKeyResult.ConvertTo <IChileProductDetailReturn>());
            }
            var predicate = new ChileProductKey(chileProductKeyResult.ResultingObject).FindByPredicate;
            var selector  = ProductProjectors.SelectChileProductDetail();

            var chileProduct = _productUnitOfWork.ChileProductRepository.Filter(predicate).AsExpandable().Select(selector).FirstOrDefault();

            if (chileProduct == null)
            {
                return(new FailureResult <IChileProductDetailReturn>(null, string.Format(UserMessages.ChileProductNotFound, new ChileProductKey(chileProductKeyResult.ResultingObject).KeyValue)));
            }

            return(new SuccessResult <IChileProductDetailReturn>(chileProduct));
        }
        private IResult <IDictionary <string, ILabReportChileProduct> > GetChileProducts(IEnumerable <LabReportChileLotReturn> chileLots)
        {
            var chileProductIds = chileLots.Select(c => c.ChileProductKeyReturn.ProductKey_ProductId).Distinct().ToArray();
            var select          = ProductProjectors.SelectLabReportChileProduct().Expand();
            var chileProducts   = _lotUnitOfWork.ChileProductRepository
                                  .All().AsNoTracking().Where(c => chileProductIds.Contains(c.Id)).Select(select)
                                  .ToDictionary(c => c.ProductKey, c => (ILabReportChileProduct)c);

            return(new SuccessResult <IDictionary <string, ILabReportChileProduct> >(chileProducts));
        }
示例#3
0
        public IResult <IQueryable <IProductReturn> > GetProducts(ProductTypeEnum?productType, bool includeInactive)
        {
            var select = ProductProjectors.SelectProduct();

            Expression <Func <Product, bool> > predicate = p => includeInactive || p.IsActive;

            if (productType.HasValue)
            {
                predicate = predicate.And(p => p.ProductType == productType.Value);
            }

            var query = _productUnitOfWork.ProductRepository.All().AsExpandable()
                        .Where(predicate)
                        .Select(select);

            return(new SuccessResult <IQueryable <IProductReturn> >(query));
        }
示例#4
0
        public IResult <IQueryable <IPackagingProductReturn> > GetPackagingProducts(bool includeInactive = false, bool filterProductsWithInventory = false)
        {
            var select = ProductProjectors.SelectPackagingProduct();

            Expression <Func <PackagingProduct, bool> > predicate = p => includeInactive || p.Product.IsActive;

            if (filterProductsWithInventory)
            {
                var packagingLots = _productUnitOfWork.PackagingLotRepository.All();
                predicate = predicate.And(p => packagingLots.Any(l => l.PackagingProductId == p.Id && l.Lot.Inventory.Any()));
            }
            var query = _productUnitOfWork.PackagingProductRepository.All().AsExpandable()
                        .Where(predicate)
                        .Select(select);

            return(new SuccessResult <IQueryable <IPackagingProductReturn> >(query));
        }
示例#5
0
        public IResult <IQueryable <IAdditiveProductReturn> > GetAdditiveProductSummaries(bool includeInactive = false, bool filterProductsWithInventory = false)
        {
            var additiveProduct = ProductProjectors.SelectAdditiveProduct();

            Expression <Func <AdditiveProduct, bool> > predicate = p => includeInactive || p.Product.IsActive;

            if (filterProductsWithInventory)
            {
                var additiveLots = _productUnitOfWork.AdditiveLotRepository.All();
                predicate = predicate.And(a => additiveLots.Any(l => l.AdditiveProductId == a.Id && l.Lot.Inventory.Any()));
            }

            var result = _productUnitOfWork.AdditiveProductRepository.All().AsExpandable()
                         .Where(predicate)
                         .Select(a => additiveProduct.Invoke(a));

            return(new SuccessResult <IQueryable <IAdditiveProductReturn> >(result));
        }
示例#6
0
        public IResult <IQueryable <IChileProductReturn> > GetChileProducts(ChileStateEnum?chileState = null, bool includeInactive = false, bool filterProductsWithInventory = false)
        {
            var chileProduct = ProductProjectors.SelectChileProductSummary();

            Expression <Func <ChileProduct, bool> > predicate = p => (chileState == null || p.ChileState == chileState) && (includeInactive || p.Product.IsActive);

            if (filterProductsWithInventory)
            {
                var chileLots = _productUnitOfWork.ChileLotRepository.All();
                predicate = predicate.And(p => chileLots.Any(c => c.ChileProductId == p.Id && c.Lot.Inventory.Any()));
            }

            var query = _productUnitOfWork.ChileProductRepository
                        .All().AsExpandable()
                        .Where(predicate)
                        .Select(c => chileProduct.Invoke(c));

            return(new SuccessResult <IQueryable <IChileProductReturn> >(query));
        }