Exemple #1
0
        public void DecrementConsignment(int productId)
        {
            Consignment consignment = GetLatestConsignment(dataAccess.GetProductById(productId));

            if (consignment != null)
            {
                consignment.NumberOfContent--;
                dataAccess.EditConsignment(productId, consignment);
            }
            else
            {
                consignment = new Consignment(0, -1, DateTime.Now);
                dataAccess.AddConsigment(productId, consignment);
            }
        }
Exemple #2
0
        public bool ScanProduct(string barcode)
        {
            if (barcode.Equals(Properties.Settings.Default.ClearBasketBarcode))
            {
                ClearBasket();
                return(true);
            }

            IList <Product> products = dataAccess.Products;

            foreach (var product in products)
            {
                if (product.Barcode.Equals(barcode))
                {
                    Consignment consignment = GetLatestConsignment(product);
                    if (consignment == null)
                    {
                        consignment = new Consignment(0, 0, DateTime.Now, 0);
                        dataAccess.AddConsigment(product.Id, consignment);
                    }

                    consignment = GetLatestConsignment(dataAccess.GetProductById(product.Id));

                    double price = product.Price;
                    if (product.HasConsignmentPrice)
                    {
                        price = consignment.Price;
                    }
                    SaleProduct saleProduct = new SaleProduct(0, product.Id, product.Name, price, isBasketPaidByCreditCard, isBasketPrivate, isBasketForGuest, "", price);


                    BasketItem basketItem = new BasketItem(product, consignment, saleProduct);
                    basketItems.Add(basketItem);

                    DecrementConsignment(product.Id, consignment);

                    OnPropertyChanged("BasketTotal");
                    OnPropertyChanged("BasketItems");

                    return(true);
                }
            }

            return(HandleSettingsBarcode(barcode));
        }