// GET: Hardware public IActionResult Index(string sortOrder, string searchString) //public IActionResult Index(string sortOrder, string searchString, string currentFilter, int? pageNumber) { //ViewData["CurrentSort"] = sortOrder; ViewData["NameTypeSortParm"] = String.IsNullOrEmpty(sortOrder) ? "name_desc" : ""; ViewData["StatusSortParm"] = sortOrder == "Status" ? "status_desc" : "Status"; ViewData["ProductTypeSortParm"] = sortOrder == "ProductType" ? "productType_desc" : "ProductType"; ViewData["DescriptionSortParm"] = sortOrder == "Description" ? "description_desc" : "Description"; ViewData["SpecificationFileNameSortParm"] = sortOrder == "SpecificationFileName" ? "specificationFileName_desc" : "SpecificationFileName"; //if (searchString != null) //{ // pageNumber = 1; //} //else //{ // searchString = currentFilter; //} ViewData["CurrentFilter"] = searchString; //var hardwares = service.GetAllHardwareIQuery(searchString); var hardwares = service.GetAllHardwareEnum(searchString); switch (sortOrder) { case "name_desc": hardwares = hardwares.OrderByDescending(h => h.Name ?? "").ThenByDescending(h => h.Status.Name ?? ""); break; case "Status": hardwares = hardwares.OrderBy(s => s.Status.Name); break; case "status_desc": hardwares = hardwares.OrderByDescending(s => s.Status.Name); break; case "ProductType": hardwares = hardwares.OrderBy(s => s.ProductType.Name); break; case "productType_desc": hardwares = hardwares.OrderByDescending(s => s.ProductType.Name); break; case "Description": hardwares = hardwares.OrderBy(h => h.Description); break; case "description_desc": hardwares = hardwares.OrderByDescending(h => h.Description); break; case "SpecificationFileName": hardwares = hardwares.OrderBy(h => h.SpecificationFileName ?? ""); break; case "specificationFileName_desc": hardwares = hardwares.OrderByDescending(h => h.SpecificationFileName ?? ""); break; default: hardwares = hardwares.OrderBy(h => h.Name ?? "").ThenBy(h => h.Status.Name ?? ""); break; } //int pageSize = 3; //return View(PaginatedList<Hardware>.CreateAsync(hardwares.AsNoTracking(), pageNumber ?? 1, pageSize)); //List<Hardware> hardware = service.GetAllHardware(); return(View(hardwares)); }