Esempio n. 1
0
        public ActionResult Index(string message, int?id)
        {
            var userID = User.Identity.GetUserId();
            var user   = db.Users.Include(u => u.Addresses)
                         .Include(u => u.Orders)
                         .FirstOrDefault(u => u.Id == userID);

            ViewBag.Message = message;

            var viewModel = new OrderIndexData();

            viewModel.User      = user;
            viewModel.Addresses = user.Addresses;
            viewModel.Orders    = user.Orders.ToList();

            if (id != null)
            {
                ViewBag.orderId = id.Value;

                viewModel.OrderProducts = viewModel.Orders
                                          .Where(o => o.OrderID == id.Value)
                                          .Single()
                                          .OrderProducts;
            }

            return(View(viewModel));
        }
        // GET: Order/Details/5
        public ActionResult Details(int?id, int?pizzaID, int?toppingID)
        {
            var viewModel = new OrderIndexData();

            viewModel.Orders = db.Orders
                               .Where(i => i.OrderID == id.Value)
                               .Include(i => i.Pizzas.Select(c => c.Size))
                               .Include(i => i.Delivery);

            if (id != null)
            {
                ViewBag.OrderID  = id.Value;
                viewModel.Pizzas = viewModel.Orders.Where(
                    i => i.OrderID == id.Value).Single().Pizzas;
            }

            if (pizzaID != null)
            {
                ViewBag.PizzaID    = pizzaID.Value;
                viewModel.Toppings = db.Pizzas.Where(d => d.PizzaID == pizzaID).FirstOrDefault().Toppings;
            }
            if (toppingID != null)
            {
                ViewBag.ToppingID = toppingID.Value;
            }
            return(View(viewModel));
        }
        public ActionResult HomeAdmin(int?orderID, int?productID, int?page, string search, string currentFilter)
        {
            var viewModel = new OrderIndexData();

            // test null if in search control
            if (search != null)
            {
                page = 1;
            }
            else
            {
                search = currentFilter;
            }
            Search = search;
            ViewBag.CurrentFilter = search;
            viewModel.Order       = Orders(search);
            viewModel.Command     = BigComand();

            viewModel.OrderTen = LastTenOrder();
            // test null if orders not selected in page
            if (orderID == 0)
            {
                orderID = null;
            }
            if (orderID != null)
            {
                ViewBag.OrderID        = orderID.Value;
                viewModel.Order_Detail = Details(ViewBag.OrderID);
            }
            //test null if OrdersDetails not selected in page
            if (productID == 0)
            {
                productID = null;
            }
            if (productID != null)
            {
                ViewBag.ProductID = productID.Value;

                viewModel.Product = ProductCategory(ViewBag.ProductID);
            }
            //pagination
            int pageSize;

            try
            {
                pageSize = int.Parse(System.Configuration.ConfigurationManager.AppSettings["pageSize"]);
            }
            catch
            {
                logger.Error("Exista o eroare in configurare, key pageSize trebuie sa fie un numar");
                pageSize = 10;
            }
            int pageNumber = (page ?? 1);

            viewModel.Page  = viewModel.Order.ToPagedList(pageNumber, pageSize);
            viewModel.Order = viewModel.Order.ToPagedList(pageNumber, pageSize);
            return(View(viewModel));
        }
        // GET: Order
        public ActionResult Index(int?id, int?pizzaID, int?toppingID)
        {
            var viewModel = new OrderIndexData();


            if (id != null)
            {
                //db.Configuration.LazyLoadingEnabled = false;
                //ar order = db.Orders.Find(id);
                //var selectedOrder = viewModel.Orders.Where()
                //var order = (from o in db.Orders
                //where o.OrderID == id
                //select o).FirstOrDefault<Order>();

                //db.Entry(order).Collection(o => o.Pizzas).Load();

                //var pizza = (from o in db.Pizzas
                //where o.PizzaID == id
                //select o).FirstOrDefault<Pizza>();



                // var selectedOrder = viewModel.Orders.Where(x => x.OrderID == id).Single();
                ViewBag.Order    = id.Value;
                viewModel.Pizzas = viewModel.Orders.Where(
                    i => i.OrderID == id.Value).Single().Pizzas;
            }

            if (pizzaID != null)
            {
                ViewBag.PizzaID    = pizzaID.Value;
                viewModel.Toppings = viewModel.Pizzas.Where(
                    i => i.PizzaID == id.Value).Single().Toppings;
            }
            if (toppingID != null)
            {
                ViewBag.ToppingID = toppingID.Value;
            }

            return(View());
            //var orders = db.Orders.Include(o => o.Delivery);
            //return View(orders.ToList());
        }
