示例#1
0
        private void EditOrderedProduct(object sender, RoutedEventArgs e)
        {
            Button            button = sender as Button;
            CustomizedProduct copy   = new CustomizedProduct(button.DataContext as CustomizedProduct);
            var dialog = new AddModifyCustomizedProduct(copy, ListOfToppings, ListOfProducts);

            dialog.Owner = this;
            dialog.ShowDialog();
            if (dialog.DialogResult == true)
            {
                copy.BaseProduct = dialog.ModifyCustomizeProducts.SelectedBP;
                Order.OrderedProducts.FirstOrDefault(op => op.CustomizedProductId == copy.CustomizedProductId).BaseProduct  = copy.BaseProduct;
                Order.OrderedProducts.FirstOrDefault(op => op.CustomizedProductId == copy.CustomizedProductId).CustomerWish = copy.CustomerWish;
                Order.OrderedProducts.FirstOrDefault(op => op.CustomizedProductId == copy.CustomizedProductId).Toppings.RemoveAll(p => true);
                foreach (var item in dialog.ModifyCustomizeProducts.Toppings)
                {
                    var c = Order.OrderedProducts.FirstOrDefault(o => o.CustomizedProductId == copy.CustomizedProductId);
                    if (item.IsChecked)
                    {
                        c.Toppings.Add(item.Item);
                    }
                }
                DataContext = null;
                DataContext = ModifyOrders;
            }
        }
示例#2
0
        private void AddNewCustomizeProduct(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;
            var    dialog = new AddModifyCustomizedProduct(null, ListOfToppings, ListOfProducts);
            var    copy   = dialog.ModifyCustomizeProducts.CustomizedProduct;

            dialog.Owner = this;
            dialog.ShowDialog();
            if (dialog.DialogResult == true)
            {
                var customizedPToAdd = dialog.ModifyCustomizeProducts.CustomizedProduct;
                customizedPToAdd.Toppings    = new List <Topping>();
                customizedPToAdd.BaseProduct = dialog.ModifyCustomizeProducts.SelectedBP;
                foreach (var item in dialog.ModifyCustomizeProducts.Toppings)
                {
                    if (item.IsChecked)
                    {
                        customizedPToAdd.Toppings.Add(item.Item);
                    }
                }
                if (Order.OrderedProducts == null)
                {
                    Order.OrderedProducts = new List <CustomizedProduct>();
                }
                Order.OrderedProducts.Add(customizedPToAdd);
                DataContext = null;
                DataContext = ModifyOrders;
            }
        }