コード例 #1
0
        public OperationReturnModel <ProductsReturn> GetProductsSearchBrand(string catalogType, string brandName, [FromUri] SearchInputModel searchModel, [FromUri] string searchTerms = null)
        {
            OperationReturnModel <ProductsReturn> ret = new OperationReturnModel <ProductsReturn>();

            try
            {
                searchModel.CatalogType = catalogType;
                searchModel.Facets      = string.Format("brands:{0}", brandName.ToUpper());
                ProductsReturn prods = _catalogService.GetProductsBySearch(this.SelectedUserContext, searchTerms, searchModel, this.AuthenticatedUser);

                prods.Products = FavoritesAndNotesHelper.GetFavoritesAndNotesFromLists(this.AuthenticatedUser, this.SelectedUserContext, prods.Products, _listService);

                ContractInformationHelper.GetContractCategoriesFromLists(SelectedUserContext, prods.Products, _listService);

                ret.SuccessResponse = prods;
                ret.IsSuccess       = true;
            }
            catch (Exception ex)
            {
                ret.IsSuccess    = false;
                ret.ErrorMessage = ex.Message;
                _elRepo.WriteErrorLog("GetProductsSearch", ex);
            }
            return(ret);
        }
コード例 #2
0
        public HttpResponseMessage GetProductsByHouseBrandExport(string brandControlLabel, [FromUri] SearchInputModel searchModel, ExportRequestModel exportRequest)
        {
            HttpResponseMessage ret;

            try
            {
                searchModel.Size = 500;

                ProductsReturn prods = _catalogService.GetHouseProductsByBranch(this.SelectedUserContext, brandControlLabel, searchModel, this.AuthenticatedUser);

                prods.Products = FavoritesAndNotesHelper.GetFavoritesAndNotesFromLists(this.AuthenticatedUser, this.SelectedUserContext, prods.Products, _listService);

                ContractInformationHelper.GetContractCategoriesFromLists(SelectedUserContext, prods.Products, _listService);

                if (exportRequest.Fields != null)
                {
                    _exportSettingRepository.SaveUserExportSettings(this.AuthenticatedUser.UserId, ExportType.Products, ListType.Custom,
                                                                    exportRequest.Fields, exportRequest.SelectedType);
                }

                ret = ExportModel <Product>(prods.Products, exportRequest, SelectedUserContext);
            }
            catch (Exception ex)
            {
                _elRepo.WriteErrorLog("GetProductsByHouseBrandExport", ex);
                ret = Request.CreateResponse(HttpStatusCode.InternalServerError);
            }
            return(ret);
        }
コード例 #3
0
        public OperationReturnModel <ProductsReturn> GetProductsSearch(string catalogType, string searchTerms, [FromUri] SearchInputModel searchModel)
        {
            OperationReturnModel <ProductsReturn> ret = new OperationReturnModel <ProductsReturn>();

            try
            {
                if (catalogType.Equals(Constants.CATALOG_UNFI) && this.SelectedUserContext.BranchId.Equals(Constants.BRANCH_FEL))
                {
                    catalogType = Constants.CATALOG_UNFIEAST;
                }
                searchModel.CatalogType = catalogType;
                ProductsReturn prods = _catalogService.GetProductsBySearch(this.SelectedUserContext, searchTerms, searchModel, this.AuthenticatedUser);

                prods.Products = FavoritesAndNotesHelper.GetFavoritesAndNotesFromLists(this.AuthenticatedUser, this.SelectedUserContext, prods.Products, _listService);

                ContractInformationHelper.GetContractCategoriesFromLists(SelectedUserContext, prods.Products, _listService);

                ret.SuccessResponse = prods;
                ret.IsSuccess       = true;
            }
            catch (Exception ex)
            {
                ret.IsSuccess    = false;
                ret.ErrorMessage = ex.Message;
                _elRepo.WriteErrorLog("GetProductsSearch", ex);
            }
            return(ret);
        }
