// [Authorize(Roles = "RoleViewUser")] public ActionResult ListUsers(bool? showInactive, string searchText, int? userType, int page = 1, int itemsperpage = 10) { ViewBag.UserList = _userViewModelBuilder.utsDistributor(); //string filter = userType; try { if (itemsperpage != null) { ViewModelBase.ItemsPerPage = itemsperpage; } bool showinactive = false; if (showInactive != null) showinactive = (bool)showInactive; ViewBag.showInactive = showinactive; if (TempData["msg"] != null) { ViewBag.msg = TempData["msg"].ToString(); TempData["msg"] = null; } ViewBag.searchParam = searchText; int currentPageIndex = page < 0 ? 0 : page - 1; int take = itemsperpage; int skip = currentPageIndex*take; var query = new QueryUsers() { ShowInactive = showinactive, Name = searchText, Skip = skip, Take = take, }; List<int> userTypes; if(userType.HasValue) { userTypes = new List<int>(); userTypes.Add(userType.Value); query.UserTypes = userTypes; } var ls = _userViewModelBuilder.Query(query); var data = ls.Data; var count = ls.Count; return View(data.ToPagedList(currentPageIndex, ViewModelBase.ItemsPerPage, count)); } catch (Exception ex) { ViewBag.lsUsers = ex.ToString(); return View(); } }
public ActionResult ListAgriUsers(bool? showInactive, string userType, int itemsperpage = 10, int page = 1, string srchParam="") { try { if (itemsperpage != null) { ViewModelBase.ItemsPerPage = itemsperpage; } bool showinactive = false; if (showInactive != null) showinactive = (bool)showInactive; ViewBag.showInactive = showinactive; if (TempData["msg"] != null) { ViewBag.msg = TempData["msg"].ToString(); TempData["msg"] = null; } ViewBag.SearchParam = srchParam; int currentPageIndex = page - 1 < 0 ? 0 : page - 1; int take = itemsperpage; int skip = currentPageIndex*take; // var listOfUsers =new List<int>(); //listOfUsers.Add((int)UserType.HubManager); //listOfUsers.Add((int)UserType.Clerk); //listOfUsers.Add((int)UserType.PurchasingClerk); //listOfUsers.Add(()); var query = new QueryUsers() { Name = srchParam, ShowInactive = showinactive, Skip = skip, Take = take }; var ls = _agriUserViewModelBuilder.Query(query); var data = ls.Data; var count = ls.Count; return View(data.ToPagedList(currentPageIndex, ViewModelBase.ItemsPerPage, count)); } catch (Exception ex) { ViewBag.lsUsers = ex.ToString(); return View(); } }
public ActionResult ListAllUsers(bool? showInactive, string searchText, int itemsperpage = 10, int page = 1) { try { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); if (itemsperpage != null) { ViewModelBase.ItemsPerPage = itemsperpage; } bool showinactive = false; if (showInactive != null) showinactive = (bool) showInactive; ViewBag.showInactive = showinactive; ViewBag.searchParam = searchText; int currentPageIndex = page < 0 ? 0 : page - 1; int take = itemsperpage; int skip = currentPageIndex*take; var query = new QueryUsers(); query.ShowInactive = showinactive; query.Skip = skip; query.Take = take; query.Name = searchText; var result = _userViewModelBuilder.SupplierQuery(query); var count = result.Count; var data = result.Data; if (Session["msg"] != null) { ViewBag.msg = Session["msg"].ToString(); Session["msg"] = null; } stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; // Format and display the TimeSpan value. string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.TotalMilliseconds); stopWatch.Reset(); _auditLogViewModelBuilder.AddAuditLog(this.User.Identity.Name, "Timestamp", "Supplier User Controller:" + elapsedTime, DateTime.Now); return View(data.ToPagedList(currentPageIndex, ViewModelBase.ItemsPerPage, count)); } catch (DomainValidationException dve) { ValidationSummary.DomainValidationErrors(dve, ModelState); return View(); } catch (Exception ex) { _log.Debug("Failed to list supplier" + ex.Message); _log.Error("Failed to list supplier" + ex.ToString()); return View(); } }
public QueryResult<AgriUserViewModel> Query(QueryUsers query) { var queryResult = _userRepository.Query(query); var result = new QueryResult<AgriUserViewModel>(); result.Data = queryResult.Data.OfType<User>().ToList().Select(Map).ToList(); result.Count = queryResult.Count; return result; }
public ActionResult ResetHqUserPassword(Boolean? showInactive, string searchParam = "", int page = 1) { bool showinactive = false; if (showInactive != null) showinactive = (bool) showInactive; ViewBag.showInactive = showinactive; ViewBag.costCentre = TempData["costCentre"]; if (TempData["msgHqPass"] != null) { ViewBag.msg = TempData["msgHqPass"].ToString(); } // var ls = _userViewModelBuilder.GetHqUsers(showinactive); int currentPageIndex = page - 1 < 0 ? 0 : page - 1; var take = DistributorWebHelper.GetItemPerPage(); var skip = currentPageIndex*take; var query = new QueryUsers {Name = searchParam, ShowInactive = showinactive, Skip = skip, Take = take}; var ls = _userViewModelBuilder.Query(query); var total = ls.Count; var data = ls.Data; // var data = item.ToPagedList(currentPageIndex, take, total); return View(data.ToPagedList(currentPageIndex, take, total)); }