public ActionResult MainInfo(string dataSearch, int?pageNo) { BrandSearchViewModel model = new BrandSearchViewModel(); pageNo = pageNo.HasValue? pageNo.Value > 0 ? pageNo.Value : 1 : 1; int pageSize = int.Parse(BasicConfigService.Instance.GetBasicConfiguration("ListingPageSize").ConfigDescription); int TotalRecords = 0; if (!String.IsNullOrEmpty(dataSearch)) { model.SearchTerm = dataSearch; } TotalRecords = BrandsService.Instance.GetBrandsCount(dataSearch); model.brand = BrandsService.Instance.GetBrands(dataSearch, pageNo.Value); if (model.brand != null) { model.pager = new Pager(TotalRecords, pageNo, pageSize); return(PartialView(model)); } else { return(HttpNotFound()); } }
public ActionResult List(BrandSearchViewModel model) { int pageIndex = model.Page ?? 1; var data = _brandservice.GetList(x => (string.IsNullOrEmpty(model.BrandName) || x.Name.ToLower().Contains(model.BrandName.ToLower()))); List <BrandListViewModel> list = new List <BrandListViewModel>(); foreach (var item in data) { BrandListViewModel _brand = new BrandListViewModel(); _brand.BrandName = item.Name; _brand.Id = item.Id; _brand.OrderNo = item.OrderNo; list.Add(_brand); } model.BrandList = list.ToPagedList(pageIndex, 10); if (Request.IsAjaxRequest()) { return(PartialView("_BrandList", model)); } return(View(model)); }