コード例 #4
0
        public ProductsReturn GetProductsByIdsWithPricing(UserSelectedContext catalogInfo, List <string> ids)
        {
            int totalProcessed = 0;
            var products       = new ProductsReturn()
            {
                Products = new List <Product>()
            };

            while (totalProcessed < ids.Count)
            {
                var tempProducts = _catalogRepository.GetProductsByIds(catalogInfo.BranchId, ids.Skip(totalProcessed).Take(500).Distinct().ToList());

                if (tempProducts != null && tempProducts.Products != null && tempProducts.Products.Count > 0)
                {
                    products.Count      += tempProducts.Count;
                    products.TotalCount += tempProducts.TotalCount;
                    products.Products.AddRange(tempProducts.Products);
                }

                totalProcessed += 500;
            }

            if (products.Products.Count > 0)
            {
                AddPricingInfo(products, catalogInfo, new SearchInputModel());
            }

            return(products);
        }
コード例 #5
0
        private ProductsReturn ApplySpecialFilters(UserSelectedContext catalogInfo, UserProfile profile, List <string> specialFilters, SearchInputModel searchModel, ProductsReturn returnProducts)
        {
            if (specialFilters != null &&
                specialFilters.Count > 0)
            {
                if (specialFilters.Contains(Constants.SPECIALFILTER_DEVIATEDPRICES))
                {
                    FilterDeviatedPriceProducts(returnProducts, catalogInfo);
                }

                if (specialFilters.Contains(Constants.SPECIALFILTER_PREVIOUSORDERED))
                {
                    FilterPreviouslyOrderedProducts(catalogInfo, profile, returnProducts);
                }

                ProductsReturn filtered = _catalogRepository.GetProductsByIds(catalogInfo.BranchId,
                                                                              returnProducts.Products.Select(p => p.ItemNumber)
                                                                              .ToList());

                // add facet for specialfilters to return and set count to number of products
                filtered.Facets = returnProducts.Facets;
                _catalogRepository.RecalculateFacets(filtered, specialFilters);
                returnProducts = filtered;
            }
            return(returnProducts);
        }
コード例 #6
0
                public void GoodParams_ReturnsProducts()
                {
                    // arrange
                    ICatalogLogic       testLogic   = MakeMockLogic();
                    UserSelectedContext testContext = new UserSelectedContext()
                    {
                        BranchId   = "FUT",
                        CustomerId = "123456"
                    };
                    String           search      = "hotdog";
                    SearchInputModel searchModel = new SearchInputModel()
                    {
                        From        = 0,
                        Size        = 1,
                        Facets      = "",
                        SField      = "",
                        SDir        = "",
                        CatalogType = "",
                        Dept        = ""
                    };

                    // act
                    ProductsReturn results = testLogic.GetProductsBySearch(testContext, search, searchModel, null);

                    // assert
                    results.Products.Count().Should().Be(1);
                }
コード例 #7
0
            public void GoodItem_GetProductsByItemNumberReturnsProductImages()
            {
                // arrange
                int                       expected        = 1;
                ICatalogLogic             testLogic       = MakeMockLogic();
                Mock <ICatalogRepository> testRepo        = new Mock <ICatalogRepository>();
                List <string>             testItemNumbers = new List <string> {
                    "555555"
                };
                UserSelectedContext testContext = new UserSelectedContext {
                    BranchId   = "FUT",
                    CustomerId = "123456"
                };

                // act
                ProductsReturn results = testLogic.GetProductsByItemNumbers(testContext, testItemNumbers,
                                                                            new SearchInputModel(), new UserProfile());

                // assert
                results.Products
                .First()
                .ProductImages.Count()
                .Should()
                .Be(expected);
            }
