public ActionResult Index(int page = 1, int itemsperpage = 10, bool showInactive = false, string srchParam = "") { if (TempData["msg"] != null) { ViewBag.msg = TempData["msg"].ToString(); TempData["msg"] = null; } try { ViewBag.srchParam = srchParam; ViewBag.showInactive = showInactive; int currentPageIndex = page - 1 < 0 ? 0 : page - 1; int take = itemsperpage; int skip = currentPageIndex * take; var query = new QueryCommodityProducerService { Skip = skip, Take = take, Name = srchParam, ShowInactive = showInactive }; var ls = _serviceRepository.Query(query); var total = ls.Count; var data = ls.Data.ToList(); return View(data.ToPagedList(currentPageIndex,take, total)); } catch (Exception ex) { TempData["msg"] = "Error loading Commodiy Producer Service\nDetails:" + ex.Message; } return View(); }
protected override void Load(bool isFirstLoad = false) { Application.Current.Dispatcher.BeginInvoke( new Action( delegate { // if (isFirstLoad) using (var c = NestedContainer) { var query = new QueryCommodityProducerService(); query.Take = ItemsPerPage; query.Skip = ItemsPerPage * (CurrentPage - 1); query.ShowInactive = ShowInactive; if (!string.IsNullOrWhiteSpace(SearchText)) query.Name = SearchText; var rawList = Using<IServiceRepository>(c).Query(query); _pagedCommodityProducerService = new PagenatedList<CommodityProducerService>(rawList.Data.OfType<CommodityProducerService>().AsQueryable(), CurrentPage, ItemsPerPage, rawList.Count, true); ListOfCommodityProducerServices.Clear(); int rownumber = 0; _pagedCommodityProducerService.ToList().ForEach(n => ListOfCommodityProducerServices.Add(new VmCommodityProducerService { Id = n.Id, Code = n.Code, Name = n.Name, Cost=n.Cost, Status = n._Status, Action = n._Status == EntityStatus.Active ? "Deactivate" : "Activate", RowNumber = ++rownumber })); UpdatePagenationControl(); } })); }
public ActionResult Index(int page = 1, int itemsperpage = 10, bool showInactive = false, string srchParam = "",string srch="") { try { string command = srch; bool showinactive = false; if (showInactive != null) showinactive = (bool)showInactive; ViewBag.showInactive = showinactive; if (TempData["msg"] != null) { ViewBag.msg = TempData["msg"].ToString(); TempData["msg"] = null; } if(srch=="Search") { ViewBag.showInactive = showInactive; int currentPageIndex = page - 1 < 0 ? 0 : page - 1; int take = itemsperpage; int skip = currentPageIndex * take; var query = new QueryCommodityProducerService { Skip = skip, Take = take, Name = srchParam, ShowInactive = showInactive }; var result = _serviceRepository.Query(query); var item = result.Data.Cast<CommodityProducerService>().ToList(); int total = result.Count; var data = item.ToPagedList(currentPageIndex, take, total); return View(data); } return RedirectToAction("Index", new { showInactive = showInactive, srch = "Search", srchParam = "" }); } catch (Exception ex) { TempData["msg"] = "Error loading Commodiy Producer Service\nDetails:" + ex.Message; } return View(); }