public IActionResult PlaceOrder([FromForm] PlaceRestaurantOrderVM orderVM)
        {
            var userName = HttpContext.User.Identity.Name;

            userService.SelectCurrentUser(userName);

            var curOrder = new PlaceRestaurantOrderVM
            {
                StoreName    = orderVM.StoreName,
                OrderStoreId = orderVM.OrderStoreId,
                Order        = new OrderVM
                {
                    Option = orderVM.Order.Option,
                    Price  = orderVM.Order.Price
                },
                Image     = orderVM.Image,
                Hyperlink = orderVM.Hyperlink,
                UserEmail = userService.user.Email
            };

            var storeToPlace = sessionRepository.GetActiveSession().Stores.FirstOrDefault(store => store.Name == orderVM.StoreName);

            var menuItem = new MenuItem
            {
                Details = orderVM.Order.Option,
                Price   = orderVM.Order.Price
            };

            userService.PlaceOrder(storeToPlace, menuItem, userService.user.Email);

            return(View(curOrder));
        }
        public IActionResult ModifyOrderDisplay()
        {
            activeSession = sessionRepository.GetActiveSession();

            var userEmail = HttpContext.User.Identity.Name;

            userService.SelectCurrentUser(userEmail);

            var userOrder = activeSession.Orders.FirstOrDefault(order => order.User.Email == userEmail);

            if (userOrder.IsActive == false)
            {
                return(RedirectToAction("Index", "Order"));
            }

            PlaceRestaurantOrderVM orderVM = new PlaceRestaurantOrderVM()
            {
                Order = new OrderVM
                {
                    Option = userOrder.Details,
                    Price  = userOrder.Price
                },
                StoreName = userOrder.Store.Name,
                Image     = userOrder.Store.Menu.Image
            };

            return(View(orderVM));
        }
        public IActionResult PlaceRestaurantOrder(int?id)
        {
            activeSession = sessionRepository.GetActiveSession();
            Store storeWithId = activeSession.Stores.SingleOrDefault(store => store.Id == id);

            var suggestions = storeWithId.GetProductSuggestions();

            curOrder = new PlaceRestaurantOrderVM
            {
                OrderStoreId = storeWithId.Id,
                StoreName    = storeWithId.Name,
                Image        = storeWithId.Menu.Image,
                Hyperlink    = storeWithId.Menu.Hyperlink,
                Suggestions  = suggestions.Select(menuItem => new OrderVM {
                    Option = menuItem.Details, Price = menuItem.Price
                })
                               .ToList <OrderVM>()
            };

            return(View(curOrder));
        }
        public IActionResult ModifyOrder([FromForm] PlaceRestaurantOrderVM orderVM)
        {
            activeSession = sessionRepository.GetActiveSession();
            var userEmail = HttpContext.User.Identity.Name;

            userService.SelectCurrentUser(userEmail);
            var userOrder = activeSession.Orders.FirstOrDefault(order => order.User.Email == userEmail);

            userService.LoadOrder(userOrder);

            var storeToPlace = userOrder.Store;

            var menuItem = new MenuItem
            {
                Details = orderVM.Order.Option,
                Price   = orderVM.Order.Price
            };

            userService.ChangeOrder(storeToPlace, menuItem, userOrder.Id);

            orderVM.StoreName = storeToPlace.Name;
            return(View(orderVM));
        }