コード例 #8
0
        private decimal BuildOrderTables(OrderConfirmationNotification notification, Customer customer, StringBuilder orderLineChanges, StringBuilder originalOrderInfo)
        {
            StringBuilder        itemOrderInfo    = new StringBuilder();
            StringBuilder        itemOrderInfoOOS = new StringBuilder();
            MessageTemplateModel itemsTemplate    = _messageTemplateLogic.ReadForKey(MESSAGE_TEMPLATE_ORDERITEMS);
            MessageTemplateModel itemsOOSTemplate = _messageTemplateLogic.ReadForKey(MESSAGE_TEMPLATE_ORDERITEMSOOS);
            decimal        totalAmount            = 0;
            ProductsReturn products = _catRepo.GetProductsByIds(customer.CustomerBranch, notification.OrderChange.Items.Select(i => i.ItemNumber).ToList());
            var            pricing  = _priceLogic.GetPrices(customer.CustomerBranch, customer.CustomerNumber, DateTime.Now.AddDays(1), products.Products);

            foreach (var line in notification.OrderChange.Items)
            {
                Product currentProduct = products.Products.Where(i => i.ItemNumber == line.ItemNumber).FirstOrDefault();
                if (currentProduct == null)
                {
                    currentProduct = _catRepo.GetProductById(line.ItemCatalog, line.ItemNumber);
                }
                var    price        = pricing.Prices.Where(p => p.ItemNumber.Equals(line.ItemNumber)).FirstOrDefault();
                string priceInfo    = BuildPriceInfo(line, currentProduct);
                string extPriceInfo = BuildExtPriceInfo(line, currentProduct);
                if (line.OriginalStatus == null)
                {
                    return(-1);
                }
                if (line.OriginalStatus.Equals("filled", StringComparison.CurrentCultureIgnoreCase))
                {
                    totalAmount += GetLinePrice(line, currentProduct, price);
                    BuildItemDetail(itemOrderInfo, line, priceInfo, extPriceInfo, currentProduct);
                }
                else
                {
                    totalAmount += GetLinePrice(line, currentProduct, price);
                    BuildExceptionItemDetail(itemOrderInfoOOS, line, priceInfo, extPriceInfo, currentProduct);
                }
            }
            if (itemOrderInfoOOS.Length > 0)
            {
                originalOrderInfo.Append(itemsOOSTemplate.Body.Inject(new {
                    OrderConfirmationItemOOSDetail = itemOrderInfoOOS.ToString()
                }));
            }
            if (orderLineChanges.Length > 0)
            {
                MessageTemplateModel changeTemplate = _messageTemplateLogic.ReadForKey(MESSAGE_TEMPLATE_ORDERCHANGE);
                originalOrderInfo.Append(changeTemplate.Body.Inject(new {
                    OrderChangeLines = orderLineChanges.ToString()
                }));
            }
            if (itemOrderInfo.Length > 0)
            {
                originalOrderInfo.Append(itemsTemplate.Body.Inject(new {
                    OrderConfirmationItemDetail = itemOrderInfo.ToString()
                }));
            }
            return(totalAmount);
        }
コード例 #9
0
        private ProductsReturn GetAllProductsBySearchShallow(string search, SearchInputModel searchModel,
                                                             UserSelectedContext tempCatalogInfo)
        {
            searchModel.Size = 1; // set size to 1 to make results small; we want total
            ProductsReturn ret = _catalogRepository.GetProductNumbersBySearch(tempCatalogInfo, search, searchModel);

            searchModel.Size = ret.TotalCount; // set size to total to get all
            ret = _catalogRepository.GetProductNumbersBySearch(tempCatalogInfo, search, searchModel);
            return(ret);
        }
