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.showInactive = showInactive; ViewBag.srchParam = srchParam; int currentPageIndex = page - 1 < 0 ? 0 : page - 1; int take = itemsperpage; int skip = currentPageIndex * take; var query = new QuerySeason { Skip = skip, Take = take, Name = srchParam, ShowInactive = showInactive }; var ls = _seasonRepository.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 Agrimanagr Settings\nDetails:" + ex.Message; } return View(); }
protected override void Load(bool isFirstLoad = false) { Application.Current.Dispatcher.BeginInvoke( new Action( delegate { if (isFirstLoad) Setup(); using (var c = NestedContainer) { var query = new QuerySeason(); query.Take = ItemsPerPage; query.Skip = ItemsPerPage * (CurrentPage - 1); query.ShowInactive = ShowInactive; if (!string.IsNullOrWhiteSpace(SearchText)) query.Name = SearchText; var rawList = Using<ISeasonRepository>(c).Query(query); _pagedSeasons = new PagenatedList<Season>(rawList.Data.OfType<Season>().AsQueryable(), CurrentPage, ItemsPerPage, rawList.Count, true); ListOfSeasons.Clear(); int rownumber = 0; _pagedSeasons.ToList().ForEach(n => ListOfSeasons.Add(new VmSeason { Id = n.Id, Code = n.Code, Name=n.Name, StartDate=n.StartDate.Date, EndDate=n.EndDate.Date, 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; //if (showInactive != null) // showinactive = (bool)showInactive; //showinactive = false; 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 QuerySeason { Skip = skip, Take = take, Name = srchParam, ShowInactive = showInactive }; var result = _seasonRepository.Query(query); var item = result.Data.Cast<Season>().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) { ViewBag.msg = ex.Message; return View(); } }