public ActionResult _Index1(ProductSourceSearch productSourceSearch, int?page) { int TotalCount = 0; var pageSize = 10; var pageNumber = page ?? 1; int CurrentPage = pageNumber; var endPage = CurrentPage + 4; int PagesToShow = 10; var body = JsonConvert.SerializeObject(productSourceSearch); var ProductSourceModelList = Services.ProductSourceService.GetSearchData(productSourceSearch, page, out TotalCount); ViewBag.TotalCount = TotalCount; ViewBag.PageSize = pageSize; var result = Helper.CommonFunction.GetPages(TotalCount, pageSize, CurrentPage, PagesToShow); int totalPages = (TotalCount / pageSize) + (TotalCount % pageSize == 0 ? 0 : 1); ViewBag.result = result; ViewBag.totalPages = totalPages; ViewBag.CurrentPage = CurrentPage; var pageCount = result.Count(); ViewBag.pageCount = pageCount; ViewBag.endPage = endPage; return(View(ProductSourceModelList)); }
public ServiceResult <List <ProductSource> > GetSearchData(ProductSourceSearch productSourceSearch) { ServiceResult <List <ProductSource> > model = new ServiceResult <List <ProductSource> >(); var source = db.ProductSources.Where(x => x.IsActive == true); var pageSize = 10; if (productSourceSearch != null) { if (!string.IsNullOrEmpty(productSourceSearch.Source)) { source = source.Where(m => m.Source.Contains(productSourceSearch.Source)); } } var result = source.ToList(); int count = result.Count(); var items = source.OrderByDescending(m => m.Id).Skip(((productSourceSearch.Page ?? 1) - 1) * pageSize).Take(pageSize).ToList(); model.data = items.Select(x => new ProductSource { Id = x.Id, Source = x.Source, }).ToList(); model.TotalCount = count; return(model); }
public List <ProductSourceModel> GetSearchData(ProductSourceSearch productSourceSearch, int?page, out int TotalCount) { //int pageSize = 10; int pageNumber = (page ?? 1); var body = JsonConvert.SerializeObject(productSourceSearch); var result = ServerResponse.Invoke <ServiceResult <List <ProductSourceModel> > >("api/productSource/getSearchData", body, "Post"); TotalCount = result.TotalCount; if (result.data != null) { var model = result.data.ToList(); return(model); } else { } return(result.data.ToList()); }