public static ResponseViewModel <PageViewModel <GetCategoryList_Result> > GetProductCategoryList(SearchViewModel searchViewModel) { using (EcommerceEntities entities = new EcommerceEntities()) { ResponseViewModel <PageViewModel <GetCategoryList_Result> > ViewModel = new ResponseViewModel <PageViewModel <GetCategoryList_Result> >(); List <GetCategoryList_Result> getProductResult = new List <GetCategoryList_Result>(); PageViewModel <GetCategoryList_Result> pageViewModel = new PageViewModel <GetCategoryList_Result>(); getProductResult = entities.GetCategoryList(searchViewModel.pageIndex, searchViewModel.pageSize, searchViewModel.searchText == "" ? null : searchViewModel.searchText, searchViewModel.sortOrder, searchViewModel.sortColoumn).ToList(); pageViewModel.Data = getProductResult; pageViewModel.totalRecords = getProductResult.Count(); if (((pageViewModel.totalRecords % searchViewModel.pageSize) == 0)) { if (pageViewModel.totalRecords < searchViewModel.pageSize) { pageViewModel.totalPage = 1; } else { pageViewModel.totalPage = (pageViewModel.totalRecords / searchViewModel.pageSize); } } else { pageViewModel.totalPage = (pageViewModel.totalRecords / 10) + 1; } ViewModel.Data = pageViewModel; return(ViewModel); } }