public Acustomer AddNewCustomer(Acustomer cust) { cust.Id = ((context.Acustomers.Any(c => c.Id == 1)) ? context.Acustomers.Max(o => o.Id) + 1 : 1); context.Acustomers.Add(cust); context.SaveChanges(); return(cust); }
static void CreateOrder(Astore orderingStore, Acustomer orderingCustomer) { var context = new PizzaBoxContext(); int input = -1; List <Apizza> pizzas = new List <Apizza>(); var newOrder = new Aorder() { OrderId = (context.Aorders.Any(o => o.OrderId == 1))?context.Aorders.Max(o => o.OrderId) + 1: 1, CustomerId = orderingCustomer.Id, StoreId = orderingStore.Id, TimeOrdered = DateTime.Now }; Console.WriteLine("What Pizza Do you want in your order"); do { if (input != 2) { pizzas.Add(SelectPizza()); ModifyPizza(pizzas[pizzas.Count - 1]); } else { RemovePizza(pizzas); } Console.WriteLine("Order Total $: " + newOrder.TotalPrice(pizzas).Value); if (pizzas.Count >= maxPizzaCount || newOrder.TotalPrice(pizzas) > maxPizzaOrder) { input = 0; Console.WriteLine("You have reached the limit of your order"); } else { Console.WriteLine("Do you want another pizza. 0 for no 1 for yes 2 to remove pizza"); int.TryParse(Console.ReadLine(), out input); } }while(!(input == 0)); foreach (var p in pizzas) { Console.WriteLine(p.ToString()); } var totalPrice = 0m; foreach (var p in pizzas) { totalPrice += p.GetPizzaPrice(); } SubmitOrder(newOrder, pizzas); }
public IActionResult EditEmployee(int id, Acustomer customer) { var existingCust = customerData.GetCustomer(id); if (existingCust != null) { customer.Id = existingCust.Id; customerData.EditCustomer(customer); return(Ok(customer)); } return(NotFound()); }
public IActionResult GetCustomer(string fname, string lname) { var customer = customerData.GetCustomer(fname, lname); if (customer != null) { return(Ok(customer)); } Acustomer empty = new Acustomer() { Id = 0 }; return(Ok(empty)); }
//This will view orders for a customer static void ViewOrders(Acustomer cust) { var context = new PizzaBoxContext(); List <Aorder> ord = context.Aorders.Where(o => o.CustomerId == cust.Id).ToList(); foreach (var o in ord) { Console.WriteLine("Order # " + o.OrderId + " " + o.TimeOrdered + " $" + o.Total); List <AorderedPizza> piz = context.AorderedPizzas.Where(pi => pi.OrderId == o.OrderId).ToList(); foreach (var p in piz) { Console.WriteLine(" " + p.ToString()); } } }
//Checks to see if the customer has used this store within a time frame static bool checkCustomerStore(Acustomer checkCust, Astore checkStore, int storeLimit) { var context = new PizzaBoxContext(); var query = context.Aorders.Where(c => c.CustomerId == checkCust.Id); var queriable = query.Where(d => d.StoreId == checkStore.Id); if (queriable.Any(t => t.TimeOrdered >= DateTime.Now.AddHours(-storeLimit))) { Console.WriteLine("You have ordered in the last " + storeLimit + " hours"); return(true); } else { return(false); } }
static bool checkCustomerTime(Acustomer checkCust, int customerHourLimit) { var context = new PizzaBoxContext(); var query = context.Aorders.Where(c => c.CustomerId == checkCust.Id); if (query.Any(t => t.TimeOrdered >= DateTime.Now.AddHours(-customerHourLimit))) { Console.WriteLine("You have ordered in the last " + customerHourLimit + " hours"); return(true); } else { Console.WriteLine("Welcome " + checkCust.CustomerName); return(false); } }
public IActionResult GetCustomer(Acustomer customer) { Logic buis = new Logic(); //return Ok(customerData.GetCustomers()); var checkCust = customerData.GetCustomer(customer); if (checkCust == null) { return(Ok(buis.AddNewCustomer(customer))); } else { Acustomer empty = new Acustomer() { Id = 0 }; return(Ok(empty)); } }
static Acustomer SelectCustomer() { var context = new PizzaBoxContext(); Console.WriteLine("What is your name"); var name = Console.ReadLine(); if (context.Acustomers.Any(c => c.CustomerName == name)) { return(context.Acustomers.Where(c => c.CustomerName == name).First()); } else { var cust = new Acustomer() { Id = context.Acustomers.Max(c => c.Id) + 1, CustomerName = name }; context.Acustomers.Add(cust); context.SaveChanges(); return(cust); } }
public Acustomer GetCustomer(string fname, string lname) { Acustomer customer = context.Acustomers.SingleOrDefault(c => c.Fname == fname && c.Lname == lname); return(customer); }
public void DeleteCustomer(Acustomer customer) { throw new NotImplementedException(); }
public Acustomer AddCustomer(Acustomer customer) { return(customer); }
public Acustomer GetCustomer(Acustomer customer) { return(customers.Find(c => c.Fname == customer.Fname && c.Lname == customer.Lname)); }
public Acustomer EditCustomer(Acustomer customer) { throw new NotImplementedException(); }
public Acustomer EditCustomer(Acustomer customer) { customers.SingleOrDefault(c => c.Id == customer.Id).Fname = customer.Fname; customers.SingleOrDefault(c => c.Id == customer.Id).Lname = customer.Lname; return(customers.SingleOrDefault(c => c.Id == customer.Id)); }
public void DeleteCustomer(Acustomer customer) { var cust = customers.SingleOrDefault(c => c.Id == customer.Id); customers.Remove(cust); }
public Acustomer AddCustomer(Acustomer customer) { customers.Add(customer); return(customer); }
public Acustomer GetCustomer(Acustomer customer) { return(context.Acustomers.SingleOrDefault(c => c.Fname == customer.Fname && c.Lname == customer.Lname)); }
public Acustomer GetCustomer(int id) { Acustomer customer = context.Acustomers.SingleOrDefault(c => c.Id == id); return(customer); }