Example #1
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.Order_win = ((Shop.Order)(target));
                return;

            case 2:
                this.UserBtn = ((System.Windows.Controls.Button)(target));
                return;

            case 3:
                this.OrderLB = ((System.Windows.Controls.ListBox)(target));
                return;

            case 4:
                this.UserAvatar = ((System.Windows.Controls.Image)(target));
                return;

            case 5:
                this.UserName = ((System.Windows.Controls.Label)(target));
                return;

            case 6:
                this.DateLabel = ((System.Windows.Controls.Label)(target));
                return;
            }
            this._contentLoaded = true;
        }
        public double RequestOrder(Order order)
        {
            foreach (KeyValuePair<int,int> requestedItem in order.OrderedItems)
            {
                bool found = false;
                foreach (Product product in products)
                {
                    if (product.Id == requestedItem.Key)
                    {
                        if (product.Quantity >= requestedItem.Value)
                        {
                            found = true;
                        }
                    }
                }
                if (!found) throw new NotAvailableInInventoryException("Some items are unavailable!");
            }

            double price = 0;

            foreach (var requestedItem in order.OrderedItems)
            {
                foreach (var product in products)
                {
                    if (product.Id == requestedItem.Key)
                    {
                        product.Quantity = product.Quantity - requestedItem.Value;
                        price += requestedItem.Value * product.AfterTaxPrice;
                    }
                }
            }
            return price;
        }
 partial void DeleteOrder(Order instance);
 partial void UpdateOrder(Order instance);
 partial void InsertOrder(Order instance);