protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (DataContext != null) return; var id = NavigationContext.QueryString["id"]; _cart = App.Locator.Main.GetCart(new Guid(id)); DataContext = _cart; App.Locator.Main.SelectedItem = _cart.Items.FirstOrDefault(); }
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); }
/// <summary> /// Gets the navigation URI for this view. /// </summary> /// <param name="cart">The cart.</param> /// <returns></returns> public static Uri GetNavigationUri(Cart cart) { return new Uri(CartDetailView.NavigateToMeUri + cart.Id, UriKind.Relative); }
/// <summary> /// Initializes a new instance of the <see cref="CartItem" /> class. /// </summary> /// <param name="owningCart">The owning cart.</param> public CartItem(Cart owningCart) { OwningCart = owningCart; }