//[ValidateAntiForgeryToken] public IActionResult FinishPizza(PizzaViewModel pModel) { //if (ModelState.IsValid) //{ // return Redirect("user/home"); //} OrderRepository oRepo = new OrderRepository(_db); PizzaRepository pRepo = new PizzaRepository(_db); CrustRepository cRepo = new CrustRepository(_db); SizeRepository sRepo = new SizeRepository(_db); ToppingRepository tRepo = new ToppingRepository(_db); PizzaFactory pf = new PizzaFactory(); Pizza p = pf.CreateCustom(); p.Crust = cRepo.GetCrustByName(pModel.Crust); p.Size = sRepo.GetSizeByName(pModel.Size); p.Order = oRepo.Get2(pModel.OrderId); foreach (SelectedTopping st in pModel.SelectedToppings) { if (st.IsSelected) { p.PizzaToppings.Add(new PizzaTopping() { Topping = tRepo.GetToppingByName(st.Name), Pizza = p }); } } p.Price = p.GetPrice(); pRepo.Add(p); pModel.Order = oRepo.Get(pModel.OrderId); return(View("Order", pModel)); }
public void SetUp() { var database = new Mock <IDatabase>(); database.Setup(x => x.Query <ToppingRecord>()).Throws <Exception>(); var subject = new ToppingRepository(database.Object); _result = subject.GetAll(); }
public PizzeriaService(PizzaBoxDbContext context) { _ctx = context; _pr = new PizzaRepository(context); _cr = new CrustRepository(context); _sr = new SizeRepository(context); _tr = new ToppingRepository(context); _ur = new UserRepository(context); _or = new OrderRepository(context); _rr = new StoreRepository(context); }
public UnitOfWork(PizzaBoxContext context) { _context = context; Stores = new StoreRepository(context); Customers = new CustomerRepository(context); Crusts = new CrustRepository(context); Sizes = new SizeRepository(context); Toppings = new ToppingRepository(context); Pizzas = new PizzaRepository(context); Orders = new OrderRepository(context); }
public DataTest() { _db = new NpgsqlConnection(ConnectionString); if (_db.State != ConnectionState.Open) { _db.Open(); } _scope = _db.CreateAsyncTransactionScope(); Toppings = new ToppingRepository(_db); Pizzas = new PizzaRepository(_db, Toppings); }
public void ConvertSpecial(PizzaViewModel pizzaViewModel, PizzaStoreDBContext _db) { var CR = new CrustRepository(_db); var SR = new SizeRepository(_db); var PR = new PizzaRepository(_db); var TR = new ToppingRepository(_db); var OR = new OrderRepository(_db); var UR = new UserRepository(_db); var STR = new StoreRepository(_db); var PF = new PizzaFactory(); var tempSpecialty = PF.Create(); tempSpecialty = PR.Get(SelectedPizza); var tempPizza = PF.Create(); tempPizza.Name = SelectedPizza; tempPizza.Description = tempSpecialty.Description; tempPizza.Size = SR.Get(pizzaViewModel.Size); tempPizza.Crust = CR.Get(pizzaViewModel.Crust); tempPizza.Toppings = new List <ToppingsModel>(); tempPizza.SpecialPizza = true; foreach (var t in tempSpecialty.Toppings) { var tempTopping = new ToppingsModel() { Name = t.Name, Description = t.Description }; tempPizza.Toppings.Add(tempTopping); TR.Add(tempTopping); } var cart = OR.GetCurrentOrder(); var OF = new OrderFactory(); if (cart != null) { OR.AddPizza(cart.Id, tempPizza); } else { cart = OF.Create(); cart.Pizzas.Add(tempPizza); cart.CurrentOrder = true; OR.UpdateCurrentOrder(cart); var tempUser = UR.Get(User); UR.AddOrder(tempUser.Id, cart); var tempStore = STR.Get(Store); STR.AddOrder(tempStore.Id, cart); } }
public PizzaViewModel(PizzaStoreDBContext dbo) { var cRepo = new CrustRepository(dbo); Crusts = cRepo.GetAll(); var sRepo = new SizeRepository(dbo); Sizes = sRepo.GetAll(); var tRepo = new ToppingRepository(dbo); Toppings = new List <ToppingsModel>(); Toppings2 = new List <CheckBoxTopping>(); foreach (ToppingsModel t in tRepo.GetAll()) { Toppings.Add(t); } foreach (var t in Toppings) { Toppings2.Add(new CheckBoxTopping() { Name = t.Name, Id = t.Id, Description = t.Description, Text = t.Name, IsSelected = false }); } var uRepo = new UserRepository(dbo); Users = uRepo.GetAll(); var stRepo = new StoreRepository(dbo); Stores = stRepo.GetAll(); var pRepo = new PizzaRepository(dbo); SpecialtyPizzas = pRepo.GetAllSpecialty(); Pizzas = new List <CheckBoxPizza>(); GetCart(dbo); if (Cart.Pizzas != null) { foreach (PizzaModel p in Cart.Pizzas) { Pizzas.Add(new CheckBoxPizza() { Name = p.Name, Id = p.Id, Description = p.Description, Text = p.Name, IsSelected = false }); } } }
protected void btnDataOps_Click(object sender, EventArgs e) { DummyDataRepository newDataOps = new DummyDataRepository(); PizzaRepository newPizzaOps = new PizzaRepository(); ToppingRepository newTopping = new ToppingRepository(); OrderRepository newOrder = new OrderRepository(); newTopping.InsertNewTopping(newDataOps.GetNewToppingToInsert()); newPizzaOps.CreateOrder(newDataOps.GetNewPizzaToInsert()); newOrder.CreateOrder(newDataOps.GetNewOrderToInsert()); //newPizzaOps.CreateOrder(newPizzas.GetPizzaToppings()); //Console.WriteLine(newDataOps.GetPizzaToppings()); //BulletedListToppingsData.DataSource = newDataOps.GetPizzaToppings().Select(topping => topping.topping); //BulletedListToppingsData.DataBind(); //BulletedListPizzaData.DataSource = newDataOps.GetPizzas().Select(pizza => pizza.name); //BulletedListPizzaData.DataBind(); }
public void SetUp() { var database = new Mock <IDatabase>(); database.Setup(x => x.Query <ToppingRecord>()).Returns(new List <ToppingRecord> { new ToppingRecord { Id = 1, Name = "Onion" }, new ToppingRecord { Id = 2, Name = "Ham" } }); var subject = new ToppingRepository(database.Object); _result = subject.GetAll(); }
public IActionResult AddPizza(PizzaViewModel pModel) { CrustRepository cRepo = new CrustRepository(_db); SizeRepository sRepo = new SizeRepository(_db); ToppingRepository tRepo = new ToppingRepository(_db); OrderRepository oRepo = new OrderRepository(_db); UserRepository uRepo = new UserRepository(_db); pModel.User = uRepo.GetUserByName(pModel.Username); pModel.Order = oRepo.Get(pModel.OrderId); pModel.Crusts = cRepo.GetCrusts(); pModel.Sizes = sRepo.GetSizes(); pModel.Toppings = tRepo.GetToppings(); foreach (Topping t in pModel.Toppings) { pModel.SelectedToppings.Add(new PizzaViewModel.SelectedTopping() { Text = t.Name, IsSelected = false }); } return(View("AddPizza", pModel)); }
public void ConvertRegular(PizzaViewModel pizzaViewModel, PizzaStoreDBContext _db) { var UR = new UserRepository(_db); var STR = new StoreRepository(_db); var OR = new OrderRepository(_db); var CR = new CrustRepository(_db); var SR = new SizeRepository(_db); var PR = new PizzaRepository(_db); var TR = new ToppingRepository(_db); var PF = new PizzaFactory(); List <ToppingsModel> TM = new List <ToppingsModel>(); SelectedToppings = new List <CheckBoxTopping>(); foreach (var t in Toppings2) { if (t.IsSelected) { SelectedToppings.Add(t); } } foreach (var t in SelectedToppings) { var throwaway = TR.Get(t.Text); var tempTopping = new ToppingsModel() { Name = throwaway.Name, Description = throwaway.Description }; TM.Add(tempTopping); } //TM.Add(TR.Get(Topping)); var tempPizza = PF.Create(); tempPizza.Name = "custom"; tempPizza.Description = "custom"; tempPizza.Size = SR.Get(pizzaViewModel.Size); tempPizza.Crust = CR.Get(pizzaViewModel.Crust); tempPizza.Toppings = new List <ToppingsModel>(); tempPizza.Toppings = TM; tempPizza.SpecialPizza = false; var cart = OR.GetCurrentOrder(); var OF = new OrderFactory(); if (cart != null) { OR.AddPizza(cart.Id, tempPizza); } else { cart = OF.Create(); cart.Pizzas = new List <PizzaModel>(); cart.Pizzas.Add(tempPizza); cart.CurrentOrder = true; OR.UpdateCurrentOrder(cart); var tempUser = UR.Get(User); UR.AddOrder(tempUser.Id, cart); var tempStore = STR.Get(Store); STR.AddOrder(tempStore.Id, cart); } }
private ToppingSingleton() { repository = new ToppingRepository(DbContextSingleton.Instance.Context); Toppings = repository.GetList(); }
public ToppingsController(ToppingRepository toppingRepository) { _toppingRepository = toppingRepository; }