public IActionResult ValidateLogin(Models.PuserModel user) { Lib.Model.Puser deUser = new Lib.Model.Puser() { Username = user.Username, PPassword = user.PPassword }; try { deUser = repository.GetUser(deUser); if (deUser != null) { TempData["user"] = deUser.PUserId; Lib.Model.Employee employee = repository.GetEmployee(deUser.PUserId); if (employee == null) { return(RedirectToAction("CustomerMenu", "Home")); } else { return(RedirectToAction("EmployeeMenu", "Home")); } } } catch (Exception e) { } return(View("Login")); }
public IActionResult PizzaInventory() { int userId = Convert.ToInt32(TempData["user"]); TempData["user"] = userId; Domain.Model.Puser user = repository.GetUser(userId); List <Domain.Model.Pizza> pizzas = repository.GetPizzas(user.LocationId); List <PizzaModel> pizzModels = new List <PizzaModel>(); foreach (Domain.Model.Pizza pizza in pizzas) { PizzaModel model = new PizzaModel() { PizzaId = pizza.PizzaId, PType = pizza.PType, PSize = pizza.PSize, Crust = pizza.Crust, PPrice = pizza.PPrice, SLocationId = pizza.SLocationId }; pizzModels.Add(model); } return(View(pizzModels)); }
public IActionResult ViewOrdersAdmin() { double totalOrderCost = 0; List <Domain.Model.Porder> orders = repository.GetOrders(); List <PorderModel> orderModels = new List <PorderModel>(); TempData["orderCount"] = orders.Count; foreach (Domain.Model.Porder order in orders) { PorderModel porderModel = new PorderModel(); porderModel.OrderId = order.OrderId; porderModel.PDate = order.PDate; porderModel.PTime = order.PTime; porderModel.OrderCost = order.OrderCost; totalOrderCost += Convert.ToDouble(order.OrderCost.Trim()); Domain.Model.Puser user = repository.GetUser(order.PUserId); porderModel.FirstName = user.Firstname; porderModel.LastName = user.Lastname; Domain.Model.Pizza pizza = repository.GetPizza(order.PizzaId); porderModel.PType = pizza.PType; porderModel.PSize = pizza.PSize; porderModel.PPrice = pizza.PPrice; porderModel.Crust = pizza.Crust; orderModels.Add(porderModel); } TempData["totalCost"] = totalOrderCost; return(View(orderModels)); }
public IActionResult Pizza(int id) { List <Pizza> pizzas = repository.GetPizzasFromLocation(id); List <PizzaModel> pizzaModels = new List <PizzaModel>(); List <ToppingsModel> toppModels = new List <ToppingsModel>(); List <Domain.Model.Toppings> toppings = repository.GetToppings(Convert.ToInt32(id)); int userId = Convert.ToInt32(TempData["user"]); bool validateDate = Lib.Handler.OrderHandler.CheckOrderDateTime(repository.GetOrders(), repository.GetLocation(id), repository.GetUser(userId)); TempData["user"] = userId; if (validateDate == true) { if (pizzas != null) { foreach (Domain.Model.Toppings topp in toppings) { ToppingsModel topModel = new ToppingsModel() { TopId = topp.TopId, TName = topp.TName, T_Type = topp.T_Type, Cost = topp.Cost }; toppModels.Add(topModel); } foreach (Pizza pizza in pizzas) { PizzaModel pizzaModel = new PizzaModel() { PizzaId = pizza.PizzaId, PType = pizza.PType, PSize = pizza.PSize, Crust = pizza.Crust, PPrice = pizza.PPrice, SLocationId = pizza.SLocationId }; pizzaModels.Add(pizzaModel); } ViewBag.toppingsModel = toppModels; return(View(pizzaModels)); } else { } } return(RedirectToAction("Message")); }