public IActionResult Index()
        {
            //get user Id from cookie
            var          loggedInUser = HttpContext.User;
            string       Id           = loggedInUser.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Name).Value;
            User         user         = UserRepo.getUserById(Int32.Parse(Id));
            List <Order> orders       = ORepo.GetOrdersByUserId(user.Id);

            orders.OrderByDescending(o => o.TimeStamp);
            List <MenuItem> items = new List <MenuItem>();

            foreach (Order order in orders)
            {
                foreach (OrderItem oi in order.OrderItems)
                {
                    MenuItem item = MIRepo.GetMenuItemById(oi.MenuItemId);
                    items.Add(item);
                }
            }

            ProfileViewModel pvm = new ProfileViewModel();

            pvm.User        = user;
            pvm.RecentItems = items;

            return(View(pvm));
        }
Beispiel #2
0
        public async Task <bool> HandleAsync(GetMenuItemByIdRequest message, IOutputPort <GetMenuItemByIdResponse> outputPort)
        {
            var response = await _menuItemRepository.GetMenuItemById(message.Id);

            outputPort.Handle(new GetMenuItemByIdResponse(response, true, null));

            return(true);
        }
 public async Task <MenuItem> GetMenuItemById(int menuItemId, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(await _menuItemRepository.GetMenuItemById(menuItemId, cancellationToken));
 }