public void SaveProduct(IDataProduct product)
        {
            using DbRestaurantContext context = new DbRestaurantContext();
            var P_Products = new Products();

            // add BusinessLogic Customer to DbCustomer
            P_Products.ProductName = product.ProductName;
            P_Products.Cost        = product.Cost;


            context.Add(P_Products);
            context.SaveChanges();
        }
        public void SaveCustomer(ICustomer customer)
        {
            using DbRestaurantContext context = new DbRestaurantContext();
            var C_Customer = new Customers();

            // add BusinessLogic Customer to DbCustomer
            C_Customer.FullName = customer.FullName;
            C_Customer.Password = customer.Password;
            C_Customer.Username = customer.Username;


            context.Add(C_Customer);
            context.SaveChanges();
        }
Esempio n. 3
0
        public void SaveInventory(IDataInventory inventory, IDataProduct product, IDataStore store)
        {
            using DbRestaurantContext context = new DbRestaurantContext();
            var I_Inventory = new Inventorys();

            // add BusinessLogic Inventory to DbInventory
            I_Inventory.ProductId = product.ProductId;
            I_Inventory.StoreId   = store.StoreId;

            I_Inventory.Quantity = inventory.Quantity;


            context.Add(I_Inventory);
            context.SaveChanges();
        }
Esempio n. 4
0
        public void SaveStore(IDataStore store)
        {
            using DbRestaurantContext context = new DbRestaurantContext();
            var S_Stores = new Stores();

            // add BusinessLogic Store to DbStores
            S_Stores.StoreName     = store.StoreName;
            S_Stores.StreetAddress = store.StreetAddress;
            S_Stores.City          = store.City;
            S_Stores.State         = store.State;
            S_Stores.Zipcode       = store.Zipcode;


            context.Add(S_Stores);
            context.SaveChanges();
        }
        public void SaveOrder(Orders order, ICustomer customer, IDataStore store)
        {
            using DbRestaurantContext context = new DbRestaurantContext();
            var O_Orders = new Orders();

            // add BusinessLogic Order to DBOrders
            O_Orders.CustomerId = customer.CustomerId;
            O_Orders.StoreId    = store.StoreId;
            O_Orders.Total      = order.Total;

            O_Orders.TimeOrdered = DateTime.Now; // local time


            context.Add(O_Orders);
            context.SaveChanges();
        }
Esempio n. 6
0
        /*static void ShowOrderHistory(Store store)
         * {
         *
         * }*/

        static void AddOrder(Customer customer, Stores store)
        {
            // NOTE: REJECT ORDERLINE IF QUANTITY ORDERED IS MORE THAN QUANTITY IN INVENTORY
            // do a while loop to keep asking for customer to buy product
            Console.WriteLine("Add an order");
            Console.WriteLine("Your store has the following to choose from");



            var PDAL = new ProductDAL();
            var productIDsInStock = PDAL.LoadProductIDsFromStoreInStock(store); // need to load product ids for the specific store here

            // select products where productid matches one of the items(ids) in the list
            foreach (var productID in productIDsInStock)
            {
                var Product_products = PDAL.LoadProductByID(productID);

                //output list of products
                Console.WriteLine(Product_products.ProductId + " " + Product_products.ProductName + " " + Product_products.Cost);
            }
            var newOrder = new Orders();

            newOrder.Total      = 0;                   // need a value to do =+
            newOrder.StoreId    = store.StoreId;       // order has to be at a specific store. Store was selected above
            newOrder.CustomerId = customer.CustomerId; // order has to be placed by a customer. customer passed above

            using var ctx = new DbRestaurantContext();
            var ListOfallOrderIDs = from order in ctx.Orders select order.OrderId;
            var newOrderID        = ListOfallOrderIDs.Max() + 1;

            bool doneOrdering = false;

            using var context = new DbRestaurantContext();

            context.Orders.Add(newOrder);
            newOrder.TimeOrdered = DateTime.Now;
            context.SaveChanges();

            while (doneOrdering == false) // buy several products
            {
                Console.Write("Select from the above...");
                Console.WriteLine("For example: 7");
                var productIDChosen = Convert.ToInt32(Console.ReadLine());

                Console.WriteLine("How many would you like to buy?");
                int pQuantity = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Stop ordering? (y/n)");
                var yN = Console.ReadLine();
                if (yN == "y")
                {
                    doneOrdering = true;
                }
                // if input matches a product id TO BE IMPLEMENTED

                // get product details and add/pass that to the order
                var productToBeOrdered = PDAL.LoadProductByID(productIDChosen);



                var newOrderline = new Orderlines()
                {
                    ProductId = productIDChosen,
                    Quantity  = pQuantity,
                    OrderId   = newOrderID
                };

                newOrder.Total += productToBeOrdered.Cost * pQuantity;
                context.Orderlines.Add(newOrderline);
            }



            // Display total cost
            Console.WriteLine("Your order total is " + newOrder.Total);
            Console.WriteLine("Do you confirm the purchase? (y/n)");
            var input = Console.ReadLine();

            if (input == "y" || input == "Y")
            {
                //save order in db

                /*var oDAL = new OrderDAL();
                 * oDAL.SaveOrder(newOrder, customer, store);*/
                // put the order time

                context.SaveChanges();
            }
            else
            {
                Console.WriteLine("Order cancelled.");
                Console.WriteLine("You will not be charged");
                return;
            }
        }