private async void DoTapAction(StoreItem key)
        {
            if (!LicenseInformation.ProductLicenses[key.Code].IsActive)
            {
                try
                {
#if DEBUG
                    var result = await CurrentAppSimulator.RequestProductPurchaseAsync(key.Code);
#else
                    var result = await CurrentApp.RequestProductPurchaseAsync(key.Code);
#endif

                    CheckBuy();

                    CheckType();
                }
                catch (Exception e)
                {
                }
            }
            else
            {
                var item = AvailableProducts.Where(x => x.Code == key.Code).FirstOrDefault();
                if (item != null)
                {
                    item.Purchased = true;
                }
            }
        }
Exemple #2
0
        private void ConfigureAndCreateEntitiesBeforeRunningTests()
        {
            //update current project to support these languages
            var project = this.ChangeProjectLanguages(new List <string> {
                "en", "de"
            });

            Assert.Equal(2, project.Languages.Count);
            Assert.True(project.Languages.Contains("en") && project.Languages.Contains("de"));

            //Fill entities
            this.FillCategories();
            this.FillProducts();
            var allProductIds = AvailableProducts.Select(product => product.Id).ToArray();

            var searchRequest = new SearchProductProjectionsCommand();

            searchRequest.SetStaged(true);
            searchRequest.FilterQuery(p => p.Id.In(allProductIds));
            IClient commerceToolsClient = this.GetService <IClient>();

            //wait till elastic search index refreshed with created products
            AssertEventually(() =>
            {
                var searchResults = commerceToolsClient.ExecuteAsync(searchRequest).Result;
                Assert.Equal(allProductIds.Length, searchResults.Results.Count);
            });
        }
 public ProductProjection FindProduct(Func <ProductProjection, bool> predicate)
 {
     if (AvailableProducts == null || AvailableProducts.Count == 0)
     {
         return(null);
     }
     return(AvailableProducts.FirstOrDefault(predicate));
 }
Exemple #4
0
 public void DisplayFoodMenu()
 {
     Console.Clear();
     Console.WriteLine("Current balance: {0}\n", Balance);
     foreach (var i in AvailableProducts)
     {
         Console.WriteLine("{0}. Type: {1}. Product: {2}. Price: {3} kr", AvailableProducts.IndexOf(i) + 1, i.ProductType, i.ProductName, i.Price);
     }
     Console.Write("\nChoose product(1-9) and then enter. Press 'Q' to go back to main menu: ");
 }
        public void CanLoadItemToCart()
        {
            Order             order = new Order();
            AvailableProducts A     = new AvailableProducts("A", 50);

            order.addProduct(A, 5);
            AvailableProducts B = new AvailableProducts("B", 30);

            order.addProduct(B, 3);
            Assert.AreEqual(order.Quantiy, 2).;
        }
        private void CheckType()
        {
            var purchased = AvailableProducts.Where(x => x.Purchased).LastOrDefault();

            if (purchased != null)
            {
                ShowUpgrade = false;
                UserType    = purchased.Name;
            }
            else
            {
                ShowUpgrade = true;
                UserType    = _resourceLoader.GetString("gratis");
            }
        }
Exemple #7
0
        private void SetupPicklist()
        {
            var orderProductsIds  = Order.Model.OrderItems.Select(o => o.Product.Id).ToList();
            var addedProducts     = _allProducts.Where(p => orderProductsIds.Contains(p.Id)).OrderBy(o => o.Name);
            var availableProducts = _allProducts.Except(addedProducts).OrderBy(p => p.Name);

            AddedProducts.Clear();
            AvailableProducts.Clear();
            foreach (var addedProduct in addedProducts)
            {
                AddedProducts.Add(addedProduct);
            }
            foreach (var availableProduct in availableProducts)
            {
                AvailableProducts.Add(availableProduct);
            }
        }
Exemple #8
0
        private void OnRemoveProductExecute()
        {
            var productToRemove = SelectedAddedProduct;
            // &???????????????????????????????????
            OrderItem orderItemToRemove = productToRemove.OrderItems.FirstOrDefault(o => o.ProductId == productToRemove.Id);

            Order.Model.OrderItems.Remove(orderItemToRemove);

            productToRemove.StockBalance += orderItemToRemove.Quantity;

            decimal discount = (decimal)(100 - productToRemove.ProductDiscount.Rate) / 100;

            Order.TotalAmount -= orderItemToRemove.Quantity * orderItemToRemove.UnitPrice * discount;

            AddedProducts.Remove(productToRemove);
            AvailableProducts.Add(productToRemove);
            HasChanges = _orderRepository.HasChanges();
            ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged();
        }