コード例 #10
0
        public Product GetProductByIdOrUPC(UserSelectedContext catalogInfo, string idorupc, UserProfile profile)
        {
            Product ret = null;

            if (idorupc.Length <= 6)
            {
                ret = _catalogRepository.GetProductById(catalogInfo.BranchId, idorupc);
            }
            else
            {
                //Try to find by UPC
                ProductsReturn products = GetProductsBySearch(catalogInfo, idorupc, new SearchInputModel()
                {
                    From = 0, Size = 10, SField = "upc"
                }, profile);
                foreach (Product p in products.Products)
                {
                    if (p.UPC == idorupc)
                    {
                        return(p);
                    }
                }
            }

            if (ret == null)
            {
                return(null);
            }

            AddProductImageInfo(ret);
            AddItemHistoryToProduct(ret, catalogInfo);

            //PriceReturn pricingInfo = _priceLogic.GetPrices(catalogInfo.BranchId, catalogInfo.CustomerId, DateTime.Now.AddDays(1), new List<Product>() { ret });
            PriceReturn pricingInfo = null;

            //if (!IsSpecialtyCatalog(null,ret.CatalogId))
            pricingInfo = _priceLogic.GetPrices(catalogInfo.BranchId, catalogInfo.CustomerId, DateTime.Now.AddDays(1), new List <Product>()
            {
                ret
            });
            //else
            //    pricingInfo = _priceLogic.GetNonBekItemPrices(catalogInfo.BranchId, catalogInfo.CustomerId, GetCatalogTypeFromCatalogId(ret.CatalogId), DateTime.Now.AddDays(1), new List<Product>() { ret });

            if (pricingInfo != null && pricingInfo.Prices.Where(p => p.ItemNumber.Equals(ret.ItemNumber)).Any())
            {
                var price = pricingInfo.Prices.Where(p => p.ItemNumber.Equals(ret.ItemNumber)).First();
                ret.CasePrice           = price.CasePrice.ToString();
                ret.CasePriceNumeric    = price.CasePrice;
                ret.PackagePrice        = price.PackagePrice.ToString();
                ret.PackagePriceNumeric = price.PackagePrice;
                ret.DeviatedCost        = price.DeviatedCost ? "Y" : "N";
            }

            return(ret);
        }
コード例 #11
0
 private void SortAscendingByPrices(ProductsReturn prods, SearchInputModel searchModel)
 {
     if (searchModel.SField == "caseprice")
     {
         prods.Products.Sort((x, y) => x.CasePriceNumeric.CompareTo(y.CasePriceNumeric));
     }
     else
     {
         prods.Products.Sort((x, y) => x.UnitCost.CompareTo(y.UnitCost));
     }
 }
コード例 #12
0
        private ProductsReturn GetAllCategoryProductsShallow(SearchInputModel searchModel, string categoryName,
                                                             UserSelectedContext newCatalog)
        {
            // get just the itemnumber and catalogid of the products matching the query
            searchModel.Size = 1; // set size 1 to to min results; we want total
            ProductsReturn ret = _catalogRepository.GetProductNumbersByCategory(newCatalog, categoryName, searchModel);

            searchModel.Size = ret.TotalCount; // set size total from before
            ret = _catalogRepository.GetProductNumbersByCategory(newCatalog, categoryName, searchModel);
            return(ret);
        }
コード例 #13
0
        private ProductsReturn GetAllHouseBrandProductsShallow(UserSelectedContext catalogInfo, string brandControlLabel,
                                                               SearchInputModel searchModel)
        {
            searchModel.Size = 1; // set size to 1; we want total
            ProductsReturn returnValue = _catalogRepository.GetHouseProductNumbersByBranch(catalogInfo, brandControlLabel,
                                                                                           searchModel);

            searchModel.Size = returnValue.TotalCount; // set size to total
            returnValue      = _catalogRepository.GetHouseProductNumbersByBranch(catalogInfo, brandControlLabel, searchModel);
            return(returnValue);
        }
