public void OnGet(Clothing clothing, int pageIndex, int?CategoryId) { string userId; Categories = db.Categories.ToList(); //if (User.Identity.IsAuthenticated) //{ userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; if (CategoryId != null) { Clothes = db.Clothes.Where(c => c.CategoryId == CategoryId && c.OwnerId == userId); } else { Clothes = db.Clothes .Where(c => c.OwnerId == userId); } if (clothing.ClothName != null) { Clothing = clothing; } // filter foreach (var item in Clothes) { if (!item.IsClean) { isDirty.Add(item); } } if (isDirty.Count > 3) { msg = $"You have {isDirty.Count} items in your dirty pile. Time to do laundry!"; popoverclass = "fas fa-bell text-danger"; } else { msg = "No new notifications at this time"; popoverclass = "fas fa-bell"; } //} // --------- PAGINATION --------- int totalItems = Clothes.Count(); Clothes = Clothes.Skip(pageIndex * ITEMS_PER_PAGE).Take(ITEMS_PER_PAGE); PaginationInfo = new PaginationInfoVM() { PageIndex = pageIndex, ItemsPerPage = Clothes.Count(), TotalItems = totalItems, TotalPages = int.Parse(Math.Ceiling(((decimal)totalItems / ITEMS_PER_PAGE)).ToString()), }; PaginationInfo.Previous = PaginationInfo.PageIndex == 0 ? "is-disabled" : ""; PaginationInfo.Next = PaginationInfo.PageIndex == PaginationInfo.TotalPages - 1 ? "is-disabled" : ""; }