Beispiel #1
0
        public async Task <IActionResult> Index()
        {
            var userIsInBusinessCustomerStockerRole = User.IsInBusinessCustomerStockerRole();

            var viewModel = new TrolleyIndexViewModel
            {
                AspController = userIsInBusinessCustomerStockerRole ? "Pantry" : "CatalogItem", Trolley = await GetTrolleyViewModelAsync()
            };

            return(View(viewModel));
        }
Beispiel #2
0
        public async Task <IActionResult> Index()
        {
            var userIsInBusinessCustomerStockerRole = User.IsInBusinessCustomerStockerRole();

            var userId           = User.FindFirstValue(Constants.ClaimTypes.ObjectIdentifier);
            var trolleyViewModel = await _trolleyViewService.GetOrCreateTrolleyForOwnerAsync(userId);

            if (trolleyViewModel == null || !trolleyViewModel.Items.Any())
            {
                return(RedirectToAction("Index", "Home"));
            }

            var viewModel = new TrolleyIndexViewModel
            {
                AspController = userIsInBusinessCustomerStockerRole ? "Pantry" : "CatalogItem", Trolley = trolleyViewModel
            };

            await _trolleyManager.RemoveAllItemFromTrolleyAsync(trolleyViewModel.Id);

            return(View(viewModel));
        }