コード例 #14
0
        private List <Core.Models.SiteCatalog.Pricing.PowerMenu.Product> GetItemPricing(string branchId, string customerNumber, List <ProductLine> products,
                                                                                        DateTime effectiveDate)
        {
            List <Core.Models.SiteCatalog.Pricing.PowerMenu.Product> retVal = new List <Core.Models.SiteCatalog.Pricing.PowerMenu.Product>();

            List <string> itemNumbers = (from ProductLine p in products
                                         select p.ProductNumber).ToList();
            ICatalogLogic  catLogic = _scope.GetService(typeof(ICatalogLogic)) as ICatalogLogic;
            ProductsReturn items    = catLogic.GetProductsByIdsWithPricing(new UserSelectedContext()
            {
                BranchId = branchId, CustomerId = customerNumber
            }, itemNumbers);

            foreach (Svc.Core.Models.SiteCatalog.Product item in items.Products)
            {
                KeithLink.Svc.Core.Models.SiteCatalog.Pricing.PowerMenu.Product currentItem = new KeithLink.Svc.Core.Models.SiteCatalog.Pricing.PowerMenu.Product();

                currentItem.ProductNumber = item.ItemNumber;
                currentItem.IsAuthorized  = item.HasPrice;
                currentItem.IsActive      = true;
                currentItem.AvailableQty  = 0;
                currentItem.IsCatchWeight = item.CatchWeight;

                ProductLine myProduct = (from ProductLine p in products
                                         where p.ProductNumber == currentItem.ProductNumber
                                         select p).FirstOrDefault();
                if (item.CatchWeight)
                {
                    currentItem.Price          = (decimal)item.CasePriceNumeric;
                    currentItem.PurchaseByUnit = "lb";
                }
                else if (myProduct.Unit.Length == 0 || myProduct.Unit.Equals("case", StringComparison.InvariantCultureIgnoreCase))
                {
                    currentItem.Price          = (decimal)item.CasePriceNumeric;
                    currentItem.PurchaseByUnit = "cs";
                }
                else if (myProduct.Unit.Equals("each", StringComparison.InvariantCultureIgnoreCase))
                {
                    currentItem.Price          = (decimal)item.PackagePriceNumeric;
                    currentItem.PurchaseByUnit = "ea";
                }
                else
                {
                    currentItem.Price          = 0;
                    currentItem.PurchaseByUnit = string.Empty;
                }

                retVal.Add(currentItem);
            }

            return(retVal);
        }
コード例 #15
0
        public void AddPricingInfo(ProductsReturn prods, UserSelectedContext context, SearchInputModel searchModel)
        {
            if (context == null || String.IsNullOrEmpty(context.CustomerId))
            {
                return;
            }

            PriceReturn pricingInfo = GetPricingInfoForProducts(prods, context);

            AddPricingInfoToProducts(prods, pricingInfo);

            AddSortForPricingWhenApplicable(prods, searchModel);
        }
コード例 #16
0
        private ProductsReturn GetDeviatedPriceProductsBySearch(UserSelectedContext catalogInfo, string search, SearchInputModel searchModel, UserSelectedContext tempCatalogInfo)
        {
            ProductsReturn ret = _catalogRepository.GetProductNumbersBySearch(tempCatalogInfo, search, searchModel);

            // filter out just those with deviated prices
            FilterDeviatedPriceProducts(ret, catalogInfo);
            // now go back and fill out the rest of the product information on those with deviated prices
            ret = _catalogRepository.GetProductsByIds(catalogInfo.BranchId, ret.Products.Select(p => p.ItemNumber).ToList());
            // add facet for specialfilters to return and set count to number of products
            ret.Facets = new System.Dynamic.ExpandoObject();
            _catalogRepository.AddSpecialFiltersToFacets(ret.Facets, ret.Products.Count().ToString());
            return(ret);
        }
コード例 #17
0
                public void EmptyIds_ReturnsNoProducts()
                {
                    // arrange
                    ICatalogLogic testLogic = MakeMockLogic();
                    String        branch    = "FRT?";
                    List <string> ids       = new List <string>();

                    // act
                    ProductsReturn results = testLogic.GetProductsByIds(branch, ids);

                    // assert
                    results.Products.Count().Should().Be(0);
                }
コード例 #18
0
        public ProductsReturn GetCatalogCampaignProducts(string campaignUri, UserSelectedContext context, SearchInputModel model, UserProfile profile)
        {
            CatalogCampaignReturnModel campaign = _campaignLogic.GetCampaignByUri(campaignUri);

            ProductsReturn products = null;
            var            items    = campaign?.Items?.Select(x => x.ItemNumber).ToList();

            if (items != null)
            {
                products = _catalogLogic.GetProductsByItemNumbers(context, items, model, profile);
            }

            return(products);
        }
コード例 #19
0
        private void AddPricingInfoToProducts(ProductsReturn prods, PriceReturn pricingInfo)
        {
            foreach (Price p in pricingInfo.Prices)
            {
                Product prod = prods.Products.Find(x => x.ItemNumber == p.ItemNumber);

                prod.CasePrice           = p.CasePrice.ToString();
                prod.CasePriceNumeric    = p.CasePrice;
                prod.PackagePrice        = p.PackagePrice.ToString();
                prod.PackagePriceNumeric = p.PackagePrice;
                prod.DeviatedCost        = p.DeviatedCost ? "Y" : "N";
                //}
            }
        }
コード例 #20
0
        public ListModel BuildList(UserProfile user, UserSelectedContext catalogInfo, ListImportFileModel file)
        {
            ListModel newList = new ListModel {
                Name = string.Format("Imported List - {0}", DateTime.Now.ToShortDateString()), BranchId = catalogInfo.BranchId
            };

            List <ListItemModel> items = new List <ListItemModel>();

            switch (file.FileFormat)
            {
            case FileFormat.CSV:
                items = parseListDelimited(file, CSV_DELIMITER, user, catalogInfo);
                break;

            case FileFormat.Tab:
                items = parseListDelimited(file, TAB_DELIMITER, user, catalogInfo);
                break;

            case FileFormat.Excel:
                items = parseListExcel(file, user, catalogInfo);
                break;
            }

            ProductsReturn validProducts = catalogLogic.GetProductsByIds(catalogInfo.BranchId, items.Select(i => i.ItemNumber)
                                                                         .Distinct()
                                                                         .ToList());

            List <ListItemModel> mergedItems = (from x in items
                                                join y in validProducts.Products on x.ItemNumber.Trim() equals y.ItemNumber.Trim()
                                                select x).ToList();

            //if (items.Select( p => p.ItemNumber ).Distinct().Count() != validProducts.Products.Select( o => o.ItemNumber ).Distinct().Count()) {
            if (items.Distinct()
                .Count() != mergedItems.Distinct()
                .Count())
            {
                Warning("Some items were not imported because they were not found in the current catalog.");
                newList.Items = mergedItems;
                //foreach (var item in items)
                //    if (validProducts.Products.Where( p => p.ItemNumber.Equals( item.ItemNumber ) ).Any())
                //        newList.Items.Add( item );
            }
            else
            {
                newList.Items = items;
            }

            return(newList);
        }
コード例 #21
0
 private void AddSortForPricingWhenApplicable(ProductsReturn prods, SearchInputModel searchModel)
 {
     if ((searchModel.SField == "caseprice" ||
          searchModel.SField == "unitprice"))   // sort pricing info first
     {
         if (searchModel.SDir == "asc")
         {
             SortAscendingByPrices(prods, searchModel);
         }
         else
         {
             SortDescendingByPrices(prods, searchModel);
         }
     }
 }
コード例 #22
0
        private void GetPreviouslyOrderedProductInfo(UserProfile profile, ProductsReturn ret, UserSelectedContext catalogInfo)
        {
            if (profile != null)
            {
                List <InHistoryReturnModel> history = _historyLogic.ItemsInHistoryList(catalogInfo, ret.Products.Select(p => p.ItemNumber)
                                                                                       .ToList());

                ret.Products.ForEach(delegate(Product prod)
                {
                    prod.InHistory = history.Where(h => h.ItemNumber.Equals(prod.ItemNumber))
                                     .FirstOrDefault()
                                     .InHistory;
                });
            }
        }
