Ejemplo n.º 1
0
        public async Task <IActionResult> Index()
        {
            var userEmail = HttpContext.User.Identity.Name;
            var isUser    = userRepository.FindUser(userEmail);

            if (isUser == false)
            {
                var identityUser = await usersManager.FindByEmailAsync(userEmail);

                User user = new User()
                {
                    Email = identityUser.Email, Name = identityUser.Name
                };
                userRepository.Create(user);
            }

            try
            {
                var currentSession = sessionRepository.GetActiveSession();
            }
            catch (SessionNotFoundException)
            {
                return(View(true));
            }

            return(View(false));
        }
        public IActionResult Index()
        {
            activeSession = null;
            var           userEmail     = HttpContext.User.Identity.Name;
            OrderActiveVM orderActiveVM = new OrderActiveVM()
            {
                Session = null, OrderIsActive = true
            };

            try
            {
                activeSession         = sessionRepository.GetActiveSession();
                orderActiveVM.Session = activeSession;
            }
            catch (SessionNotFoundException)
            {
                return(View(orderActiveVM));
            }

            userService.SelectCurrentUser(userEmail);

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

            if (userOrder == null)
            {
                return(View(orderActiveVM));
            }
            else
            {
                orderActiveVM.Order            = new Order();
                orderActiveVM.Order.Store      = new Store();
                orderActiveVM.Order.Store.Name = userOrder.Store.Name;
                orderActiveVM.Order.Price      = userOrder.Price;
                orderActiveVM.Order.User       = new User();
                orderActiveVM.Order.User.Name  = userOrder.User.Name;
                orderActiveVM.Order.Details    = userOrder.Details;
                orderActiveVM.OrderIsActive    = userOrder.IsActive;
                if (userOrder.IsActive == false)
                {
                    return(View(orderActiveVM));
                }

                return(RedirectToAction("ModifyOrderDisplay", "Order"));
            }
        }