public void GetOrderDetailTest() { //Arrange var options = new DbContextOptionsBuilder <StoreAppContext>() .UseInMemoryDatabase(databaseName: "GetOrderDetailTest") .Options; //Act using (var db = new StoreAppContext(options)) { Store location = new Store { Location = "Maryland" }; db.Add(location); db.SaveChanges(); Customer customer = new Customer { FirstName = "Michael", LastName = "Hall", UserName = "******", Password = "******" }; db.Add(customer); db.SaveChanges(); Product product = new Product { StoreId = 1, ProductName = "bar", Inventory = 5, Price = 10 }; db.Add(product); db.SaveChanges(); Order order = new Order { CustomerId = 1, ProductId = 1, Quantity = 3, }; db.Add(order); db.SaveChanges(); } //Assert using (var context = new StoreAppContext(options)) { var repo = new OrderRepo(); var orderTest = repo.GetOrderDetails(context, 1); Assert.Equal(1, orderTest.Id); } }
public void MarkShipped(long id) { Order order = context.Orders.Find(id); if (order != null) { order.Shipped = true; context.SaveChanges(); } }
public IActionResult CreateSupplier([FromBody] SupplierData sdata) { if (ModelState.IsValid) { Supplier s = sdata.Supplier; context.Add(s); context.SaveChanges(); return(Ok(s.SupplierId)); } else { return(BadRequest(ModelState)); } }
public void UpdateInventoryTest() { //Arrange var options = new DbContextOptionsBuilder <StoreAppContext>() .UseInMemoryDatabase(databaseName: "UpdateInventoryTest") .Options; //Act using (var db = new StoreAppContext(options)) { Product product = new Product { StoreId = 1, ProductName = "bar", Inventory = 5, Price = 10 }; db.Add(product); db.SaveChanges(); } //Assert using (var context = new StoreAppContext(options)) { var repo = new ProductRepo(); var product1 = context.Products.Where(p => p.StoreId == 1).FirstOrDefault(); Assert.Equal(5, product1.Inventory); repo.UpdateInventory(context, 1, 3); Assert.Equal(2, product1.Inventory); } }
[Fact]//the name of the function should tell the user what the function is doing public void CreateCustomerSavesANewPlayerToTheDb() { // arrange // Creating the in-memory Db var options = new DbContextOptionsBuilder <StoreAppContext>() .UseInMemoryDatabase(databaseName: "TestDb").Options; // act // add to the In-memory Db Customer p1 = new Customer(); using (var context = new StoreAppContext(options)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); StoreAppRepsitoryLayer repo = new StoreAppRepsitoryLayer(context); p1 = repo.CreateCustomer("sparky", "jones"); context.SaveChanges(); } // assert // verify the results was as expected using (var context = new StoreAppContext(options)) { StoreAppRepsitoryLayer repo = new StoreAppRepsitoryLayer(context); Customer result = repo.CreateCustomer("sparky", "jones"); Assert.True(p1.Customer_Id.Equals(result.Customer_Id)); } }
public void GetInventoryTest() { //Arrange var options = new DbContextOptionsBuilder <StoreAppContext>() .UseInMemoryDatabase(databaseName: "GetInventoryTest") .Options; //Act using (var db = new StoreAppContext(options)) { Product product = new Product { StoreId = 1, ProductName = "bar", Inventory = 5, Price = 10 }; db.Add(product); db.SaveChanges(); } //Assert using (var context = new StoreAppContext(options)) { var repo = new ProductRepo(); int inventory = repo.GetInventory(context, 1); Assert.Equal(5, inventory); } }
public void GetOrdersTest() { //Arrange var options = new DbContextOptionsBuilder <StoreAppContext>() .UseInMemoryDatabase(databaseName: "GetOrdersTest") .Options; //Act using (var db = new StoreAppContext(options)) { Order location = new Order { CustomerId = 5, ProductId = 10, Quantity = 3, }; db.Add(location); db.SaveChanges(); } //Assert using (var context = new StoreAppContext(options)) { var repo = new OrderRepo(); var orders = repo.GetOrders(context); Assert.Equal(1, orders.Count()); var order1 = context.Orders.Where(o => o.Id == 1).FirstOrDefault(); Assert.Equal(1, order1.Id); Assert.Equal(5, order1.CustomerId); Assert.Equal(10, order1.ProductId); Assert.Equal(3, order1.Quantity); } }
public void AddsProductToDbTest() { //Arrange var options = new DbContextOptionsBuilder <StoreAppContext>() .UseInMemoryDatabase(databaseName: "AddsProductToDbTest") .Options; //Act using (var db = new StoreAppContext(options)) { Product bar = new Product { StoreId = 7, ProductName = "bar", Inventory = 5, Price = 10 }; db.Add(bar); db.SaveChanges(); } //Assert using (var context = new StoreAppContext(options)) { Assert.Equal(1, context.Products.Count()); var product1 = context.Products.Where(p => p.StoreId == 7).FirstOrDefault(); Assert.Equal(7, product1.StoreId); Assert.Equal(1, product1.Id); } }
public void AddsCustomerToDbTest() { //Arrange var options = new DbContextOptionsBuilder <StoreAppContext>() .UseInMemoryDatabase(databaseName: "AddsCustomerToDbTest") .Options; //Act using (var db = new StoreAppContext(options)) { Customer location = new Customer { FirstName = "Michael", LastName = "Hall", UserName = "******", Password = "******" }; db.Add(location); db.SaveChanges(); } //Assert using (var context = new StoreAppContext(options)) { Assert.Equal(1, context.Customers.Count()); var customer1 = context.Customers.Where(c => c.Id == 1).FirstOrDefault(); Assert.Equal(1, customer1.Id); Assert.Equal("Michael", customer1.FirstName); Assert.Equal("Hall", customer1.LastName); Assert.Equal("mbhall", customer1.UserName); Assert.Equal("yes", customer1.Password); } }
public void GetStoresTest() { //Arrange var options = new DbContextOptionsBuilder <StoreAppContext>() .UseInMemoryDatabase(databaseName: "GetStoresTest") .Options; //Act using (var db = new StoreAppContext(options)) { Store location = new Store { Location = "Maryland" }; db.Add(location); db.SaveChanges(); } //Assert using (var context = new StoreAppContext(options)) { var repo = new StoreRepo(); var products = repo.GetStores(context); Assert.Equal(1, products.Count()); var store1 = context.Stores.Where(s => s.Id == 1).FirstOrDefault(); Assert.Equal(1, store1.Id); Assert.Equal("Maryland", store1.Location); } }
/// <summary> /// Updates the inventory for a particular product /// based on the quantity that a recent order has purchased /// </summary> /// <param name="context"></param> /// <param name="id"></param> /// <param name="quant"></param> public void UpdateInventory(StoreAppContext context, int id, int quant) { var product = context.Products .Where(p => p.Id == id) .FirstOrDefault(); product.Inventory -= quant; context.SaveChanges(); }
public void AgregarTienda(SucursalDto sucursal) { var store = _context.Sucursal.Add(new Sucursal() { Nombre = sucursal.Nombre }); _context.SaveChanges(); }
public void PlaceOrder(Order LogicOrder, StoreAppContext context) { try { context.Orders.Add(parser.LogicOrderToContextOrder(LogicOrder)); context.SaveChanges(); } catch (Microsoft.EntityFrameworkCore.DbUpdateException e) { Console.WriteLine("Something went wrong inputting order: " + e); } }
/// <summary> /// Adds new order products and details to database /// </summary> /// <param name="order">Library Order object containing relevant order info</param> /// <returns>True if order added succesfully false if otherwise</returns> public bool AddNewOrder(Order order) { using var context = new StoreAppContext(_contextOptions); if (order != null) { var dbOrder = new OrderDetail() { CustomerId = order.GetCustomerId, LocationId = order.GetStoreId, Date = order.GetTime, Total = order.GetTotal }; context.OrderDetails.Add(dbOrder); context.SaveChanges(); foreach (var product in order.GetOrderItems) { var dbOrderProduct = new OrderProduct() { OrderId = dbOrder.Id, ProductId = product.Key, Quantity = product.Value }; context.OrderProducts.Add(dbOrderProduct); } context.SaveChanges(); return(true); } else { throw new ArgumentNullException(); } }
public void GetProductDataTest() { //Arrange var options = new DbContextOptionsBuilder <StoreAppContext>() .UseInMemoryDatabase(databaseName: "GetProductDataTest") .Options; //Act using (var db = new StoreAppContext(options)) { Store location = new Store { Location = "Maryland" }; db.Add(location); db.SaveChanges(); Product product = new Product { StoreId = 1, ProductName = "bar", Inventory = 5, Price = 10 }; db.Add(product); db.SaveChanges(); } //Assert using (var context = new StoreAppContext(options)) { var repo = new ProductRepo(); var product1 = repo.GetProductData(context); } }
public void AddNewCustomer(Logic.Customer LogicCustomer, StoreAppContext context) { //Some code to input customer data to the DB try { //SaveChanges is needed to persist the data context.Customer.Add(parser.LogicCustomerToContextCustomer(LogicCustomer)); context.SaveChanges(); } catch (Exception e) { Console.WriteLine("Failed to put the customer into the database: " + e.Message); } }
/// <summary> /// Adds new customer to database /// </summary> /// <param name="customer">Customer object of customer to add to database</param> /// <returns>True if customer added succesfully and false if customer already exists in database</returns> public bool AddNewCustomer(Customer customer) { using var context = new StoreAppContext(_contextOptions); var dbCustomer = new CustomerTable() { FirstName = customer.CustomerFirstName, LastName = customer.CustomerLastName, Phone = customer.PhoneNumber }; if (GetCustomerByFirstAndLastName(customer.CustomerFirstName, customer.CustomerLastName) == null) { context.CustomerTables.Add(dbCustomer); context.SaveChanges(); return(true); } return(false); }
/// <summary> /// updates store inventory in database /// </summary> /// <param name="storeId"> Target store id</param> /// <param name="items">Dictionary containing all order items with product id as key and quantity as value</param> /// <returns></returns> public bool PlaceOrder(int storeId, Dictionary <int, int> items) { Store store = GetStoreById(storeId); if (store != null) { using var context = new StoreAppContext(_contextOptions); foreach (var item in items) { var dbStore = context.Inventories.First(i => i.LocationId == storeId && i.ProductId == item.Key); dbStore.Stock = dbStore.Stock - item.Value; context.SaveChanges(); } return(true); } else { return(false); } }
public void SearchLastNameTest() { //Arrange var options = new DbContextOptionsBuilder <StoreAppContext>() .UseInMemoryDatabase(databaseName: "SearchLastNameTest") .Options; //Act using (var db = new StoreAppContext(options)) { Customer location = new Customer { FirstName = "Michael", LastName = "Hall", UserName = "******", Password = "******" }; db.Add(location); db.SaveChanges(); } //Assert using (var context = new StoreAppContext(options)) { var repo = new CustomerRepo(); var customers = repo.GetCustomers(context); var filter = repo.SearchLastName(customers, "Ha"); Assert.Equal(1, filter.Count()); var customer1 = filter.Where(c => c.Id == 1).FirstOrDefault(); Assert.Equal(1, customer1.Id); Assert.Equal("Michael", customer1.FirstName); Assert.Equal("Hall", customer1.LastName); Assert.Equal("mbhall", customer1.UserName); Assert.Equal("yes", customer1.Password); } }
public static void CustomerMenu(StoreAppContext context, int cust) { Logic.Customer newCust = new Logic.Customer(); GetDataHandler getDBHandler = new GetDataHandler(); InputDBHandler Inputhandler = new InputDBHandler(); Logic.Customer getCustomer = new Logic.Customer(); Logic.Store getStore = new Logic.Store(); Logic.Order order = new Logic.Order(); Logic.Product items = new Logic.Product(); List <Order> orderList = new List <Order>(); string username = null; string userInput; bool customerMenu = true; bool nextMenu = false; switch (cust) { /// <summary> /// Sign Up New Account /// </summary> case 1: while (customerMenu) { if (newCust.IsCustomerNotNull() == false) { if (newCust.userName == null) { Console.WriteLine("What is your username"); newCust.userName = Console.ReadLine(); /// <summary> /// Check Username To Make Sure It's not Existing /// </summary> var check = getDBHandler.GetCustomerDataFromUsername(newCust.userName, context); if (check != null) { Console.WriteLine("Username Existing. Choose another one"); newCust.userName = Console.ReadLine(); } } else if (newCust.firstName == null) { Console.WriteLine("What is your first name?"); newCust.firstName = Console.ReadLine(); } else if (newCust.lastName == null) { Console.WriteLine("What is your last name?"); newCust.lastName = Console.ReadLine(); } else if (newCust.customerAddress.IsAddressNotNull() == false) { Console.WriteLine("What is your address?"); newCust.customerAddress.street = Console.ReadLine(); Console.WriteLine("Please enter a city"); newCust.customerAddress.city = Console.ReadLine(); Console.WriteLine("Please enter a state"); newCust.customerAddress.state = Console.ReadLine(); Console.WriteLine("Please enter a zip"); newCust.customerAddress.zip = Console.ReadLine(); } } else { /// <summary> /// Insert New Account Into DB /// </summary> try { Console.WriteLine("1.Yes 2.No"); userInput = UserChoiceHandler.UserOptionHandler(Int32.Parse(Console.ReadLine()), 2); Console.WriteLine("Added New Customer Successfully! Welcome, " + newCust.firstName + " " + newCust.lastName); Inputhandler.AddNewCustomer(newCust, context); Console.WriteLine("Please Login With Your Username To Continue"); CustomerMenu(context, 2); break; } catch (Exception e) { Console.WriteLine("Unknown exception thrown: " + e); } } } nextMenu = true; //resets menu true to go into next menu cust = 2; break; /// <summary> /// Logging Int User Account /// </summary> case 2: while (customerMenu) { Console.WriteLine("What is your username?"); username = Console.ReadLine(); if (getDBHandler.UsernameParser(username, context) == false) { Console.WriteLine("Your UserName is Incorrect. Please Try It Again"); break; } else { try { /// <summary> /// Get Customer Information From Logic.Customer /// </summary> getCustomer = getDBHandler.GetCustomerDataFromUsername(username, context); Console.WriteLine("Welcome " + getCustomer.firstName + " " + getCustomer.lastName); nextMenu = true; } catch (NullReferenceException e) { Console.WriteLine("NULL Error " + username + ": " + e.Message + "\n"); Log.Error("Null Value"); } catch (Exception e) { Console.WriteLine("Unknown exeption " + e); Log.Error("Unknown Error"); } } customerMenu = false; //resets menu true to go into next menu } break; } while (nextMenu) { Console.WriteLine("1. Place order\n2. View your order history\n3. Stop"); userInput = UserChoiceHandler.UserOptionHandler(Int32.Parse(Console.ReadLine()), 3); switch (userInput) { /// <summary> /// Place An Order /// </summary> case "1": Console.WriteLine("What is your favorite store?\n1.Arlington \n5.Houston"); string store = Console.ReadLine(); if (getDBHandler.CheckIDParsable(Int32.Parse(store)) == false) { Console.WriteLine("Please Choice Either 1 or 2"); break; } else //if the input only has numbers in it { int storeId = Int32.Parse(store); /// <summary> /// Display Store Information Retrieved From DB /// </summary> try { getStore = getDBHandler.GetStoreFromStoreId(storeId, context); Console.WriteLine("Store Address {0}, {1}, {2}, {3}", getStore.address.street, getStore.address.city, getStore.address.state, getStore.address.zip); Console.WriteLine("Ariel: {0}, Downie: {1}, Suavitel: {2}", getStore.storeInventory.items.NumberofAriel, getStore.storeInventory.items.NumberofDownie, getStore.storeInventory.items.NumberofSuavitel); bool decided = false; int ariel; int downie; int suavitel; while (!decided) { try { Console.WriteLine("Ariel:"); string input = Console.ReadLine(); ariel = Int32.Parse(input); Console.WriteLine("Downie:"); input = Console.ReadLine(); downie = Int32.Parse(input); Console.WriteLine("Suavitels"); input = Console.ReadLine(); suavitel = Int32.Parse(input); Console.WriteLine("You have an order of Ariel: {0} || Downie: {1} || Suavitel: {2}", ariel, downie, suavitel); Console.WriteLine("1.Yes 2.No"); userInput = UserChoiceHandler.UserOptionHandler(Int32.Parse(Console.ReadLine()), 2); if (userInput == "1") { decided = true; Console.WriteLine(". . .\n"); if (ariel > getStore.storeInventory.items.NumberofAriel || downie > getStore.storeInventory.items.NumberofDownie || suavitel > getStore.storeInventory.items.NumberofSuavitel) { Console.WriteLine("Not Enough--Available: "); Console.WriteLine("Ariel: {0} || Downie: {1} || Suavitel: {2}", getStore.storeInventory.items.NumberofAriel.ToString(), getStore.storeInventory.items.NumberofDownie.ToString(), getStore.storeInventory.items.NumberofSuavitel.ToString()); decided = false; } else { order = new Logic.Order(); //uses input handler to input order into DB var entityStore = context.Store.FirstOrDefault(i => i.StoreId == Int32.Parse(store)); if (entityStore != null) { order.customer = getCustomer; order.cartItems.NumberofAriel = ariel; order.cartItems.NumberofDownie = downie; order.cartItems.NumberofSuavitel = suavitel; order.ordererAddress = getCustomer.customerAddress; order.PlaceOrderTime(); /// <summary> /// Update Products' Quantities /// </summary> entityStore.Ariel -= ariel; entityStore.Downie -= downie; entityStore.Suavitel -= suavitel; order.storeLocation.address = getStore.address; order.storeLocation.storeInventory = getStore.storeInventory; order.storeLocation.storeId = getStore.storeId; } context.Store.Update(entityStore); context.SaveChanges(); try { /// <summary> /// Placed Order Successfully /// </summary> Inputhandler.PlaceOrder(order, context); nextMenu = false; Console.WriteLine("Order successfully created! Thank you for your business!\nReturning back to customer menue"); } catch (Exception e) { Console.WriteLine("Unable to perform the operation: \n" + e); Log.Error("Exception Error"); } } } else if (userInput == "2") { Console.WriteLine("Please make a new order again"); } else { Console.WriteLine("Invalid input, please type one of the following options."); Log.Error("Null Value"); } } catch (Exception e) { Console.WriteLine("Please Enter NUMBER ONLY."); Log.Error("Non Numerical Error"); } } nextMenu = true; break; } catch (Exception e) { Console.WriteLine("Error finding store with input ID: \n"); } } break; /// <summary> /// Display Order History of The customer /// </summary> case "2": var enityOrder = context.Orders.Where(user => user.CustomerId == getCustomer.customerId).ToList(); string storeInfo; foreach (var row in enityOrder) { if (row.StoreId == 1) { storeInfo = "Arlington,TX"; } else { storeInfo = "Houston, TX"; } Console.WriteLine("Your Order Id: {0} Store Location: {1}", row.OrderId, storeInfo); Console.WriteLine("Ariel: {0}, \nDownie: {1} \nSuavitel: {2}", row.Ariel, row.Downie, row.Suavitel); Console.WriteLine(); } break; case "3": Console.Clear(); Console.WriteLine("See You Later"); Environment.Exit(0); break; default: //error handling Log.Error("Invalid Input"); break; } } }
public virtual void Commit() { _context.SaveChanges(); }
public static void ManagerMenu(StoreAppContext context, int manager) { Logic.Customer newCust = new Logic.Customer(); GetDataHandler getDBHandler = new GetDataHandler(); InputDBHandler Inputhandler = new InputDBHandler(); Logic.Customer getCustomer = new Logic.Customer(); Logic.Store getStore = new Logic.Store(); Logic.Order order = new Logic.Order(); Logic.Product items = new Logic.Product(); List <Order> orderList = new List <Order>(); bool managerMenu = true; bool nextMenu = false; while (managerMenu) { switch (manager) { /// <summary> /// View Orders History of A Store /// </summary> case 1: Console.WriteLine("Please Choose A Store:"); Console.WriteLine("1. Arlington,TX\n5. Houston,TX\n3. Exit"); int storeId = Int32.Parse(Console.ReadLine()); if (storeId == 3) { Console.WriteLine("Manager's Options:"); Console.WriteLine("1. View Order History Of A Store\n2. Add New Items To Stores\n3. Switch To Customer Menu \n4. Stop"); manager = Int32.Parse(Console.ReadLine()); } nextMenu = true; while (nextMenu) { try { getStore = getDBHandler.GetStoreFromStoreId(storeId, context); Console.WriteLine("Store Address {0}, {1}, {2}, {3}", getStore.address.street, getStore.address.city, getStore.address.state, getStore.address.zip); Console.WriteLine("Ariel: {0}, Downie: {1}, Suavitel: {2}", getStore.storeInventory.items.NumberofAriel, getStore.storeInventory.items.NumberofDownie, getStore.storeInventory.items.NumberofSuavitel); var enityOrder = context.Orders.Where(order => order.StoreId == storeId).ToList(); foreach (var row in enityOrder) { var cust = getDBHandler.GetCustomerDataFromID(row.CustomerId, context); Console.WriteLine("------------------------------------------------------------"); Console.WriteLine("Order Id: {0} \nCustomer Id: {1}", row.OrderId, row.CustomerId); Console.WriteLine("Customer Name: " + cust.firstName + " " + cust.lastName); Console.WriteLine("Ariel: {0}, \nDownie: {1} \nSuavitel: {2}", row.Ariel, row.Downie, row.Suavitel); Console.WriteLine(); } nextMenu = false; Console.WriteLine("Manager's Options:"); Console.WriteLine("1. View Order History Of A Store\n2. Add New Items To Stores\n3. Search User Information By Name \n4. Exit Main Menu \n5.Stop"); manager = Int32.Parse(Console.ReadLine()); } catch (Exception e) { Console.WriteLine("Error finding store with input store"); //error handling Log.Warning("Invalid Store ID"); break; } } break; /// <summary> /// Add new Items /// </summary> case 2: Console.WriteLine("Please Choose A Store:"); Console.WriteLine("1. Arlington,TX\n5. Houston,TX\n3. Exit"); storeId = Int32.Parse(Console.ReadLine()); if (storeId == 3) { Console.WriteLine("Manager's Options:"); Console.WriteLine("1. View Order History Of A Store\n2. Add New Items To Stores\n3. Search User Information By Name \n4. Switch To Customer \n5.Stop"); manager = Int32.Parse(Console.ReadLine()); } try { getStore = getDBHandler.GetStoreFromStoreId(storeId, context); Console.WriteLine("Store Address {0}, {1}, {2}, {3}", getStore.address.street, getStore.address.city, getStore.address.state, getStore.address.zip); Console.WriteLine("Inventory:\nAriel: {0}, Downie: {1}, Suavitel: {2}", getStore.storeInventory.items.NumberofAriel, getStore.storeInventory.items.NumberofDownie, getStore.storeInventory.items.NumberofSuavitel); bool decided = false; int ariel; int downie; int suavitel; while (!decided) { try { Console.WriteLine("Ariel:"); string input = Console.ReadLine(); ariel = Int32.Parse(input); Console.WriteLine("Downie:"); input = Console.ReadLine(); downie = Int32.Parse(input); Console.WriteLine("Suavitels"); input = Console.ReadLine(); suavitel = Int32.Parse(input); Console.WriteLine("You added number of Ariel: {0} || Downie: {1} || Suavitel: {2}", ariel, downie, suavitel); Console.WriteLine("Ready To Add New Item? \n1.Yes 2.No"); string userInput = UserChoiceHandler.UserOptionHandler(Int32.Parse(Console.ReadLine()), 2); if (userInput == "1") { decided = true; Console.WriteLine(". . .\n"); { order = new Logic.Order(); //uses input handler to input order into DB var entityStore = context.Store.FirstOrDefault(i => i.StoreId == storeId); entityStore.Ariel += ariel; entityStore.Downie += downie; entityStore.Suavitel += suavitel; context.Store.Update(entityStore); context.SaveChanges(); try { nextMenu = false; Console.WriteLine("Added New Items Successfully!!!"); } catch (Exception e) { Console.WriteLine("Unable to perform the operation: \n" + e); //error handling Log.Error("Unknown Error"); } } } else if (userInput == "2") { Console.WriteLine("Please Enter The Amount of Items Again!!!"); } else { Console.WriteLine("Invalid input, please type one of the following options."); //error handling Log.Debug("Invalid Input"); } } catch (Exception e) { Console.WriteLine("Error! Please Try It Again"); } } nextMenu = true; break; } catch (Exception e) { Console.WriteLine("Error finding store with input ID" + e.Message); break; } /// <summary> /// Search Customer By Name /// </summary> case 3: Console.WriteLine("Enter First Name or Last Name To Search Information: "); string name = Console.ReadLine(); nextMenu = true; while (nextMenu) { try { getCustomer = getDBHandler.GetCustomerDataByName(name, context); var entityCustomer = context.Customer.FirstOrDefault(cust => cust.LastName == name || cust.FirstName == name); if (getCustomer != null) { Console.WriteLine("------------------------------------------------------------"); Console.WriteLine("Customer Id: {0} \nCustomer username: {1}", getCustomer.customerId, getCustomer.userName); Console.WriteLine("Name: {0} {1}", getCustomer.firstName, getCustomer.lastName); Console.WriteLine("Address"); Console.WriteLine("{0}, {1}, {2}, {3}", getCustomer.customerAddress.street, getCustomer.customerAddress.city, getCustomer.customerAddress.state.ToUpper(), getCustomer.customerAddress.zip); Console.WriteLine(); } if (getCustomer is null) { Console.WriteLine("No Customer Information"); } nextMenu = false; Console.WriteLine("Manager's Options:"); Console.WriteLine("1. View Order History Of A Store\n2. Add New Items To Stores\n3. Search User Information By Name \n4. Switch To Customer Menu \n5.Stop"); manager = Int32.Parse(Console.ReadLine()); } catch (Exception e) { Console.WriteLine("Error! Invalid Input. Please enter name of customer only" + e.Message); break; } } break; case 4: Console.Clear(); //Move To Customer's Menu Console.WriteLine("1. Sign Up \n2. Login \n3. Stop"); string userChoice = Console.ReadLine(); string customerChoice = UserChoiceHandler.UserOptionHandler(Int32.Parse(userChoice), 4); if (userChoice == "3") { Console.Clear(); Console.WriteLine("See You Later"); Environment.Exit(0); } else if (userChoice == "1" || userChoice == "2") { Menu.CustomerMenu(context, Int32.Parse(userChoice)); } else //Invalid input { Console.WriteLine("Invalid input, please type one of the following options"); //error handling Log.Error("Invalid Input"); } break; case 5: Console.WriteLine("Bye"); Environment.Exit(0); break; default: //error handling Log.Error("Invalid Input"); break; } } }