protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            var id = NavigationContext.QueryString["id"];
            _item = App.Locator.Main.GetItem(new Guid(id));
            DataContext = _item;
        }
        public void GetCarts(Action<IEnumerable<Cart>, Exception> callback)
        {
            var carts = new List<Cart>();
            var randomizer = new Random();
            var storeEnumCount = Enum.GetNames(typeof(Store)).Length;
            var discountTypeEnumCount = Enum.GetNames(typeof(DiscountType)).Length;

            for (int i = 0; i < 10; i++)
            {
                var cart = new Cart();
                cart.Name = "Cart " + (i + 1);
                cart.Store = (Store)randomizer.Next(storeEnumCount);

                for (int j = 0; j < 10; j++)
                {
                    var item = new CartItem(cart);
                    item.Name = "Cart Item " + (j + 1);
                    item.Price = j * 10;
                    item.Quantity = j;
                    item.Taxable = i % 2 == 0;
                    item.ExpirationDate = DateTime.Now;

                    for (int k = 0; k < 3; k++)
                    {
                        var discount = new CartItemDiscount(item);
                        discount.Name = "Discount " + (i + 1);
                        discount.Discount = k * .75;
                        discount.Type = (DiscountType)randomizer.Next(discountTypeEnumCount);
                        discount.ExpirationDate = DateTime.Now;
                        item.Discounts.Add(discount);
                    }

                    cart.Items.Add(item);
                }

                carts.Add(cart);
            }

            callback(carts, null);
        }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CartItemDiscount" /> class.
 /// </summary>
 /// <param name="owningItem">The owning item.</param>
 public CartItemDiscount(CartItem owningItem)
 {
     OwningItem = owningItem;
 }
 public static Uri GetNavigationUri(CartItem item)
 {
     return new Uri(ItemDetailView.NavigateToMeUri + item.Id, UriKind.Relative);
 }