Exemple #9
0
        /// <summary>
        /// Function to get all products in a given, hardcoded catalog
        /// Reads through a csv file and creates new a <see cref="Product"/> for each line
        /// </summary>
        private void GetProducts()
        {
            try
            {
                var reader = new StreamReader(File.OpenRead("catalog.csv"));

                while (!reader.EndOfStream)
                {
                    string line        = reader.ReadLine();
                    var    productInfo = line.Split(',');

                    AvailableProducts.Add(new Product(productInfo[0], productInfo[1], productInfo[2]));
                }

                SelectedProduct = AvailableProducts.FirstOrDefault();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
Exemple #10
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to Shopping Zone!");
            Order             order = new Order();
            AvailableProducts A     = new AvailableProducts("A", 50);

            order.addProduct(A, 5);
            // 250 + 3*30
            AvailableProducts B = new AvailableProducts("B", 30);

            order.addProduct(B, 3);
            AvailableProducts C = new AvailableProducts("C", 20);

            order.addProduct(C, 4);
            AvailableProducts D = new AvailableProducts("D", 15);

            order.addProduct(D, 3);
            Promotion fixedPriceOnMultipleItem1 = new NumberOfProductInFixedCost("Buy 3A at fixed Price 130", new List <Product> {
                A
            }, 130, 3);

            order.AddDiscount(fixedPriceOnMultipleItem1);
            Promotion fixedPriceOnMultipleItem2 = new NumberOfProductInFixedCost("Buy 2B at fixed Price 45", new List <Product> {
                B
            }, 45, 2);

            order.AddDiscount(fixedPriceOnMultipleItem2);
            Promotion fixedPrice = new BuySKU1_SKU2FixedPrice("Buy SKU1 & SKU2 at fixed Price", new List <Product> {
                C
            }, new List <Product> {
                D
            }, 30);

            order.AddDiscount(fixedPrice);
            foreach (var item in order.ItemOnCart)
            {
                Console.WriteLine("Product- " + item.Product.Name + " purchased at price of " + item.DiscountAmount);
            }
            Console.ReadLine();
        }
Exemple #11
0
        private void OnAddProductExecute()
        {
            var     productToAdd = SelectedAvailableProduct;
            decimal discount     = (100m - Convert.ToDecimal(productToAdd.ProductDiscount.Rate)) / 100m;

            Order.Model.OrderItems.Add(new OrderItem
            {
                OrderId    = Id,
                ProductId  = productToAdd.Id,
                UnitPrice  = productToAdd.Price,
                Quantity   = ProductQuantityToAdd,
                TotalPrice = ProductQuantityToAdd * productToAdd.Price * discount
            });

            SelectedAvailableProduct.StockBalance -= ProductQuantityToAdd;
            Order.TotalAmount +=
                ProductQuantityToAdd * productToAdd.Price * discount;

            AddedProducts.Add(productToAdd);
            AvailableProducts.Remove(productToAdd);
            HasChanges = _orderRepository.HasChanges();
            ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged();
        }
Exemple #12
0
        public void CreateProductList()
        {
            Product product = new Product("Coca Cola", 15, "Beverage");

            AvailableProducts.Add(product);
            product = new Product("Fanta", 15, "Beverage");
            AvailableProducts.Add(product);
            product = new Product("Sprite", 15, "Beverage");
            AvailableProducts.Add(product);

            product = new Product("Salad", 99, "Food");
            AvailableProducts.Add(product);
            product = new Product("Sushi", 105, "Food");
            AvailableProducts.Add(product);
            product = new Product("Sandwich", 65, "Food");
            AvailableProducts.Add(product);

            product = new Product("Mars", 20, "Snack");
            AvailableProducts.Add(product);
            product = new Product("Snickers", 20, "Snack");
            AvailableProducts.Add(product);
            product = new Product("KitKat", 20, "Snack");
            AvailableProducts.Add(product);
        }
 /// <summary>
 /// Returns the view where a user can add products to their cart.
 /// </summary>
 public ActionResult Product()
 {
     List<DAL_Entity> entities = _dal.RetrieveEntities(new Inventory());
     AvailableProducts products = new AvailableProducts();
     foreach (var item in entities)
         if (item is Inventory)
             products.Products.Add((Inventory)item);
     return View(products);
 }