Exemple #1
0
        /// <summary>
        ///   The overloaded Load method that will return a <see cref="UserRoleCollection"/>.
        /// </summary>
        /// <param name="aUserKey">A <see cref="UserKey"/> object.</param>
        /// <param name="aUserRoleCollection">A <see cref="UserRoleCollection"/> object.</param>
        /// <exception cref="ArgumentNullException">If <c>aUserRoleCollection</c> argument is <c>null</c>.</exception>
        public static void Load(UserKey aUserKey, UserRoleCollection aUserRoleCollection)
        {
            if (aUserRoleCollection == null)
            {
                throw new ArgumentNullException("Load UserRole Business");
            }

            if (!UserFunctionAccessData.HasModeAccess(aUserKey, "UserRole", AccessMode.List))
            {
                throw new ZpAccessException("Access Denied", String.Format("{0}", aUserKey.UsrKey), AccessMode.List, "UserRole");
            }

            UserRoleData.Load(aUserRoleCollection);
        }
 /// <summary>
 ///   The <c>GetUserRoleCollection</c> implementation method deserializes an incoming XML Argument <see cref="string"/> as a new <see cref="UserRoleCollection"/> object.
 ///   It invokes the <c>Insert</c> method of <see cref="UserRoleBusiness"/> with the newly deserialized <see cref="UserRoleCollection"/> object.
 ///   Finally, it returns the collection object as a serialized <see cref="string"/> of XML.
 /// </summary>
 /// <param name="aXmlArgument">XML Argument <see cref="string"/>.</param>
 /// <returns><see cref="UserRoleCollection"/> as XML <see cref="string"/>.</returns>
 /// <exception cref="ArgumentNullException">If <c>aXmlArgument</c> is <c>null</c>.</exception>
 public static string GetUserRoleCollection(UserKey aUserKey, string aXmlArgument)
 {
     if (aXmlArgument == null)
     {
         throw new ArgumentNullException("aXmlArgument of GetUserRoleCollection");
     }
     UserRoleCollection vUserRoleCollection = new UserRoleCollection();
     vUserRoleCollection = XmlUtils.Deserialize<UserRoleCollection>(aXmlArgument);
     UserRoleBusiness.Load(aUserKey, vUserRoleCollection);
     return XmlUtils.Serialize<UserRoleCollection>(vUserRoleCollection, true);
 }
Exemple #3
0
 /// <summary>
 ///   The overloaded Load method that will fill the <c>UserRoleList</c> property a <see cref="UserRoleCollection"/> object as an
 ///   ordered <c>List</c> of <see cref="UserRole"/>, filtered by the filter properties of the passed <see cref="UserRoleCollection"/>.
 /// </summary>
 /// <param name="aUserRoleCollection">The <see cref="UserRoleCollection"/> object that must be filled.</param>
 /// <remarks>
 ///   The filter properties of the <see cref="UserRoleCollection"/> must be correctly completed by the calling application.
 /// </remarks>
 /// <exception cref="ArgumentNullException">If <c>aUserRoleCollection</c> argument is <c>null</c>.</exception>
 public static void Load(UserRoleCollection aUserRoleCollection)
 {
     if (aUserRoleCollection == null)
     {
         throw new ArgumentNullException("aUserRoleCollection");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         if (aUserRoleCollection.IsFiltered)
         {
             if (aUserRoleCollection.UserKeyFilter > 0)
             {
                 vStringBuilder.AppendLine("and    t1.USR_Key = @USRKey");
                 vSqlCommand.Parameters.AddWithValue("@USRKey", aUserRoleCollection.UserKeyFilter);
             }
         }
         vStringBuilder.AppendLine("order by t2.URL_Key");
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             while (vSqlDataReader.Read())
             {
                 var vUserRole = new UserRole();
                 DataToObject(vUserRole, vSqlDataReader);
                 aUserRoleCollection.UserRoleList.Add(vUserRole);
             }
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }