예제 #1
0
        public void BuyingOffer()
        {
            CartViewItem.Clear();
            OfferViewItem.Clear();
            Dictionary <string, List <string> > BuyingOffer = CreatCartM.GetBuyingOffer(CartItemList.Select(x => x.Name).ToList());

            if (BuyingOffer != null && BuyingOffer.Count != 0)
            {
                foreach (var tempItemName in BuyingOffer.Keys)
                {
                    foreach (var tempCartItem in CartItemList)
                    {
                        if (tempItemName == tempCartItem.Name)
                        {
                            CartViewItem.Add(tempCartItem);
                        }
                    }
                }

                List <string> tempItemList = new List <string>();

                foreach (var list in BuyingOffer.Values)
                {
                    tempItemList.AddRange(list);
                }

                foreach (var tempItemName in tempItemList.Distinct())
                {
                    foreach (var tempItem in ItemList)
                    {
                        if (tempItem.Name == tempItemName)
                        {
                            Item item = CreatCartM.GetItemsByName(tempItemName).FirstOrDefault();
                            tempItem.Description    = item.Description;
                            tempItem.ImagePath      = item.ImagePath;
                            tempItem.CheapestBranch = CreatCartM.GetCheapestBranch(tempItemName);
                            OfferViewItem.Add(tempItem);
                        }
                    }
                }

                ViewVisible = Visibility.Visible;
                return;
            }
            ViewVisible = Visibility.Hidden;
        }