Exemple #1
0
 /// <summary>
 ///   Update a <see cref="FanFed"/> passed as an argument .
 /// </summary>
 /// <param name="aFanFed">A <see cref="FanFed"/>.</param>
 public static void Update(FanFed aFanFed)
 {
     if (aFanFed == null)
     {
         throw new ArgumentNullException("aFanFed");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("update FEN_FanFederation");
         vStringBuilder.AppendLine("set    FEN_DateJoined = @FENDateJoined,");
         vStringBuilder.AppendLine("where  FED_Key = @FEDKey");
         vStringBuilder.AppendLine("and    FAN_Key = @FANKey");
         ObjectToData(vSqlCommand, aFanFed);
         vSqlCommand.Parameters.AddWithValue("@FENDateJoined", aFanFed.FanFedDateJoined);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Exemple #2
0
 /// <summary>
 ///   The overloaded Load method that will return a specific <see cref="FanFed"/>, with keys in the <c>aFanFed</c> argument.
 /// </summary>
 /// <param name="aFanFed">A <see cref="FanFed"/>.</param>
 /// <exception cref="ArgumentNullException">If <c>aFanFed</c> argument is <c>null</c>.</exception>
 /// <exception cref="Exception">If no record is found.</exception>
 public static void Load(FanFed aFanFed)
 {
     if (aFanFed == null)
     {
         throw new ArgumentNullException("aFanFed");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         vStringBuilder.AppendLine("and t1.FED_Key = @FEDKey");
         vStringBuilder.AppendLine("and t2.FAN_Key = @FANKey");
         vSqlCommand.Parameters.AddWithValue("@FEDKey", aFanFed.FedKey);
         vSqlCommand.Parameters.AddWithValue("@FANKey", aFanFed.FanKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             if (!vSqlDataReader.HasRows)
             {
                 throw new Exception(String.Format("Expected FederationFAN not found: FED_Key = {0}, FAN_Key = {1}", aFanFed.FedKey, aFanFed.FanKey));
             }
             vSqlDataReader.Read();
             DataToObject(aFanFed, vSqlDataReader, true);
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Exemple #3
0
 /// <summary>
 ///   Delete a <see cref="FanFed"/> object passed as an argument.
 /// </summary>
 /// <param name="aFanFed">The <see cref="FanFed"/> object to be deleted.</param>
 /// <exception cref="ArgumentNullException">If <c>aFanFed</c> argument is <c>null</c>.</exception>
 public static void Delete(FanFed aFanFed)
 {
     if (aFanFed == null)
     {
         throw new ArgumentNullException("aFanFed");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("delete FEN_FanFederation");
         if (aFanFed.FedKey > 0 && aFanFed.FanKey > 0)
         {
             vStringBuilder.AppendLine("where  FED_Key = @FEDKey");
             vStringBuilder.AppendLine("and    FAN_Key = @FANKey");
         }
         else if (aFanFed.FedKey > 0)
         {
             vStringBuilder.AppendLine("where  FED_Key = @FEDKey");
         }
         else if (aFanFed.FanKey > 0)
         {
             vStringBuilder.AppendLine("where  FAN_Key = @FANKey");
         }
         vSqlCommand.Parameters.AddWithValue("@FEDKey", aFanFed.FedKey);
         vSqlCommand.Parameters.AddWithValue("@FANKey", aFanFed.FanKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Exemple #4
0
 /// <summary>
 ///   Delete a <see cref="FanFed"/> object passed as an argument.
 /// </summary>
 /// <param name="aFanFed">The <see cref="FanFed"/> object to be deleted.</param>
 /// <exception cref="ArgumentNullException">If <c>aFanFed</c> argument is <c>null</c>.</exception>
 public static void Delete(FanFed aFanFed)
 {
     if (aFanFed == null)
     {
         throw new ArgumentNullException("aFanFed");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("delete FEN_FanFederation");
         if (aFanFed.FedKey > 0 && aFanFed.FanKey > 0)
         {
             vStringBuilder.AppendLine("where  FED_Key = @FEDKey");
             vStringBuilder.AppendLine("and    FAN_Key = @FANKey");
         }
         else if (aFanFed.FedKey > 0)
         {
             vStringBuilder.AppendLine("where  FED_Key = @FEDKey");
         }
         else if (aFanFed.FanKey > 0)
         {
             vStringBuilder.AppendLine("where  FAN_Key = @FANKey");
         }
         vSqlCommand.Parameters.AddWithValue("@FEDKey", aFanFed.FedKey);
         vSqlCommand.Parameters.AddWithValue("@FANKey", aFanFed.FanKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Exemple #5
0
 /// <summary>
 ///   Load a <see cref="SqlDataReader"/> into a <see cref="FanFed"/> object.
 /// </summary>
 /// <param name="aFanFed">A <see cref="Federation"/> argument.</param>
 /// <param name="aSqlDataReader">A <see cref="SqlDataReader"/> argument.</param>
 public static void DataToObject(FanFed aFanFed, SqlDataReader aSqlDataReader, bool aIncludeAvatar)
 {
     aFanFed.FedKey           = Convert.ToInt32(aSqlDataReader["FED_Key"]);
     aFanFed.FedName          = Convert.ToString(aSqlDataReader["FED_Name"]);
     aFanFed.FanKey           = Convert.ToInt32(aSqlDataReader["FAN_Key"]);
     aFanFed.FanName          = Convert.ToString(aSqlDataReader["FAN_Name"]);
     aFanFed.FanSurname       = Convert.ToString(aSqlDataReader["FAN_Surname"]);
     aFanFed.FanFedDateJoined = Convert.ToDateTime(aSqlDataReader["FEN_DateJoined"]);
 }
Exemple #6
0
 /// <summary>
 ///   Load a <see cref="SqlDataReader"/> into a <see cref="FanFed"/> object.
 /// </summary>
 /// <param name="aFanFed">A <see cref="Federation"/> argument.</param>
 /// <param name="aSqlDataReader">A <see cref="SqlDataReader"/> argument.</param>
 public static void DataToObject(FanFed aFanFed, SqlDataReader aSqlDataReader, bool aIncludeAvatar)
 {
     aFanFed.FedKey = Convert.ToInt32(aSqlDataReader["FED_Key"]);
     aFanFed.FedName = Convert.ToString(aSqlDataReader["FED_Name"]);
     aFanFed.FanKey = Convert.ToInt32(aSqlDataReader["FAN_Key"]);
     aFanFed.FanName = Convert.ToString(aSqlDataReader["FAN_Name"]);
     aFanFed.FanSurname = Convert.ToString(aSqlDataReader["FAN_Surname"]);
     aFanFed.FanFedDateJoined = Convert.ToDateTime(aSqlDataReader["FEN_DateJoined"]);
 }
Exemple #7
0
 /// <summary>
 ///   The overloaded Load method that will fill the <c>FanFedList</c> property a <see cref="FanFedCollection"/> object as an
 ///   ordered <c>List</c> of <see cref="FanFed"/>, filtered by the filter properties of the passed <see cref="FanFedCollection"/>.
 /// </summary>
 /// <param name="aFanFedCollection">The <see cref="FanFedCollection"/> object that must be filled.</param>
 /// <remarks>
 ///   The filter properties of the <see cref="FanFedCollection"/> must be correctly completed by the calling application.
 /// </remarks>
 /// <exception cref="ArgumentNullException">If <c>aFanFedCollection</c> argument is <c>null</c>.</exception>
 public static void Load(FanFedCollection aFanFedCollection)
 {
     if (aFanFedCollection == null)
     {
         throw new ArgumentNullException("aFanFedCollection");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         if (aFanFedCollection.IsFiltered)
         {
             if (aFanFedCollection.FanFedFilter.FanfedFilter.FedKey > 0)
             {
                 vStringBuilder.AppendLine("and t1.FED_Key = @FEDKey");
                 vSqlCommand.Parameters.AddWithValue("@FEDKey", aFanFedCollection.FanFedFilter.FanfedFilter.FedKey);
             }
             if (aFanFedCollection.FanFedFilter.FanfedFilter.FanKey > 0)
             {
                 vStringBuilder.AppendLine("and t2.FAN_Key = @FANKey");
                 vSqlCommand.Parameters.AddWithValue("@FANKey", aFanFedCollection.FanFedFilter.FanfedFilter.FanKey);
             }
             if (aFanFedCollection.FanFedFilter.FanfedFilter.FedName != null)
             {
                 vStringBuilder.AppendFormat("and t1.FED_Name like '%{0}%'", aFanFedCollection.FanFedFilter.FanfedFilter.FedName);
             }
             if (aFanFedCollection.FanFedFilter.FanfedFilter.FanName != null)
             {
                 vStringBuilder.AppendFormat("and t2.FAN_Name like '%{0}%'", aFanFedCollection.FanFedFilter.FanfedFilter.FanName);
             }
         }
         vStringBuilder.AppendLine("order by t1.FED_Name");
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             while (vSqlDataReader.Read())
             {
                 var vFanFed = new FanFed();
                 DataToObject(vFanFed, vSqlDataReader, false);
                 aFanFedCollection.FanFedList.Add(vFanFed);
             }
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Exemple #8
0
        /// <summary>
        ///   The overloaded Load method that will return a specific <see cref="FanFed"/> object, with keys in <c>aFanFed</c>.
        /// </summary>
        /// <param name="aFanKey">A <see cref="FanKey"/> object.</param>
        /// <param name="aFanFed">A <see cref="FanFed"/>.</param>
        /// <exception cref="ArgumentNullException">If <c>aFanFed</c> is <c>null</c>.</exception>
        public static void Load(FanKey aFanKey, FanFed aFanFed)
        {
            if (aFanFed == null)
            {
                throw new ArgumentNullException("Load FanFed Business");
            }

            //if (!FanFunctionAccessData.HasModeAccess(aFanKey, "FanFed", AccessMode.Read))
            //{
            //    throw new ZpAccessException("Access Denied", String.Format("{0}", aFanKey.FannKey), AccessMode.Read, "FanFed");
            //}

            FanFedData.Load(aFanFed);
        }
Exemple #9
0
        /// <summary>
        ///   The overloaded Load method that will return a specific <see cref="FanFed"/> object, with keys in <c>aFanFed</c>.
        /// </summary>
        /// <param name="aFanKey">A <see cref="FanKey"/> object.</param>
        /// <param name="aFanFed">A <see cref="FanFed"/>.</param>
        /// <exception cref="ArgumentNullException">If <c>aFanFed</c> is <c>null</c>.</exception>
        public static void Load(FanKey aFanKey, FanFed aFanFed)
        {
            if (aFanFed == null)
            {
                throw new ArgumentNullException("Load FanFed Business");
            }

            //if (!FanFunctionAccessData.HasModeAccess(aFanKey, "FanFed", AccessMode.Read))
            //{
            //    throw new ZpAccessException("Access Denied", String.Format("{0}", aFanKey.FannKey), AccessMode.Read, "FanFed");
            //}

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

            _isFiltered = (aSource as FanFedCollection)._isFiltered;
            _fanFedFilter = (aSource as FanFedCollection)._fanFedFilter;
            _fanFedList.Clear();
            foreach (FanFed vFanFedSource in (aSource as FanFedCollection)._fanFedList)
            {
                FanFed vFanFedTarget = new FanFed();
                vFanFedTarget.AssignFromSource(vFanFedSource);
                _fanFedList.Add(vFanFedTarget);
            }
        }
Exemple #11
0
        /// <summary>
        ///    Assigns all <c>aSource</c> object's values to this instance of <see cref="FanFedCollection"/>.
        /// </summary>
        /// <param name="aSource">A source object.</param>
        public override void AssignFromSource(object aSource)
        {
            if (!(aSource is FanFedCollection))
            {
                throw new ArgumentException("Invalid assignment source", "FanFedCollection");
            }

            _isFiltered   = (aSource as FanFedCollection)._isFiltered;
            _fanFedFilter = (aSource as FanFedCollection)._fanFedFilter;
            _fanFedList.Clear();
            foreach (FanFed vFanFedSource in (aSource as FanFedCollection)._fanFedList)
            {
                FanFed vFanFedTarget = new FanFed();
                vFanFedTarget.AssignFromSource(vFanFedSource);
                _fanFedList.Add(vFanFedTarget);
            }
        }
Exemple #12
0
 /// <summary>
 ///   Loads the <see cref="SqlCommand"/> parameters with values from an <see cref="FanFed"/>.
 /// </summary>
 /// <param name="aSqlCommand">A <see cref="SqlDataReader"/> argument.</param>
 /// <param name="aFederation">A <see cref="FanFed"/> argument.</param>
 public static void ObjectToData(SqlCommand aSqlCommand, FanFed aFanFed)
 {
     aSqlCommand.Parameters.AddWithValue("@FEDKey", aFanFed.FedKey);
     aSqlCommand.Parameters.AddWithValue("@FANKey", aFanFed.FanKey);
     aSqlCommand.Parameters.AddWithValue("@FEDFANDateJoined", aFanFed.FanFedDateJoined);
 }
Exemple #13
0
 /// <summary>
 ///   The overloaded Load method that will return a specific <see cref="FanFed"/>, with keys in the <c>aFanFed</c> argument.
 /// </summary>
 /// <param name="aFanFed">A <see cref="FanFed"/>.</param>
 /// <exception cref="ArgumentNullException">If <c>aFanFed</c> argument is <c>null</c>.</exception>
 /// <exception cref="Exception">If no record is found.</exception>
 public static void Load(FanFed aFanFed)
 {
     if (aFanFed == null)
     {
         throw new ArgumentNullException("aFanFed");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         vStringBuilder.AppendLine("and t1.FED_Key = @FEDKey");
         vStringBuilder.AppendLine("and t2.FAN_Key = @FANKey");
         vSqlCommand.Parameters.AddWithValue("@FEDKey", aFanFed.FedKey);
         vSqlCommand.Parameters.AddWithValue("@FANKey", aFanFed.FanKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             if (!vSqlDataReader.HasRows)
             {
                 throw new Exception(String.Format("Expected FederationFAN not found: FED_Key = {0}, FAN_Key = {1}", aFanFed.FedKey, aFanFed.FanKey));
             }
             vSqlDataReader.Read();
             DataToObject(aFanFed, vSqlDataReader, true);
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Exemple #14
0
 /// <summary>
 ///   The overloaded Load method that will fill the <c>FanFedList</c> property a <see cref="FanFedCollection"/> object as an
 ///   ordered <c>List</c> of <see cref="FanFed"/>, filtered by the filter properties of the passed <see cref="FanFedCollection"/>.
 /// </summary>
 /// <param name="aFanFedCollection">The <see cref="FanFedCollection"/> object that must be filled.</param>
 /// <remarks>
 ///   The filter properties of the <see cref="FanFedCollection"/> must be correctly completed by the calling application.
 /// </remarks>
 /// <exception cref="ArgumentNullException">If <c>aFanFedCollection</c> argument is <c>null</c>.</exception>
 public static void Load(FanFedCollection aFanFedCollection)
 {
     if (aFanFedCollection == null)
     {
         throw new ArgumentNullException("aFanFedCollection");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         if (aFanFedCollection.IsFiltered)
         {
             if (aFanFedCollection.FanFedFilter.FanfedFilter.FedKey > 0)
             {
                 vStringBuilder.AppendLine("and t1.FED_Key = @FEDKey");
                 vSqlCommand.Parameters.AddWithValue("@FEDKey", aFanFedCollection.FanFedFilter.FanfedFilter.FedKey);
             }
             if (aFanFedCollection.FanFedFilter.FanfedFilter.FanKey > 0)
             {
                 vStringBuilder.AppendLine("and t2.FAN_Key = @FANKey");
                 vSqlCommand.Parameters.AddWithValue("@FANKey", aFanFedCollection.FanFedFilter.FanfedFilter.FanKey);
             }
             if (aFanFedCollection.FanFedFilter.FanfedFilter.FedName != null)
             {
                 vStringBuilder.AppendFormat("and t1.FED_Name like '%{0}%'", aFanFedCollection.FanFedFilter.FanfedFilter.FedName);
             }
             if (aFanFedCollection.FanFedFilter.FanfedFilter.FanName != null)
             {
                 vStringBuilder.AppendFormat("and t2.FAN_Name like '%{0}%'", aFanFedCollection.FanFedFilter.FanfedFilter.FanName);
             }
         }
         vStringBuilder.AppendLine("order by t1.FED_Name");
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             while (vSqlDataReader.Read())
             {
                 var vFanFed = new FanFed();
                 DataToObject(vFanFed, vSqlDataReader, false);
                 aFanFedCollection.FanFedList.Add(vFanFed);
             }
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Exemple #15
0
 /// <summary>
 ///   Update a <see cref="FanFed"/> passed as an argument .
 /// </summary>
 /// <param name="aFanFed">A <see cref="FanFed"/>.</param>
 public static void Update(FanFed aFanFed)
 {
     if (aFanFed == null)
     {
         throw new ArgumentNullException("aFanFed");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("update FEN_FanFederation");
         vStringBuilder.AppendLine("set    FEN_DateJoined = @FENDateJoined,");
         vStringBuilder.AppendLine("where  FED_Key = @FEDKey");
         vStringBuilder.AppendLine("and    FAN_Key = @FANKey");
         ObjectToData(vSqlCommand, aFanFed);
         vSqlCommand.Parameters.AddWithValue("@FENDateJoined", aFanFed.FanFedDateJoined);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
 /// <summary>
 ///   Gets a specified <see cref="FanFed"/> by key.
 /// </summary>
 /// <param name="aFanToken">A <see cref="FanToken"/> object used for Access Control.</param>
 /// <param name="aFanFed"><see cref="FanFed"/> object.</param>
 public static void GetFanFed(FanToken aFanToken, FanFed aFanFed)
 {
     FanCallHandler.ServiceCall <FanFed>(aFanToken, "GetFanFed", aFanFed);
 }
Exemple #17
0
 /// <summary>
 ///   Gets the <see cref="FanFed"/> by Key.
 /// </summary>
 /// <param name="aXmlArgument">XML Argument <see cref="string"/>.</param>
 /// <returns>FanFed as XML <see cref="string"/>.</returns>
 /// <exception cref="ArgumentNullException">If <c>aXmlArgument</c> is <c>null</c>.</exception>
 public static string GetFanFed(FanKey aFanKey, string aXmlArgument)
 {
     if (aXmlArgument == null)
     {
         throw new ArgumentNullException("aXmlArgument of GetFanFed");
     }
     FanFed vFanFed = new FanFed();
     vFanFed = XmlUtils.Deserialize<FanFed>(aXmlArgument);
     FanFedBusiness.Load(aFanKey, vFanFed);
     return XmlUtils.Serialize<FanFed>(vFanFed, true);
 }
Exemple #18
0
 /// <summary>
 ///   Loads the <see cref="SqlCommand"/> parameters with values from an <see cref="FanFed"/>.
 /// </summary>
 /// <param name="aSqlCommand">A <see cref="SqlDataReader"/> argument.</param>
 /// <param name="aFederation">A <see cref="FanFed"/> argument.</param>
 public static void ObjectToData(SqlCommand aSqlCommand, FanFed aFanFed)
 {
     aSqlCommand.Parameters.AddWithValue("@FEDKey", aFanFed.FedKey);
     aSqlCommand.Parameters.AddWithValue("@FANKey", aFanFed.FanKey);
     aSqlCommand.Parameters.AddWithValue("@FEDFANDateJoined", aFanFed.FanFedDateJoined);
 }
 /// <summary>
 ///   Gets a specified <see cref="FanFed"/> by key.
 /// </summary>
 /// <param name="aFanToken">A <see cref="FanToken"/> object used for Access Control.</param>
 /// <param name="aFanFed"><see cref="FanFed"/> object.</param>
 public static void GetFanFed(FanToken aFanToken, FanFed aFanFed)
 {
     FanCallHandler.ServiceCall<FanFed>(aFanToken, "GetFanFed", aFanFed);
 }