Пример #1
0
        public PriceReturn GetNonBekItemPrices(string branchId, string customerNumber, string source, DateTime shipDate, List <Product> products)
        {
            List <Price>   cachedPriceList     = null;
            List <Product> uncachedProductList = null;

            BuildCachedPriceList(branchId, customerNumber, products, out cachedPriceList, out uncachedProductList);

            PriceReturn retVal = new PriceReturn();

            retVal.Prices.AddRange(cachedPriceList);

            if (uncachedProductList.Count > 0)
            {
                List <Price> uncachedPrices = _priceRepository.GetNonBekItemPrices(branchId, customerNumber, shipDate, source, uncachedProductList);

                foreach (Price p in uncachedPrices)
                {
                    _priceCacheRepository.AddItem(CACHE_GROUPNAME, CACHE_PREFIX, CACHE_NAME,
                                                  GetCacheKey(p.BranchId, p.CustomerNumber, p.ItemNumber), TimeSpan.FromHours(2), p);
                }
                retVal.Prices.AddRange(uncachedPrices);
            }

            return(retVal);
        }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
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";
                //}
            }
        }
Пример #5
0
        private List <Core.Models.SiteCatalog.Pricing.PowerMenu.Product> GetItemPricing(string branchId, string customerNumber, ProductLine[] products,
                                                                                        DateTime effectiveDate)
        {
            List <Core.Models.SiteCatalog.Pricing.PowerMenu.Product> retVal = new List <Core.Models.SiteCatalog.Pricing.PowerMenu.Product>();

            List <Core.Models.SiteCatalog.Product> productList = (from ProductLine p in products
                                                                  select new Core.Models.SiteCatalog.Product {
                ItemNumber = p.ProductNumber
            }).ToList();

            IPriceLogic priceLogic = _scope.GetService(typeof(IPriceLogic)) as IPriceLogic;
            PriceReturn prices     = priceLogic.GetPrices(branchId, customerNumber, effectiveDate, productList);

            foreach (Price price in prices.Prices)
            {
                KeithLink.Svc.Core.Models.SiteCatalog.Pricing.PowerMenu.Product currentItem = new KeithLink.Svc.Core.Models.SiteCatalog.Pricing.PowerMenu.Product();

                currentItem.ProductNumber = price.ItemNumber;
                currentItem.IsAuthorized  = (price.CasePrice > 0 || price.PackagePrice > 0);
                currentItem.IsActive      = true;
                currentItem.AvailableQty  = 0;
                currentItem.IsCatchWeight = false;

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

                retVal.Add(currentItem);
            }

            return(retVal);
        }
Пример #6
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);
        }
Пример #7
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;
        }
Пример #8
0
        public ActionResult PriceGet()
        {
            DateTime    dateTime = DateTime.Parse(Request.Form["dTime"]);
            var         prices   = DC.Set <StoreInPrice>().Where(x => x.DateIn == dateTime && x.CompanyId == new Guid(LoginUserInfo.Attributes["CompanyId"].ToString())).OrderByDescending(x => x.CreateTime).FirstOrDefault();
            PriceReturn pr       = new PriceReturn();

            if (prices == null)
            {
                pr.ResultCode = "1";
            }
            else
            {
                pr.ResultCode = "0";
                pr.sip        = prices;
            }
            return(new JsonResult(pr));
        }
Пример #9
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);
        }
Пример #10
0
        public Product GetProductById(UserSelectedContext catalogInfo, string id, UserProfile profile, string catalogType)
        {
            var    bekBranchId = catalogInfo.BranchId;
            string catalogId   = GetBranchId(catalogInfo.BranchId, catalogType);

            catalogInfo.BranchId = catalogId;
            Product ret = _catalogRepository.GetProductById(catalogInfo.BranchId, id);

            //Dictionary<string, string> contractdictionary = ContractInformationHelper.GetContractInformation(catalogInfo, _listRepo, _catalogCacheRepository);

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

            AddProductImageInfo(ret);
            AddItemHistoryToProduct(ret, catalogInfo);
            //ret.Category = ContractInformationHelper.AddContractInformationIfInContract(contractdictionary, new ListItemModel() { ItemNumber = ret.ItemNumber });

            PriceReturn pricingInfo = null;

            //if (IsSpecialtyCatalog(catalogType)) {
            //    pricingInfo = _priceLogic.GetNonBekItemPrices(bekBranchId, catalogInfo.CustomerId, catalogType, DateTime.Now.AddDays(1), new List<Product>() { ret });
            //} else {
            pricingInfo = _priceLogic.GetPrices(bekBranchId, catalogInfo.CustomerId, 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
        /// <summary>
        /// Filter the given list of products for just those with deviated prices
        /// </summary>
        /// <param name="prods"></param>
        /// <param name="context"></param>
        /// <param name="searchModel"></param>
        private void FilterDeviatedPriceProducts(ProductsReturn prods, UserSelectedContext context)
        {
            if (context == null || String.IsNullOrEmpty(context.CustomerId))
            {
                return;
            }

            PriceReturn pricingInfo = GetPricingInfoForProducts(prods, context);

            foreach (Price p in pricingInfo.Prices)
            {
                Product prod = prods.Products.Find(x => x.ItemNumber == p.ItemNumber);

                prod.DeviatedCost = p.DeviatedCost ? "Y" : "N";
            }

            prods.Products   = prods.Products.Where(p => p.DeviatedCost == "Y").ToList();
            prods.Count      = prods.Products.Count();
            prods.TotalCount = prods.Products.Count();
        }