Пример #1
0
    public OrderDetails OrderItem(string userName, string password, int productID, int quantity)
    {
        // Login client using provided username and password
        IBuySpy.CustomersDB accountSystem = new IBuySpy.CustomersDB();
        String customerId = accountSystem.Login(userName, password);

        if (customerId == null)
        {
            throw new Exception("Error: Invalid Login!");
        }

        // Wrap in try/catch block to catch errors in the event that someone types in
        // an invalid value for quantity
        int qty = System.Math.Abs(quantity);

        if (qty == quantity && qty < 1000)
        {
            // Add Item to Shopping Cart
            IBuySpy.ShoppingCartDB myShoppingCart = new IBuySpy.ShoppingCartDB();
            myShoppingCart.AddItem(customerId, productID, qty);

            // Place Order
            IBuySpy.OrdersDB orderSystem = new IBuySpy.OrdersDB();
            int orderID = orderSystem.PlaceOrder(customerId, customerId);

            // Return OrderDetails
            return(orderSystem.GetOrderDetails(orderID, customerId));
        }
        else
        {
            // invalid input
            return(null);
        }
    }
Пример #2
0
    public OrderDetails CheckStatus(string userName, string password, int orderID)
    {
        // Login client using provided username and password
        IBuySpy.CustomersDB accountSystem = new IBuySpy.CustomersDB();
        String customerId = accountSystem.Login(userName, password);

        if (customerId == null)
        {
            throw new Exception("Error: Invalid Login!");
        }

        // Return OrderDetails Status for Specified Order
        IBuySpy.OrdersDB orderSystem = new IBuySpy.OrdersDB();
        return(orderSystem.GetOrderDetails(orderID, customerId));
    }