Example #1
0
        // Adds Products to Database ****************************
        public static void AddProduct()
        {
            bool status = true;

            do
            {
                System.Console.WriteLine("\nPlease Enter The Product Name");
                string productName = Console.ReadLine();
                System.Console.WriteLine("\nPlease Enter The Product Price (ex. 1.99 or 10.99)");
                decimal productPrice = Convert.ToDecimal(Console.ReadLine());

                using (var context = new BalloonParty.Data.Entities.BalloonPartyContext())
                {
                    var newProduct = new BalloonParty.Data.Entities.Products {
                        ProductName  = productName,
                        ProductPrice = productPrice,
                    };
                    AddToInventory(productName);
                    context.Products.Add(newProduct);
                    context.SaveChanges();
                    System.Console.WriteLine($"Product : {newProduct} has been added\n\n");
                    System.Console.WriteLine("\nWould you like to add another product y/n");
                    string x = Console.ReadLine();
                    if (x == "n")
                    {
                        status = false;
                        adminInterface.adminMainMenu();
                    }
                }
                System.Console.Clear();
            } while(status);
        }
        // Adds Customer To Database ******************************
        public static void AddCustomer()
        {
            bool status = true;

            do
            {
                System.Console.WriteLine("\n\nPlease Enter Your Information\n");
                System.Console.WriteLine("First Name");
                string firstName = Console.ReadLine();

                System.Console.WriteLine("Last Name");
                string lastName = Console.ReadLine();

                System.Console.WriteLine("Email Address");
                string emailAddress = Console.ReadLine();

                System.Console.WriteLine("Password");
                string pw = Console.ReadLine();

                System.Console.WriteLine("Street Address (With Street Name)");
                string streetAddress = Console.ReadLine();

                System.Console.WriteLine("City");
                string cityName = Console.ReadLine();

                System.Console.WriteLine("State");
                string stateName = Console.ReadLine();

                System.Console.WriteLine("Zip Code");
                int zipCode = int.Parse(Console.ReadLine());

                using (var context = new BalloonParty.Data.Entities.BalloonPartyContext())
                {
                    var newCustomer = new BalloonParty.Data.Entities.Customer {
                        FirstName    = firstName,
                        LastName     = lastName,
                        EmailAddress = emailAddress,
                        CustomerPw   = pw,
                        Address      = streetAddress,
                        City         = cityName,
                        State        = stateName,
                        ZipCode      = zipCode,
                    };

                    context.Customer.Add(newCustomer);
                    context.SaveChanges();
                    System.Console.WriteLine($"Customer : {firstName} {lastName} has been stored to the database\n\n Returning to main menu");
                    System.Console.WriteLine("Would you like to add another customer y/n");
                    string x = Console.ReadLine();
                    if (x == "n")
                    {
                        status = false;
                        storeInterface.storeMainMenu();
                    }
                }
            }while(status);
        }
Example #3
0
 public static void AddToInventory(string productName)
 {
     using (var context = new BalloonParty.Data.Entities.BalloonPartyContext())
     {
         var inventoryObject = context.StoreInventory.First(c => c.ProductName == productName);
         inventoryObject.ProductCount = inventoryObject.ProductCount + 1;
         context.Update(inventoryObject);
         context.SaveChanges();
     }
 }
