public MainPage()
        {
            InitializeComponent();
            ViewModel      = new GetItemsViewModel();
            BindingContext = ViewModel;

            session.Text = CrossSecureStorage.Current.GetValue("firstname") + " " + CrossSecureStorage.Current.GetValue("lastname");
        }
        // GET: Items
        public async Task <IActionResult> Index(string category, string manufacturer, int?priceMin, int?priceMax, string keywords, int?pageNumber, SortByFilter sortBy = SortByFilter.NewestArrivals)
        {
            const int         pageSize = 16;
            IQueryable <Item> items    = Context.Items.Where(i => i.Active);

            List <string> categories = items.Select(i => i.Category).Distinct().ToList();

            if (!string.IsNullOrWhiteSpace(category) && category != "All Categories")
            {
                items = items.Where(item => item.Category == category);
            }

            if (!string.IsNullOrWhiteSpace(manufacturer))
            {
                items = items.Where(item => item.Manufacturer == manufacturer);
            }

            if (priceMin > 0)
            {
                items = items.Where(item => item.Price >= priceMin);
            }

            if (priceMax > 0)
            {
                items = items.Where(item => item.Price <= priceMax);
            }

            if (!string.IsNullOrWhiteSpace(keywords))
            {
                items = items.Where(item =>
                                    item.Title.ToLower().Contains(keywords.ToLower()) ||
                                    item.Manufacturer.ToLower().Contains(keywords.ToLower()));
            }

            items = sortBy switch
            {
                SortByFilter.NewestArrivals => items.OrderByDescending(i => i.Id),
                SortByFilter.PriceLowToHigh => items.OrderBy(i => i.Price),
                SortByFilter.PriceHighToLow => items.OrderByDescending(i => i.Price),
                _ => throw new ArgumentOutOfRangeException(nameof(sortBy), sortBy, null)
            };

            List <string> manufactures = items.Select(i => i.Manufacturer).Distinct().ToList();

            PaginatedList <Item> paginatedList = await PaginatedList <Item> .CreateAsync(items.AsNoTracking(), pageNumber ?? 1, pageSize);

            var viewModel = new GetItemsViewModel()
            {
                Categories     = categories,
                Manufactures   = manufactures,
                Items          = items.ToArray(),
                PaginatedItems = paginatedList,
                ItemsFilter    = new ItemsFilter()
                {
                    Category     = category,
                    Manufacturer = manufacturer,
                    SortBy       = sortBy,
                    PriceMin     = priceMin,
                    PriceMax     = priceMax,
                    Keywords     = keywords
                },
                ItemsInCart = await CountItemsInCart()
            };

            return(View(viewModel));
        }