private StoreSingleton(PizzaBoxContext context) { _context = context; if (Stores == null) { Stores = _context.Stores.ToList(); } }
public static CustomerSingleton Instance(PizzaBoxContext context) { if (_instance == null) { _instance = new CustomerSingleton(context); } return(_instance); }
public static SauceSingleton Instance(PizzaBoxContext context) { if (_instance == null) { _instance = new SauceSingleton(context); } return(_instance); }
private PizzaSingleton(PizzaBoxContext context) { _context = context; // _filerepository.WriteFromFile<List<APizza>>(_path, PizzaTest); // PizzaTest = _filerepository.ReadFromFile<List<APizza>>(_path); //_context.Pizzas.AddRange(PizzaTest); // _context.SaveChanges(); PizzaTest = _context.Pizzas.ToList(); }
private PizzaSingleton(PizzaBoxContext context) { // _context = context; // Pizzas = _context.Pizzas.ToList(); if (Pizzas == null) { Pizzas = _fileRepository.ReadFromFile <List <APizza> >(_path); } // return Pizzas; }
public IEnumerable <Library.Orders> GetOrdersbyUserId(PizzaBoxContext Pizzabox) { using (var unitofWork = new PizzaBox.Storing.UnitofWork(Pizzabox)) { var orderlist = unitofWork.Order.GetAll().Where(e => e.CustomerId == authenticatedid).ToList(); return(orderlist.Select(e => new Library.Orders { Id = e.Id, orderdate = e.PlaceDate, TotalCost = e.TotalPrice, CustomerId = e.CustomerId, StoreId = e.StoreId })); } }
public IList <Library.Ingredients> ListToppings(PizzaBoxContext Pizzabox) { using (var unitofWork = new PizzaBox.Storing.UnitofWork(Pizzabox)) { var toppinglist = unitofWork.Ingrediants.GetAll().ToList(); return(toppinglist.Select(e => new Library.Ingredients { Id = e.Id, Topping = e.Topping, Price = e.Price, Type = e.Type }).ToList()); } }
private static void ConfirmOrder(Order MyOrder) { Console.WriteLine($"Your order for {MyOrder.Customer.Name} at the {MyOrder.Store.name} contains:"); for (int i = 0; i < MyOrder.Items.Count; i++) { Console.WriteLine($"{i + 1}: {MyOrder.Items[i].ToString()} - {MyOrder.Items[i].Price}"); } Console.WriteLine($"For a total of: {MyOrder.OrderTotal}"); PizzaBoxContext.Save(_context, MyOrder); }
private StoreSingleton(PizzaBoxContext context) { _context = context; if (Stores == null) { //_context.Stores.AddRange(_fileRepository.ReadFromFile<List<AStore>>(_path)); //_context.SaveChanges(); Stores = _context.Stores.ToList(); } }
static void DisplayPizzas() { var context = new PizzaBoxContext(); List <Apizza> pizzas = context.Apizzas.ToList(); foreach (var p in pizzas) { Console.WriteLine(p.ToString()); } }
public static StoreSingleton Instance(PizzaBoxContext context) { { if (_instance == null) { _instance = new StoreSingleton(); } return(_instance); } }
private PizzaSingleton(PizzaBoxContext context) { Pizzas = context.Pizzas.ToList(); if (Pizzas.Count == 0) { context.Pizzas.Add(new CheesePizza()); context.Pizzas.Add(new PepperoniPizza()); context.SaveChanges(); Pizzas = context.Pizzas.ToList(); } }
public bool AddOrder(Order order, PizzaBoxContext _context) //??????? { // _context = context; // Orders.Add(order); _context.Orders.Add(order); _context.SaveChanges(); // _fileRepository.WriteToFile<List<Customer>>(_path, Customers); return(true); }
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); }
private static void StoreHistory() { Console.WriteLine("Which store history would you like to check?"); PrintStoreList(); List <Order> Read; Read = PizzaBoxContext.StoreHistory(_context, (Common.Answer(1, 3))); foreach (var item in Read) { Console.WriteLine(item.ToString()); } }
static void UpdateDict(PizzaBoxContext db, User u) { var query = from c in db.Customer where c.Uname == u.UName select c; foreach (Customer c in query) { c.Lastorder = JsonConvert.SerializeObject(u.lastOrder); } db.SaveChanges(); }
public void Test_Crust_Name(string expected, int testID) { var context = new PizzaBoxContext(); // arrange var sut = context.Acrusts.Where(t => t.Id == testID).FirstOrDefault(); // act var actual = sut.CrustName; // assert Assert.Equal(expected, actual); }
public void Test_Topping_Price(decimal expected, int testID) { var context = new PizzaBoxContext(); // arrange Atopping sut = context.Atoppings.Where(t => t.Id == testID).FirstOrDefault(); // act var actual = sut.ToppingPrice; // assert Assert.Equal(expected, actual); }
private CrustSingleton(PizzaBoxContext context) { _context = context; Crusts = new List <Crust> { _context.Crust.FirstOrDefault(c => c.Name == "Thin"), _context.Crust.FirstOrDefault(c => c.Name == "Stuffed"), _context.Crust.FirstOrDefault(c => c.Name == "Original"), _context.Crust.FirstOrDefault(c => c.Name == "Neapolitan"), }; }
public void CheeseToppingTest() { var context = new PizzaBoxContext(); // arrange Atopping sut = context.Atoppings.Where(t => t.Id == 1).FirstOrDefault(); var expected = "Cheese"; // act var actual = sut.ToppingName; // assert Assert.Equal(expected, actual); }
private StoreSingleton(PizzaBoxContext context) { _context = context; Stores = _context.Stores.ToList(); if (Stores == null) { var s = new ChicagoStore(); var n = new NewYorkStore(); _context.Add(s); _context.Add(n); } //Stores = _context.Stores.ToList(); }
private StoreSingleton(PizzaBoxContext context) { _context = context; Stores = _context.Stores.ToList(); if (Stores.Count == 0) { _context.Stores.Add(new JayPizza()); _context.Stores.Add(new Pizzaria()); _context.SaveChanges(); Stores = _context.Stores.ToList(); } }
/// <summary> /// /// </summary> private PizzaSingleton(PizzaBoxContext context) { _context = context; //Pizzas = _fileRepository.ReadFromFile<List<APizza>>(_path); //_context.Pizzas.AddRange(_fileRepository.ReadFromFile<List<APizza>>(_path)); //var cp = new CustomPizza(); //cp.Size = _context.Sizes.FirstOrDefault(s => s.Name == "Medium"); //cp.Crust = _context.Crust.FirstOrDefault(s => s.Name == "Original"); //_context.Add(cp); //_context.SaveChanges(); //Pizzas = _context.Pizzas.ToList(); }
private static void OrderCreation(Customer Customer) { Order MyOrder = new Order(); MyOrder.Customer = Customer; bool localrestart = false; Console.WriteLine("Which store will you be purchasing from?"); PrintStoreList(); switch (Common.Answer(1, 3)) { case 1: { MyOrder.Store = PizzaBoxContext.DataReadID(1, _context.Stores); break; } case 2: { MyOrder.Store = PizzaBoxContext.DataReadID(2, _context.Stores); break; } case 3: { MyOrder.Store = PizzaBoxContext.DataReadID(3, _context.Stores); break; } } do { MyOrder.AddPizza(PizzaCreator()); Console.WriteLine(@"Would you like to add another pizza? 1: Yes 2: No "); if (Common.Answer(1, 2) == 1) { localrestart = true; } else { localrestart = false; } } while (localrestart); ConfirmOrder(MyOrder); }
private ToppingSingleton(PizzaBoxContext context) { _context = context; Toppings = new List <Topping> { _context.Toppings.FirstOrDefault(t => t.Name == "peppers"), _context.Toppings.FirstOrDefault(t => t.Name == "onions"), _context.Toppings.FirstOrDefault(t => t.Name == "olives"), _context.Toppings.FirstOrDefault(t => t.Name == "Mozzarella"), _context.Toppings.FirstOrDefault(t => t.Name == "Marinara"), _context.Toppings.FirstOrDefault(t => t.Name == "Parmigiano"), _context.Toppings.FirstOrDefault(t => t.Name == "Margherita") }; }
public IEnumerable <Library.Orders> GetOrdersbyStoreId(PizzaBoxContext Pizzabox, int id) { using (var unitofWork = new PizzaBox.Storing.UnitofWork(Pizzabox)) { var pizza = unitofWork.Pizza.GetAll(); var orderlist = unitofWork.Order.GetAll().Where(e => e.StoreId == id); return(orderlist.Select(e => new Library.Orders { Id = e.Id })); } }
static void AddUser(PizzaBoxContext db, User u) { if (db.Customer.Any(c => c.Uname == u.UName) || u.UName == null) { Console.WriteLine($"The username {u.UName} already exists."); return; } else { Customer c = Mapper.Map(u); db.Customer.Add(c); // this will generate insert query } db.SaveChanges(); // this will execute the above generate insert query }
public IEnumerable <Library.Store> RetrieveListStores(PizzaBoxContext Pizzabox) { using (var unitofWork = new PizzaBox.Storing.UnitofWork(Pizzabox)) { var storelist = unitofWork.Store.GetAll(); var storeaddress = unitofWork.Address.GetAll(); var query = from store in storelist join address in storeaddress on store.Address equals address.Id select new Library.Store { StoreId = store.Id, Name = store.Name, City = address.City }; return(query); } }
static void AddStore(PizzaBoxContext db, Domain.Models.Store s) { if (db.Store.Any(st => st.Sname == s.SName) || s.SName == null) { Console.WriteLine($"The store {s.SName} already exists."); return; } else { Storing.Repositories.Store st = Mapper.Map(s); db.Store.Add(st);// this will generate insert query } db.SaveChanges(); }
/// <summary> /// /// </summary> private PizzaSingleton(PizzaBoxContext context) { //var pizza = new MeatPizza(); //_context.Pizzas.Add(pizza); // _context.Pizzas.AddRange(_fileRepository.ReadFromFile<List<APizza>>(_path)); //var cp = new CustomPizza(); //cp.Size = _context.Sizes.FirstOrDefault(s => s.Name == "Regular"); // _context.Add(cp); //_context.SaveChanges(); //_context = context; Pizzas = context.Pizzas.ToList(); }