Example #4
0
 public static void SubtractFromInventory(int pID, int amount)
 {
     using (var context = new BalloonParty.Data.Entities.BalloonPartyContext())
     {
         var inventoryObject = context.StoreInventory.First(c => c.ProductId == pID);
         inventoryObject.ProductCount = inventoryObject.ProductCount - amount;
         context.Update(inventoryObject);
         context.SaveChanges();
     }
 }
        //  Place Customer Orders
        public static void PlaceOrder()
        {
            bool status = true;

            System.Console.WriteLine("Please enter your email address");
            string cEmail = Console.ReadLine();

            do
            {
                using (var context = new BalloonParty.Data.Entities.BalloonPartyContext())
                {
                    StoreData.ShowStores();
                    System.Console.WriteLine("Please select the cooresponding number of the store you would like to visit");
                    int customerChoice = int.Parse(Console.ReadLine());
                    System.Console.Clear();
                    ProductData.ShowInventory(customerChoice);
                    System.Console.WriteLine("Please enter the cooresponding number of the item you would like to purchase");
                    int input = int.Parse(Console.ReadLine());
                    System.Console.WriteLine("\nPlease Enter the quantity you would like to purchase");
                    int purchaseQuantity = int.Parse(Console.ReadLine());

                    var pPrice     = context.StoreInventory.First(pp => pp.ProductId == input).ProductPrice;
                    var pName      = context.StoreInventory.First(pn => pn.ProductId == input).ProductName;
                    var totalPrice = pPrice * purchaseQuantity;
                    var newOrder   = new BalloonParty.Data.Entities.CustomerOrders {
                        CustomerEmail    = cEmail,
                        FullProductCount = purchaseQuantity,
                        TotalPrice       = totalPrice,
                        ProductName      = pName,
                        OrderDate        = DateTime.Now,
                    };
                    context.CustomerOrders.Add(newOrder);
                    context.SaveChanges();
                    System.Console.WriteLine($"\n Your order has been submitted: {pName}: Quantity {purchaseQuantity}: Total Price ${totalPrice}");
                    System.Console.WriteLine("\nWould you like to place another order from the same store, y/n , no will bring you back to the main menu");
                    string userInput = Console.ReadLine();
                    if (userInput == "n")
                    {
                        System.Console.Clear();
                        status = false;
                        userInterface.userMainMenu();
                    }
                }
            }while(status);
        }
Example #6
0
        // This allows a store to order products for their store from the warehouse ******************************
        public static void OrderProducts()
        {
            StoreData.ShowStores();
            System.Console.WriteLine("Please enter your Store Number");
            int storeID = int.Parse(Console.ReadLine());

            System.Console.Clear();
            ShowProducts();
            bool status = true;

            do
            {
                using (var context = new BalloonParty.Data.Entities.BalloonPartyContext())
                {
                    System.Console.WriteLine("\nPlease enter the cooresponding number of the item you would like to order");
                    int input = int.Parse(Console.ReadLine());
                    System.Console.WriteLine("\nPlese enter the ammount you would like in your inventory");
                    int amount = int.Parse(Console.ReadLine());

                    string  pName      = context.Products.First(p => p.ProductId == input).ProductName;
                    int     pID        = context.Products.First(p => p.ProductId == input).ProductId;
                    int     sID        = context.Store.First(s => s.StoreId == input).StoreId;
                    decimal pPrice     = context.Products.First(pr => pr.ProductId == input).ProductPrice;
                    var     addProduct = new BalloonParty.Data.Entities.StoreInventory {
                        StoreId      = sID,
                        ProductId    = pID,
                        ProductName  = pName,
                        ProductCount = amount,
                        ProductPrice = pPrice,
                    };
                    SubtractFromInventory(pID, amount);
                    context.StoreInventory.Add(addProduct);
                    context.SaveChanges();
                    System.Console.WriteLine("\nWould You Like to Add More Product to Your Store  y/n");
                    string answer = Console.ReadLine();
                    if (answer == "n")
                    {
                        System.Console.Clear();
                        status = false;
                        storeInterface.storeMainMenu();
                    }
                    System.Console.Clear();
                }
            }while(status);
        }
Example #7
0
        // Adds Store to Database ******************************
        public static void AddStore()
        {
            bool status = true;

            do
            {
                System.Console.WriteLine("Please Enter Your Store Name");
                string storeName = Console.ReadLine();
                System.Console.WriteLine("Please Enter Your Store Street Address");
                string storeAddress = Console.ReadLine();
                System.Console.WriteLine("Please Enter The City");
                string storeCity = Console.ReadLine();
                System.Console.WriteLine("Please Enter The State");
                string storeState = Console.ReadLine();
                System.Console.WriteLine("Please Enter The Zip Code");
                int storeZipCode = int.Parse(Console.ReadLine());


                using (var context = new BalloonParty.Data.Entities.BalloonPartyContext())
                {
                    var newStore = new BalloonParty.Data.Entities.Store {
                        StoreName = storeName,
                        Address   = storeAddress,
                        City      = storeCity,
                        State     = storeState,
                        ZipCode   = storeZipCode,
                    };

                    context.Store.Add(newStore);
                    context.SaveChanges();
                    System.Console.WriteLine($"Store : {storeName} has been added");
                    System.Console.WriteLine("Would you like to add another store y/n");
                    string x = Console.ReadLine();
                    if (x == "n")
                    {
                        System.Console.Clear();
                        status = false;
                        adminInterface.adminMainMenu();
                    }
                }
            } while(status);
        }