Beispiel #1
0
        public async Task <IActionResult> InventoryList(int?page)
        {
            const int PageSize = 2;
            // Null coalescing operator
            int pageNumber = page ?? 1;

            ViewData["CurrentPage"] = pageNumber;

            ViewData["MaxPage"] = await GetMaxPage(PageSize);

            List <Clothing> clothes = await ClothingDB.GetClothingByPage(_context, pageNum : pageNumber, pageSize : PageSize);

            return(View(clothes));
        }
        public async Task <IActionResult> ShowAll(int?page) // method must begin with await, await req's async after public, and a task return.: ? is nullable
        {
            const int PageSize = 2;                         // default number of items per page

            //int pageNumber = page ?? 1; // null coalescing operator ?? (https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-coalescing-operator)
            int pageNumber = page.HasValue ? page.Value : 1; // conditional statement ?

            ViewData["CurrentPage"] = pageNumber;

            int maxPage = await GetMaxPage(PageSize); // How many pages, always rounds up

            ViewData["MaxPage"] = maxPage;            // put in view data so we can use it in our view

            List <Clothing> clothes = await ClothingDB.GetClothingByPage(_context, pageNum : pageNumber, pageSize : PageSize);

            return(View(clothes));
        }
Beispiel #3
0
        public async Task <IActionResult> ShowAll(int?page)
        {
            const int PageSize = 2;

            // Null-coalescing operator: ??
            // https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-coalescing-operator
            int pageNumber = page ?? 1;

            ViewData["CurrentPage"] = pageNumber;

            int maxPage = await GetMaxPage(PageSize);

            ViewData["MaxPage"] = maxPage;

            List <Clothing> clothes = await ClothingDB.GetClothingByPage(_context, pageNum : pageNumber, pageSize : PageSize);

            return(View(clothes));
        }