コード例 #23
0
        private PriceReturn GetPricingInfoForProducts(ProductsReturn prods, UserSelectedContext context)
        {
            PriceReturn pricingInfo = null;

            if (prods.Products.Count > 0 && IsSpecialtyCatalog(null, prods.Products[0].CatalogId))
            {
                string source = GetCatalogTypeFromCatalogId(prods.Products[0].CatalogId);
                pricingInfo = _priceLogic.GetNonBekItemPrices("fdf", context.CustomerId, source, DateTime.Now.AddDays(1), prods.Products);
            }
            else
            {
                pricingInfo = _priceLogic.GetPrices(context.BranchId, context.CustomerId, DateTime.Now.AddDays(1), prods.Products);
            }

            return(pricingInfo);
        }
コード例 #24
0
        public ProductsReturn GetRecommendedItemsForCart(UserSelectedContext catalogInfo, List <string> cartItems, UserProfile profile, int?pageSize, bool?getImages)
        {
            List <RecommendedItemsModel> recommendedItems = _recommendedItemsRepository.GetRecommendedItemsForCustomer(catalogInfo.CustomerId, catalogInfo.BranchId, cartItems, 50);

            ProductsReturn productsReturn = _catalogRepository.GetProductsByIdsWithoutProprietaryItems(catalogInfo.BranchId, recommendedItems.Select(x => x.RecommendedItem).ToList());
            List <Product> validProducts  = new List <Product>();

            AddPricingInfo(productsReturn, catalogInfo);

            foreach (Product product in productsReturn.Products)
            {
                bool hasImages  = false;
                bool hasPricing = false;

                if (product.HasPrice)
                {
                    hasPricing = true;
                }

                if (product.HasPrice && getImages.HasValue == true && getImages.Value == true)
                {
                    _catalogLogic.AddProductImageInfo(product);

                    if (product.ProductImages.Any() == true)
                    {
                        hasImages = true;
                    }
                }

                if ((getImages.Equals(true) && hasImages == true) || (getImages.HasValue == false || getImages.Equals(false)))
                {
                    validProducts.Add(product);
                }

                if (pageSize.HasValue && validProducts.Count >= pageSize)
                {
                    break;
                }
            }

            productsReturn.Products = validProducts;

            GetAdditionalProductInfo(profile, productsReturn, catalogInfo, false);
            ApplyRecommendedTagging(productsReturn);

            return(productsReturn);
        }
コード例 #25
0
        private void CalculateCartSupTotal(UserSelectedContext catalogInfo, ShoppingCart newCart, ref List <ShoppingCartItem> items)
        {
            ProductsReturn products = catalogLogic.GetProductsByIds(catalogInfo.BranchId, items.Select(i => i.ItemNumber)
                                                                    .ToList());

            items.ForEach(delegate(ShoppingCartItem item) {
                Product product = products.Products.Where(p => p.ItemNumber == item.ItemNumber)
                                  .FirstOrDefault();
                if (product != null)
                {
                    item.CatchWeight   = product.CatchWeight;
                    item.AverageWeight = product.AverageWeight;
                }
            });

            List <ShoppingCartItem> goodItems = new List <ShoppingCartItem>();

            PriceReturn prices = priceLogic.GetPrices(catalogInfo.BranchId, catalogInfo.CustomerId, DateTime.Now.AddDays(1), items.Select(i => new Product {
                ItemNumber = i.ItemNumber
            })
                                                      .ToList());

            foreach (ShoppingCartItem item in items)
            {
                Price price = prices.Prices.Where(p => p.ItemNumber == item.ItemNumber)
                              .FirstOrDefault();
                if (price != null)
                {
                    newCart.SubTotal += (decimal)item.LineTotal(item.Each ? price.PackagePrice : price.CasePrice);
                    if ((decimal)item.LineTotal(item.Each ? price.PackagePrice : price.CasePrice) > 0)
                    {
                        goodItems.Add(item);
                    }
                    else
                    {
                        _warnings = new StringBuilder();
                        _warnings.AppendLine("Some items failed to import.  Please check the items in your cart.");
                    }
                }
                else
                {
                    _warnings = new StringBuilder();
                    _warnings.AppendLine("Some items failed to import.  Please check the items in your cart.");
                }
            }
            items = goodItems;
        }
