Esempio n. 1
0
        public static DatabaseSystem GetInstance()
        {
            if (ds == null)
            {
                ds = new DatabaseSystem();
            }

            return(ds);
        }
Esempio n. 2
0
        public List <Category> GetCategories()
        {
            List <Category> categories = new List <Category>();

            foreach (Product p in contents)
            {
                Category c = DatabaseSystem.GetInstance().
                             GetCategoryOfProduct(p.ProductID);
                if (!categories.Contains(c))
                {
                    categories.Add(c);
                }
            }

            return(categories);
        }
Esempio n. 3
0
        public Boolean Add(int productId, int quantity)
        {
            Product product = contents.FirstOrDefault(p => p.ProductID == productId);

            if (Object.Equals(product, null))
            {
                product = DatabaseSystem.GetInstance().GetProductForId(productId);
                contents.Add(new Product(product.ProductID, product.CategoryID,
                                         product.Title, product.ShortDescription, product.LongDescription, product.Price, quantity));
                numItems++;
                totalCost += product.Price * quantity;
            }
            else
            {
                product.Quantity += quantity;
                totalCost        += product.Price * quantity;
            }

            return(true);
        }