public static void PrintCustomers(RestaurantAfrikContext ctx, List <Customers> Customer) { foreach (var item in Customer) { Console.WriteLine($"{item.CustomerId} \n{item.FirstName} {item.LastName} \n{item.Address} {item.Phone} {item.City} {item.State} {item.Zipcode} "); } }
public static void addFoodType(RestaurantAfrikContext ctx) { string searchFood = Console.ReadLine(); var foodItem = from Foods in ctx.Foods where Foods.Name == searchFood select Foods; Console.WriteLine("Choose the foodtype you will like to order: "); var allFoodType = foodItem.ToList(); foreach (var items in allFoodType) { Console.WriteLine(items.FoodId + items.Name + "\t" + items.Price); } var foodchoice = Console.ReadLine().ToUpper(); if (foodchoice == "ADD") { FoodType.addFoodType(ctx); } else if (foodchoice != null) { Console.WriteLine($"You Chose + {foodchoice}"); } else { Console.WriteLine("Please we do not have that particular item in stock"); } }
//Searches orders by given param, param is checked against Order columns according to mode //Mode Codes: // 1: Get orders by location // 2: By customer // 3: Get details of 1 specific order public async Task <List <Orders> > GetOrders(int mode = 0, params string[] search_param) { var orderList = context.Orders.Include("StoreLoc").Include("Customer").AsQueryable(); using (var context = new RestaurantAfrikContext()) { switch (mode) { case 1: orderList = orderList .Where(o => o.Store.Name == search_param[0]); break; case 2: orderList = orderList .Where(o => o.Customer.FirstName == search_param[0] && o.Customer.LastName == search_param[1]); break; case 3: orderList = orderList .Where(o => o.OrderId == Convert.ToInt32(search_param[0])); break; default: break; } } return(await orderList .Include("OrderFoods") .Include("OrderFoods.F") .Include("OrderFoods.F.F") .ToListAsync()); }
public static void addnewCustomer(RestaurantAfrikContext ctx) { Customers newCustomer = new Customers(); Console.Write("Please enter your first name: "); newCustomer.FirstName = Console.ReadLine(); Console.Write("Ok, now enter your last name: "); newCustomer.LastName = Console.ReadLine(); Console.WriteLine(); Console.Write("What is your address: ? "); newCustomer.Address = Console.ReadLine(); Console.Write("Enter phone: "); newCustomer.Phone = System.Console.ReadLine(); for (int t = 3; t >= 0; t--) { Console.Write("Enter phone: "); string phone = System.Console.ReadLine(); try { long.Parse(phone); } catch (FormatException) { Console.WriteLine("Invalid Input"); continue; } if (t == 0) { return; } if (phone.Length != 10) //(x > 10 || x < 10) { System.Console.WriteLine("Invalid input. You have " + t + " tries left."); continue; } if (t == 0) { Console.WriteLine("You have reached the maximum limit. Please restart application"); return; } ctx.Customers.Add(newCustomer); ctx.SaveChanges(); Thread.Sleep(2000); break; } }
public static void Orderfood(RestaurantAfrikContext ctx) { Console.WriteLine("Choose what you want to buy from the FoodTypes"); int uInput = int.Parse(Console.ReadLine()); int Foodchoice = Convert.ToInt32(Console.ReadLine()); var FoodId = from Food in ctx.Foods where Food.FoodId == Foodchoice select Food.FoodId; //var FoodsId = ctx.Foods.First(schoice); }
public static void mainMenuPrompt(RestaurantAfrikContext ctx, Customers customer) { while (true) { Console.WriteLine("Choose from the following options: "); Console.WriteLine("\t1) Select from Customer List"); Console.WriteLine("\t2) Add Customer"); Console.WriteLine("\t3) Show Stores"); Console.WriteLine("\t4) Will you like to make an order"); Console.WriteLine("\t5) Print order history"); Console.WriteLine("\t6) Close"); int uInput = 0; while (true) { try { uInput = int.Parse(Console.ReadLine()); break; } catch (Exception) { Console.WriteLine("Invalid input. Please try again"); } } switch (uInput) { case 1: Customer.SearchCustomer(ctx); break; case 2: Console.WriteLine("Would you like to Register"); Customer.addnewCustomer(ctx); break; case 3: tableStores.showStores(ctx); break; case 4: MakeOrders.PlaceOrder(customer); break; case 5: MakeOrders.displayOrders(); break; default: break; } } }
public static void showStores(RestaurantAfrikContext ctx) { List <StoreLoc> listStores = ctx.StoreLoc.ToList(); foreach (var item in listStores) { Console.WriteLine($" {item.StoreId} {item.Name} {item.Phone} {item.Email} {item.Street} {item.City} {item.State} {item.ZipCode} "); } Console.WriteLine("What store will you like to order from"); Console.ReadLine(); }
public static void showFoodTypes(RestaurantAfrikContext ctx) { List <Foods> FoodTypes = ctx.Foods.ToList(); foreach (var item in FoodTypes) { Console.WriteLine($"{item.FoodId} {item.Name} {item.Price}"); } Console.WriteLine("What would you like to order"); Console.ReadLine(); }
public static void SearchCustomer(RestaurantAfrikContext ctx) { DisplayCustomers(ctx); Console.WriteLine("Enter your first name: "); string firstName = Console.ReadLine(); Console.WriteLine("Enter your last name: "); string lastName = Console.ReadLine(); var custList = ctx.Customers.Where(cust => cust.FirstName == firstName && cust.LastName == lastName).ToList(); PrintCustomers(ctx, custList); }
public static void displayOrders() { Console.WriteLine("Enter the Id of Customer to display orders"); int input = int.Parse(Console.ReadLine()); using var context = new RestaurantAfrikContext(); var orderHistory = context.Orders.Where(order => order.CustomerId == input); foreach (var order in orderHistory) { Console.WriteLine($"CustomerID:{order.CustomerId} " + $"\nFoodID:{order.FoodId} " + $"\nFood Name:{order.Name} \nStoreID: {order.StoreId} Price: ${order.Price} \nDate.Time { DateTime.Now}"); } }
public static void CustomerLogin(RestaurantAfrikContext ctx) { Console.Write("Please Enter Username: "******"Now Please Enter your Password: "******"\n If no one is looking at your device"); Console.WriteLine("I will confirm the password you just gave"); Console.WriteLine("All your inputs will disappear in 3 seconds"); Console.WriteLine("\n Press any key to see it now"); Console.WriteLine("\n If your password does not match try again"); Console.ReadKey(true); Console.Write("\nThe password you entered is :" + password); Thread.Sleep(1000); Console.Clear(); Console.ReadKey(true); }
public static Customers CustomerReadPassword(RestaurantAfrikContext ctx) { Console.WriteLine("Provide a valid application domain account. [domain\\user]"); Console.WriteLine(" Enter username:"******" Enter password:"******""; ConsoleKeyInfo info = Console.ReadKey(true); while (info.Key != ConsoleKey.Enter) { if (info.Key != ConsoleKey.Backspace) { password += info.KeyChar; info = Console.ReadKey(true); } else if (info.Key == ConsoleKey.Backspace) { if (!string.IsNullOrEmpty(password)) { password = password.Substring (0, password.Length - 1); } info = Console.ReadKey(true); } } for (int i = 0; i < password.Length; i++) { Console.Write("*"); } // get customer that matches username above using var context = new RestaurantAfrikContext(); return(context.Customers.First(x => x.FirstName == username)); // returns the customer that matches username on its firstname column }
public static void PreferredStore(RestaurantAfrikContext ctx) { Console.WriteLine("Choose from a store: "); List <StoreLoc> allStores = ctx.StoreLoc.ToList(); foreach (var items in allStores) { Console.WriteLine(items.StoreId + items.Name + "\t" + items.State); } var choseStore = Console.ReadLine().ToLower(); if (choseStore == "addS") { tableStores.addStores(ctx); } else if (choseStore != null) { Console.WriteLine($"You Chose + {choseStore}"); } else { Console.WriteLine("I apologize that store does not exist"); } }
public static void PlaceOrder(Customers customer) { int customerID = customer.CustomerId; Console.WriteLine("Enter your preferred Restaurant"); using var context = new RestaurantAfrikContext(); var storeList = context.StoreLoc.ToList(); foreach (var store in storeList) { Console.WriteLine(store.StoreId + " " + store.Name); } int storeid = int.Parse(Console.ReadLine()); /*if (custinput == "1" || custinput == "2") * { * int storeId = int.Parse(custinput); * using (var ctx = new RestaurantAfrikContext()) * { * var Store = (from s in ctx.StoreLoc * where s.StoreId == storeId * select s).SingleOrDefault(); * * } * }*/ Startorder: Console.WriteLine("Select the foodtype you will like to order"); var foodtypes = context.Foods.ToList(); foreach (var foods in foodtypes) { Console.WriteLine(foods.FoodId + " " + foods.Name); } int input = int.Parse(Console.ReadLine()); Console.WriteLine(); Console.WriteLine("Please Enter your desired food quantity"); var food = context.Foods.Find(input); int qty = int.Parse(Console.ReadLine()); var new_order = new Orders { FoodId = input, Price = qty * food.Price, Name = food.Name, OrderTime = DateTime.Now, StoreId = storeid, CustomerId = customer.CustomerId }; Console.WriteLine($"You ordered {qty} {food.Name}"); Console.WriteLine("Is this order correct y/n"); var response = Console.ReadLine().ToLower(); while (response != "y" && response != "n") { Console.WriteLine("Input y or n"); response = Console.ReadLine(); if (response == "y") { context.Orders.Add(new_order); context.SaveChanges(); } else if (response == "n") { goto Startorder; } } }
public static void DisplayCustomers(RestaurantAfrikContext ctx) { var custList = ctx.Customers.ToList(); PrintCustomers(ctx, custList); }
public StoreLocsController(RestaurantAfrikContext context) { _context = context; }
public static void addStores(RestaurantAfrikContext ctx) { Console.WriteLine("Enter your preferred location"); var StoreLoc = Console.ReadLine(); }
public OrdersController(RestaurantAfrikContext context) { _context = context; }