Пример #1
0
        public void AddToCart(Product product)
        {
            // Get the matching cart and album instances
            var cart = GetCart(cartSessionID);
            var cartItem = cart.CartItems.SingleOrDefault(i => i.ProductID == product.ProductID);
            Debug.WriteLine("Add to cart: " + cartSessionID);

            if (cartItem == null)
            {
                // Create a new cart item if no cart item exists
                cartItem = new CartItem
                {
                    ProductID = product.ProductID,
                    CartID = cart.ID,
                    Quantity = 1,
                };
                storeDB.CartItems.Add(cartItem);
            }
            else
            {
                // If the item does exist in the cart,
                // then add one to the quantity
                cartItem.Quantity += 1;
                Debug.WriteLine(cartItem.Quantity);
            }
            // Save changes
            Debug.WriteLine("Before : " + cartItem.Quantity);
            storeDB.SaveChanges();
            Debug.WriteLine("After " + cartItem.Quantity);
        }
Пример #2
0
        public ProductViewModel(Product product)
        {
            Product = product;
            IconSource = AsyncImageSource.FromUriAndResource(product.IconUrl, _resource);
            NavigateToProduct = new Command(() => MessagingCenter.Send(Product, Messages.NavigateTo));

        }
Пример #3
0
 public ProductViewModel(Product product)
 {
     Product = product;
     IconSource = AsyncImageSource.FromUriAndResource(product.IconUrl, _resource);
 }
Пример #4
0
 private async void NavigateToProduct(Product product)
 {
     await _navi.ShowProduct(product);
 }
Пример #5
0
        private static void UpdateItem(Product item, string imgurId)
        {
            item.ImageUrl = string.Format("http://i.imgur.com/{0}.jpg", imgurId);
            item.IconUrl = string.Format("http://i.imgur.com/{0}s.jpg", imgurId);

            item.Name = item.Name.Titleize().Replace(".", string.Empty);
            item.Description = item.Description.Humanize(LetterCasing.Sentence);
        }