コード例 #26
0
                public void EmptyIds_ReturnsNoProducts()
                {
                    // arrange
                    ICatalogLogic       testLogic   = MakeMockLogic();
                    UserSelectedContext testContext = new UserSelectedContext()
                    {
                        BranchId   = "FUT",
                        CustomerId = "123456"
                    };
                    List <string> ids = new List <string>();

                    // act
                    ProductsReturn results = testLogic.GetProductsByIdsWithPricing(testContext, ids);

                    // assert
                    results.Products.Count().Should().Be(0);
                }
コード例 #27
0
        public ProductsReturn GetRecommendedItemsByCart(RecommendedItemsRequestModel request)
        {
            ProductsReturn recommendedItems = _catalogService.GetRecommendedItemsForCart(this.SelectedUserContext,
                                                                                         request.CartItems,
                                                                                         this.AuthenticatedUser,
                                                                                         request.PageSize,
                                                                                         request.GetImages);

            if (request.PageSize.HasValue)
            {
                //recommendedItems.Products = recommendedItems.Products.Take(request.PageSize.Value).ToList();
                recommendedItems.TotalCount = recommendedItems.Products.Count();
                recommendedItems.Count      = recommendedItems.Products.Count();
            }

            return(recommendedItems);
        }
コード例 #28
0
                public void GoodBranch_ReturnsProducts()
                {
                    // arrange
                    ICatalogLogic testLogic = MakeMockLogic();
                    String        branch    = "FRT?";
                    List <string> ids       = new List <string>()
                    {
                        "123456",
                        "234567",
                        "345678"
                    };

                    // act
                    ProductsReturn results = testLogic.GetProductsByIds(branch, ids);

                    // assert
                    results.Products.Count().Should().Be(2);
                }
コード例 #29
0
        public ProductsReturn GetProductsByItemNumbers(UserSelectedContext context, List <string> itemNumbers, SearchInputModel searchModel, UserProfile profile)
        {
            ProductsReturn returnValue = new ProductsReturn()
            {
                Products = new List <Product>()
            };

            returnValue = _catalogRepository.GetProductsByItemNumbers(context.BranchId, itemNumbers, searchModel);

            foreach (Product product in returnValue.Products)
            {
                AddProductImageInfo(product);
            }

            AddPricingInfo(returnValue, context, searchModel);

            return(returnValue);
        }
コード例 #30
0
        private PriceReturn GetPricingInfoForProducts(ProductsReturn prods, UserSelectedContext context)
        {
            PriceReturn pricingInfo = null;

            if (prods.Products.Count > 0 &&
                _catalogLogic.IsSpecialtyCatalog(null, prods.Products[0].CatalogId))
            {
                string source = _catalogLogic.GetCatalogTypeFromCatalogId(prods.Products[0].CatalogId);
                // we use FDF as the default here for external catalog pricing
                pricingInfo = _priceLogic.GetNonBekItemPrices(Constants.BRANCH_FDF, context.CustomerId, source, DateTime.Now.AddDays(1), prods.Products);
            }
            else
            {
                pricingInfo = _priceLogic.GetPrices(context.BranchId, context.CustomerId, DateTime.Now.AddDays(1), prods.Products);
            }

            return(pricingInfo);
        }