Esempio n. 1
0
 /// <summary>
 ///   Insert a <see cref="ContributorLanguage"/> passed as an argument via Stored Procedure that returns the newly inserted ContributorLanguage Key 
 /// </summary>
 /// <param name="aContributorLanguage">A <see cref="ContributorLanguage"/>.</param>
 /// <exception cref="ArgumentNullException">If <c>aContributorLanguage</c> argument is <c>null</c>.</exception>
 public static void Insert(ContributorLanguage aContributorLanguage)
 {
     if (aContributorLanguage == null)
     {
         throw new ArgumentNullException("aContributorLanguage");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("insert into CTL_ContributorLanguage");
         vStringBuilder.AppendLine("       (CON_Key, LAN_Key, CTL_Rating)");
         vStringBuilder.AppendLine("values");
         vStringBuilder.AppendLine("       (@CONKey, @LANKey, @CTLRating)");
         ObjectToData(vSqlCommand, aContributorLanguage);
         vSqlCommand.Parameters.AddWithValue("@CONKey", aContributorLanguage.ConKey);
         vSqlCommand.Parameters.AddWithValue("@LANKey", aContributorLanguage.LanKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Esempio n. 2
0
 /// <summary>
 ///   Load a <see cref="SqlDataReader"/> into a <see cref="ContributorLanguage"/> object.
 /// </summary>
 /// <param name="aContributorLanguage">A <see cref="ContributorLanguage"/> argument.</param>
 /// <param name="aSqlDataReader">A <see cref="SqlDataReader"/> argument.</param>
 public static void DataToObject(ContributorLanguage aContributorLanguage, SqlDataReader aSqlDataReader)
 {
     aContributorLanguage.ConKey = Convert.ToInt32(aSqlDataReader["CON_Key"]);
     aContributorLanguage.LanKey = Convert.ToInt32(aSqlDataReader["LAN_Key"]);
     aContributorLanguage.Rating = (LanguageLevelRating)(Convert.ToInt32(aSqlDataReader["CTL_Rating"]));
     aContributorLanguage.LanguageName = Convert.ToString(aSqlDataReader["LAN_Name"]);
     aContributorLanguage.LanguageName = Convert.ToString(aSqlDataReader["LAN_EnglishName"]);
 }
Esempio n. 3
0
 /// <summary>
 ///   The <c>AddContributorLanguage</c> implementation method deserializes an incoming XML Argument <see cref="string"/> as a new <see cref="ContributorLanguage"/> object.
 ///   It invokes the <c>Insert</c> method of <see cref="ContributorLanguageBusiness"/> with the newly deserialized <see cref="ContributorLanguage"/> object.
 ///   Finally, it returns the inserted object (now with an assigned ContributorLanguage Key) as a serialized <see cref="string"/> of XML.
 /// </summary>
 /// <param name="aXmlArgument">XML Argument <see cref="string"/>.</param>
 /// <returns><see cref="ContributorLanguage"/> as XML <see cref="string"/>.</returns>
 /// <exception cref="ArgumentNullException">If <c>aXmlArgument</c> is <c>null</c>.</exception>
 public static string AddContributorLanguage(UserKey aUserKey, string aXmlArgument)
 {
     if (aXmlArgument == null)
     {
         throw new ArgumentNullException("aXmlArgument of AddContributorLanguage");
     }
     ContributorLanguage vContributorLanguage = new ContributorLanguage();
     vContributorLanguage = XmlUtils.Deserialize<ContributorLanguage>(aXmlArgument);
     ContributorLanguageBusiness.Insert(aUserKey, vContributorLanguage);
     return XmlUtils.Serialize<ContributorLanguage>(vContributorLanguage, true);
 }
        /// <summary>
        ///   The overloaded Load method that will return a specific <see cref="ContributorLanguage"/> object, with keys in <c>aContributorLanguage</c>.
        /// </summary>
        /// <param name="aUserKey">A <see cref="UserKey"/> object.</param>
        /// <param name="aContributorLanguage">A <see cref="ContributorLanguage"/>.</param>
        /// <exception cref="ArgumentNullException">If <c>aContributorLanguage</c> is <c>null</c>.</exception>
        public static void Load(UserKey aUserKey, ContributorLanguage aContributorLanguage)
        {
            if (aContributorLanguage == null)
            {
                throw new ArgumentNullException("Load ContributorLanguage Business");
            }

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

            ContributorLanguageData.Load(aContributorLanguage);
        }
        /// <summary>
        ///    Assigns all <c>aSource</c> object's values to this instance of <see cref="ContributorLanguageCollection"/>.
        /// </summary>
        /// <param name="aSource">A source object.</param>
        public override void AssignFromSource(object aSource)
        {
            if (!(aSource is ContributorLanguageCollection))
            {
                throw new ArgumentException("Invalid assignment source", "ContributorLanguageCollection");
            }

            _contributorLanguageFilter.AssignFromSource((aSource as ContributorLanguageCollection)._contributorLanguageFilter);
            _contributorLanguageList.Clear();
            (aSource as ContributorLanguageCollection)._contributorLanguageList.ForEach(vContributorLanguageSource =>
            {
                ContributorLanguage vContributorLanguageTarget = new ContributorLanguage();
                vContributorLanguageTarget.AssignFromSource(vContributorLanguageSource);
                _contributorLanguageList.Add(vContributorLanguageTarget);
            });
        }
Esempio n. 6
0
 /// <summary>
 ///   Delete a <see cref="ContributorLanguage"/> object passed as an argument.
 /// </summary>
 /// <param name="aContributorLanguage">The <see cref="ContributorLanguage"/> object to be deleted.</param>
 /// <exception cref="ArgumentNullException">If <c>aContributorLanguage</c> argument is <c>null</c>.</exception>
 public static void Delete(ContributorLanguage aContributorLanguage)
 {
     if (aContributorLanguage == null)
     {
         throw new ArgumentNullException("aContributorLanguage");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("delete CTL_ContributorLanguage");
         vStringBuilder.AppendLine("where  CON_Key = @CONKey");
         vStringBuilder.AppendLine("and    LAN_Key = @LANKey");
         vSqlCommand.Parameters.AddWithValue("@CONKey", aContributorLanguage.ConKey);
         vSqlCommand.Parameters.AddWithValue("@LANKey", aContributorLanguage.LanKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Esempio n. 7
0
 /// <summary>
 ///   Add a <see cref="ContributorLanguage"/>.
 /// </summary>
 /// <param name="aUserToken">A <see cref="UserToken"/> object used for Access Control.</param>
 /// <param name="aContributorLanguage"><see cref="ContributorLanguage"/> object.</param>
 public static void AddContributorLanguage(UserToken aUserToken, ContributorLanguage aContributorLanguage)
 {
     UserCallHandler.ServiceCall<ContributorLanguage>(aUserToken, "AddContributorLanguage", aContributorLanguage);
 }
Esempio n. 8
0
 /// <summary>
 ///   Update a <see cref="ContributorLanguage"/> passed as an argument .
 /// </summary>
 /// <param name="aContributorLanguage">A <see cref="ContributorLanguage"/>.</param>
 public static void Update(ContributorLanguage aContributorLanguage)
 {
     if (aContributorLanguage == null)
     {
         throw new ArgumentNullException("aContributorLanguage");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("update CTL_ContributorLanguage");
         vStringBuilder.AppendLine("set    CTL_Rating = @CTLRating");
         vStringBuilder.AppendLine("where  CON_Key = @CONKey");
         vStringBuilder.AppendLine("and    LAN_Key = @LANKey");
         ObjectToData(vSqlCommand, aContributorLanguage);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Esempio n. 9
0
 /// <summary>
 ///   Loads the <see cref="SqlCommand"/> parameters with values from an <see cref="ContributorLanguage"/>.
 /// </summary>
 /// <param name="aSqlCommand">A <see cref="SqlDataReader"/> argument.</param>
 /// <param name="aContributorLanguage">A <see cref="ContributorLanguage"/> argument.</param>
 public static void ObjectToData(SqlCommand aSqlCommand, ContributorLanguage aContributorLanguage)
 {
     aSqlCommand.Parameters.AddWithValue("@CTLRating", aContributorLanguage.Rating);
 }
Esempio n. 10
0
 /// <summary>
 ///   The overloaded Load method that will return a specific <see cref="ContributorLanguage"/>, with keys in the <c>aContributorLanguage</c> argument.
 /// </summary>
 /// <param name="aContributorLanguage">A <see cref="ContributorLanguage"/>.</param>
 /// <exception cref="ArgumentNullException">If <c>aContributorLanguage</c> argument is <c>null</c>.</exception>
 /// <exception cref="Exception">If no record is found.</exception>
 public static void Load(ContributorLanguage aContributorLanguage)
 {
     if (aContributorLanguage == null)
     {
         throw new ArgumentNullException("aContributorLanguage");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         vStringBuilder.AppendLine("and    contributor.CON_Key = @CONKey");
         vStringBuilder.AppendLine("and    contributorlanguage.LAN_Key = @LANKey");
         vSqlCommand.Parameters.AddWithValue("@CONKey", aContributorLanguage.ConKey);
         vSqlCommand.Parameters.AddWithValue("@LANKey", aContributorLanguage.LanKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             if (!vSqlDataReader.HasRows)
             {
                 throw new Exception(String.Format("Expected ContributorLanguage not found: CON_Key = {0}, LAN_Key = {1}", aContributorLanguage.ConKey, aContributorLanguage.LanKey));
             }
             vSqlDataReader.Read();
             DataToObject(aContributorLanguage, vSqlDataReader);
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Esempio n. 11
0
        /// <summary>
        ///   The overloaded Load method that will fill the <c>ContributorLanguageList</c> property a <see cref="ContributorLanguageCollection"/> object as an
        ///   ordered <c>List</c> of <see cref="ContributorLanguage"/>, filtered by the filter properties of the passed <see cref="ContributorLanguageCollection"/>.
        /// </summary>
        /// <param name="aContributorLanguageCollection">The <see cref="ContributorLanguageCollection"/> object that must be filled.</param>
        /// <remarks>
        ///   The filter properties of the <see cref="ContributorLanguageCollection"/> must be correctly completed by the calling application.
        /// </remarks>
        /// <exception cref="ArgumentNullException">If <c>aContributorLanguageCollection</c> argument is <c>null</c>.</exception>
        public static void Load(ContributorLanguageCollection aContributorLanguageCollection)
        {
            if (aContributorLanguageCollection == null)
            {
                throw new ArgumentNullException("aContributorLanguageCollection");
            }
            using (var vSqlCommand = new SqlCommand()
            {
                CommandType = CommandType.Text,
                Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
            })
            {
                var vStringBuilder = BuildSQL();
                if (aContributorLanguageCollection.ContributorLanguageFilter.IsFiltered)
                {
                    if (aContributorLanguageCollection.ContributorLanguageFilter.ContributorKeyFilter > 0)
                    {
                        vStringBuilder.AppendLine("and    contributorlanguage.CON_Key = @CONKey");
                        vSqlCommand.Parameters.AddWithValue("@CONKey", aContributorLanguageCollection.ContributorLanguageFilter.ContributorKeyFilter);
                    }
                    if (aContributorLanguageCollection.ContributorLanguageFilter.ContributorKeyFilter > 0)
                    {
                        vStringBuilder.AppendLine("and    contributorlanguage.LAN_Key = @LANKey");
                        vSqlCommand.Parameters.AddWithValue("@LANKey", aContributorLanguageCollection.ContributorLanguageFilter.LanguageKeyFilter);
                    }
                }

                vStringBuilder.AppendLine("order by LAN_Name");
                vSqlCommand.CommandText = vStringBuilder.ToString();
                vSqlCommand.Connection.Open();
                using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
                {
                    while (vSqlDataReader.Read())
                    {
                        var vContributorLanguage = new ContributorLanguage();
                        DataToObject(vContributorLanguage, vSqlDataReader);
                        aContributorLanguageCollection.ContributorLanguageList.Add(vContributorLanguage);
                    }
                    vSqlDataReader.Close();
                }
                vSqlCommand.Connection.Close();
            }
        }