public ActionResult Index(UserViewModel model) { int currentPage = 1; int pageSize = AdminSettings.PageSize; try { model.AllRoles = RoleManager.Roles.OrderBy(m => m.Name).ToList(); } catch { } if (string.IsNullOrEmpty(model.SearchExec)) { model.SearchExec = "Y"; if (!ModelState.IsValid) { ModelState.Clear(); } } if (Request["Page"] != null) { currentPage = Utils.ConvertToInt32(Request["Page"], 0); } try { var isLocked = Convert.ToBoolean(model.IsLocked); model.SearchResult = _identityStore.FilterUserList(model.Email, model.RoleId, isLocked, currentPage, pageSize); model.Total = _identityStore.CountAll(model.Email, model.RoleId, isLocked); model.CurrentPage = currentPage; model.PageNo = (int)(model.Total / pageSize); model.PageSize = pageSize; if (model.SearchResult != null && model.SearchResult.Count > 0) { foreach (var record in model.SearchResult) { var _userRoles = UserManager.GetRoles(record.Id); var _newModelUser = new IdentityUser(); _newModelUser = record; if (_userRoles != null) { _newModelUser.Roles = _userRoles.ToList(); } } } } catch (Exception ex) { this.AddNotification("Failed to get data because: " + ex.ToString(), NotificationType.ERROR); return(View(model)); } return(View(model)); }