Exemple #1
0
        public static Boolean Buy(string username, string productName, int quantity)
        {
            try {
                Product  p = StoreLogicData.GetProduct(productName);
                Customer c = StoreLogicData.GetCustomer(username);

                if (c.Buy(quantity * p.Price) && p.Buy(quantity))
                {
                    c.AddOrder(new Order(p.Name, quantity, p.Price * quantity));
                    return(true);
                }
                return(false);
            } catch (NullReferenceException) {
                return(false);
            }
        }
Exemple #2
0
 public static IEnumerable <Product> GetProducts()
 {
     return(StoreLogicData.GetProducts().Where(p => p.Stock > 0));
 }
Exemple #3
0
 public static double GetCustomerMoney(string username)
 {
     return(StoreLogicData.GetCustomer(username).Money);
 }
Exemple #4
0
 public static IEnumerable <Order> GetOrdersByUsername(string username)
 {
     return(StoreLogicData.GetCustomer(username).Orders);
 }
Exemple #5
0
 public static Boolean Register(Customer c)
 {
     return(StoreLogicData.AddCustomer(c));
 }