Esempio n. 5
0
        public ActionResult Index(int?id, int?toppingID)
        {
            var viewModel = new OrderIndexData();


            if (id != null)
            {
                ViewBag.PizzaID    = id.Value;
                viewModel.Toppings = viewModel.Pizzas.Where(
                    i => i.PizzaID == id.Value).Single().Toppings;
            }

            if (toppingID != null)
            {
                ViewBag.ToppingID = toppingID.Value;
            }

            return(View(viewModel));
        }
Esempio n. 6
0
        // GET: PizzaToppings/Details/5Vi
        public ActionResult Details(int?id, int?toppingID)
        {
            var viewModel = new OrderIndexData();

            viewModel.Pizzas = db.Pizzas
                               //.Where(i => i.PizzaID == id.Value)
                               //.Include(i => i.Toppings.Select(c => c.ToppingID))
                               .Include(i => i.Size);

            if (id != null)
            {
                ViewBag.PizzaID    = id.Value;
                viewModel.Toppings = viewModel.Pizzas.Where(
                    i => i.PizzaID == id.Value).Single().Toppings;
            }
            if (toppingID != null)
            {
                ViewBag.ToppingID = toppingID.Value;
            }

            return(View(viewModel));
        }
Esempio n. 7
0
        // GET: Orders
        public async Task <IActionResult> Index(int?id)
        {
            var viewModel = new OrderIndexData();

            viewModel.Orders = await _context.Orders
                               .Include(i => i.Customer)
                               .Include(i => i.SuperMarket)
                               .Include(i => i.OrderDetails)
                               .ThenInclude(i => i.Product)
                               .AsNoTracking()
                               .ToListAsync();

            if (id != null)
            {
                ViewData["OrderID"] = id.Value;
                Order order = viewModel.Orders.Where(
                    i => i.Id == id.Value).Single();
                viewModel.Products = order.OrderDetails.Select(s => s.Product);
            }

            // var shoppingContext = _context.Orders.Include(o => o.Customer).Include(o => o.SuperMarket);
            // return View(await shoppingContext.ToListAsync());
            return(View(viewModel));
        }
        public ActionResult Home(int?orderID, int?productID, int?page, string search, string currentFilter)
        {
            var    viewModel   = new OrderIndexData();
            string curentUser  = User.Identity.Name;
            int    employeerId = db.Employees.Where(e => e.FirstName + e.LastName == curentUser).Select(e => e.EmployeeID).FirstOrDefault();

            // test null if in search control
            if (search != null)
            {
                page = 1;
            }
            else
            {
                search = currentFilter;
            }
            Search            = search;
            viewModel.Order   = Orders(search, employeerId);
            viewModel.Command = BigComand(employeerId);

            viewModel.OrderTen = LastTenOrder(employeerId);
            // test null if orders not selected in page
            if (orderID == 0)
            {
                orderID = null;
            }
            if (orderID != null)
            {
                ViewBag.OrderID        = orderID.Value;
                viewModel.Order_Detail = Details(ViewBag.OrderID);
            }
            //test null if OrdersDetails not selected in page
            if (productID == 0)
            {
                productID = null;
            }
            if (productID != null)
            {
                ViewBag.ProductID = productID.Value;

                viewModel.Product = ProductCategory(ViewBag.ProductID);
            }
            //pagination
            int pageSize;

            try
            {
                pageSize = int.Parse("10");
            }
            catch
            {
                //logger.Error("Exista o eroare in configurare, key pageSize trebuie sa fie un numar");
                pageSize = 10;
            }
            int pageNumber = (page ?? 1);

            viewModel.Page  = 1;
            viewModel.Order = viewModel.Order.ToList();


            return(View(viewModel));
        }