public IActionResult Create(SearchViewModel vm) { if (vm == null) { vm = new SearchViewModel(); } var unitOfMeasureList = _unitOfMeasureService.SpGetAllUnitOfMeasure(vm.Keyword, vm.PageIndex, vm.PageSize); var dep = new List <UnitOfMeasureViewModel>(); foreach (var unitOfMeasure in unitOfMeasureList) { var unitOfMeasureVm = convertToVm(unitOfMeasure); dep.Add(unitOfMeasureVm); } var first = dep.FirstOrDefault() ?? new UnitOfMeasureViewModel(); var response = new StaticPagedList <UnitOfMeasureViewModel>(dep, vm.PageIndex, vm.PageSize, first.TotalCount ?? 0); return(View(response)); }