Exemple #1
0
        /// <summary>
        /// List user settings for a given user
        /// </summary>
        /// <returns></returns>
        public static List <FCMUserRole> ListRoleForUser(string userID)
        {
            var roleList = new List <FCMUserRole>();

            using (var connection = new SqlConnection(ConnString.ConnectionString))
            {
                var commandString = string.Format(
                    " SELECT " +
                    FieldName.FK_UserID + "," +
                    FieldName.FK_Role + " " +
                    "   FROM management.dbo.[FCMUserRole] " +
                    "  WHERE FK_UserID = '{0}' " +
                    "   ORDER BY FK_Role ASC ", userID
                    );

                using (var command = new SqlCommand(
                           commandString, connection))
                {
                    try
                    {
                        connection.Open();

                        using (SqlDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                var userRole = new FCMUserRole();

                                userRole.FK_UserID = reader[FieldName.FK_UserID].ToString();
                                userRole.FK_Role   = reader[FieldName.FK_Role].ToString();

                                // Check if document exists
                                //

                                roleList.Add(userRole);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        LogFile.WriteToTodaysLogFile(ex.ToString(), HeaderInfo.Instance.UserID);
                    }
                }
            }

            return(roleList);
        }
Exemple #2
0
        public List <FCMUserRole> UserRoleList(string userid)
        {
            List <FCMUserRole> rolelist = new List <FCMUserRole>();

            using (var connection = new SqlConnection(ConnString.ConnectionString))
            {
                var commandString = string.Format(
                    " SELECT  " +
                    "  [UniqueID] " +
                    " ,[FK_UserID]   " +
                    " ,[FK_Role] " +
                    " ,[StartDate] " +
                    " ,[EndDate] " +
                    " ,[IsActive] " +
                    " ,[IsVoid] " +
                    "   FROM [FCMUserRole] " +
                    " WHERE FK_UserID = '{0}'", userid);

                using (var command = new SqlCommand(
                           commandString, connection))
                {
                    connection.Open();
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            FCMUserRole fcmUserRole = new FCMUserRole();
                            fcmUserRole.UniqueID  = Convert.ToInt32(reader["UniqueID"].ToString());
                            fcmUserRole.FK_UserID = reader["FK_UserID"].ToString();
                            fcmUserRole.FK_Role   = reader["FK_Role"].ToString();
                            fcmUserRole.StartDate = Convert.ToDateTime(reader["StartDate"].ToString());
                            fcmUserRole.EndDate   = Convert.ToDateTime(reader["EndDate"]);
                            fcmUserRole.IsActive  = Convert.ToChar(reader["IsActive"]);
                            fcmUserRole.IsVoid    = Convert.ToChar(reader["IsVoid"]);

                            rolelist.Add(fcmUserRole);
                        }
                    }
                }
            }

            return(rolelist);
        }