// GET: Students public async Task <IActionResult> Index( ListingFilterSortPageDto filterSortPageDto, [FromServices] IStudentService service) { PaginatedListDto <StudentListItem> paginatedList = null; try { paginatedList = await service.ListAllStudentssAsync(filterSortPageDto); // set the final page index based on the latest database records available filterSortPageDto.PageIndex = paginatedList.PageIndex; } catch (GeneralException ex) { _logger.LogError("GeneralException in Index: " + ex.Message); ViewBag.HasError = true; ViewBag.Message = ex.Message; } catch (Exception ex) { _logger.LogError("Exception in Index: " + ex.Message); ViewBag.HasError = true; ViewBag.Message = Constants.ERROR_MESSAGE_STANDARD + ": " + ex.Message; } var studentListDto = new StudentListDto { FilterSortPageValues = filterSortPageDto, Listing = paginatedList }; return(View($"{_viewFolder}Index.cshtml", studentListDto)); }
public IActionResult GetPartialResults(PartialResultRequestDto data) { data.SortOrder = string.IsNullOrEmpty(data.SortOrder) ? "Name" : data.SortOrder; ViewData["CurrentSort"] = data.SortOrder; ViewData["CurrentDesc"] = data.AscOrDescOrder; ViewData["ItemsPerPage"] = data.ItemsPerPage ?? ITEMS_PER_PAGE; if (data.SortOrder == "Id") { ViewData["IdAsc"] = !data.AscOrDescOrder; ViewData["IdStyle"] = data.AscOrDescOrder ? "fa fa-sort-desc" : "fa fa-sort-asc"; } if (data.SortOrder == "Nombre") { ViewData["NombreDesc"] = !data.AscOrDescOrder; ViewData["NombreStyle"] = data.AscOrDescOrder ? "fa fa-sort-desc" : "fa fa-sort-asc"; } if (string.IsNullOrEmpty(data.SearchString)) { data.SearchString = data.CurrentFilter; } List <Tuple <ColorOrders, bool> > orderList = new List <Tuple <ColorOrders, bool> >(); if (!string.IsNullOrEmpty(data.SortOrder)) { orderList.Add(new Tuple <ColorOrders, bool>(EnumUtils.ParseEnum <ColorOrders>(data.SortOrder), data.AscOrDescOrder)); } data.ItemsPerPage = data.ItemsPerPage > LIMIT_PAGES ? LIMIT_PAGES : data.ItemsPerPage; PaginatedListDto <ColorDto, ColorOrders> page = _coloresService.GetPaged( new PaginatedListRequest <ColorOrders>() { CurrentPage = data.PageNumber, PageSize = data.ItemsPerPage ?? ITEMS_PER_PAGE, MultiSearch = data.SearchString, OrderList = orderList } ); return(PartialView("_Results", page)); }