public static SageFrameUserCollection GetAllUsers() { string sp = "[dbo].[usp_UsersGetAll]"; SQLHandler sagesql = new SQLHandler(); SageFrameUserCollection userColl = new SageFrameUserCollection(); List <UserInfo> lstUsers = new List <UserInfo>(); try { SqlDataReader reader; reader = sagesql.ExecuteAsDataReader(sp); while (reader.Read()) { UserInfo obj = new UserInfo(); obj.UserID = new Guid(reader["userid"].ToString()); obj.UserName = reader["username"].ToString(); obj.FirstName = reader["firstname"].ToString(); obj.LastName = reader["lastname"].ToString(); obj.Email = reader["email"].ToString(); lstUsers.Add(obj); } reader.Close(); userColl.UserList = lstUsers; return(userColl); } catch (Exception ex) { throw (ex); } }
/// <summary> /// Connect to database and search application user. /// </summary> /// <param name="RoleID">RoleID</param> /// <param name="SearchText">Search text.</param> /// <param name="PortalID">PortalID</param> /// <param name="UserName">User name.</param> /// <returns>Object of SageFrameUserCollection class.</returns> public static SageFrameUserCollection SearchUsers(string RoleID, string SearchText, int PortalID, string UserName) { string sp = "[dbo].[usp_SageFrameUserListSearch]"; SageFrameSQLHelper sagesql = new SageFrameSQLHelper(); SageFrameUserCollection userColl = new SageFrameUserCollection(); List <UserInfo> lstUsers = new List <UserInfo>(); List <KeyValuePair <string, object> > ParamCollInput = new List <KeyValuePair <string, object> >(); ParamCollInput.Add(new KeyValuePair <string, object>("@RoleID", RoleID)); ParamCollInput.Add(new KeyValuePair <string, object>("@SearchText", SearchText)); ParamCollInput.Add(new KeyValuePair <string, object>("@PortalID", PortalID)); ParamCollInput.Add(new KeyValuePair <string, object>("@UserName", UserName)); SqlDataReader reader = null; try { reader = sagesql.ExecuteAsDataReader(sp, ParamCollInput); while (reader.Read()) { UserInfo obj = new UserInfo(); obj.UserID = new Guid(reader["userid"].ToString()); obj.UserName = reader["username"].ToString(); obj.FirstName = reader["firstname"].ToString(); obj.LastName = reader["lastname"].ToString(); obj.Email = reader["email"].ToString(); obj.IsActive = bool.Parse(reader["IsActive"].ToString()); obj.AddedOn = DateTime.Parse(reader["AddedOn"].ToString()); lstUsers.Add(obj); } reader.Close(); userColl.UserList = lstUsers; return(userColl); } catch (Exception ex) { throw (ex); } finally { if (reader != null) { reader.Close(); } } }
protected bool EmailAddressExists(string email, bool AllowDuplicateEmail) { bool status = false; Guid UserID = new Guid(hdnEditUserID.Value); if (!AllowDuplicateEmail) { SageFrameUserCollection userColl = m.GetAllUsers(); status = userColl.UserList.Exists( delegate(UserInfo obj) { return(obj.Email == email && obj.UserID != UserID); } ); } return(status); }