コード例 #1
0
ファイル: FanWorkoutData.cs プロジェクト: heinschulie/zfit
 /// <summary>
 ///   Delete a <see cref="FanWorkout"/> object passed as an argument.
 /// </summary>
 /// <param name="aFanWorkout">The <see cref="FanWorkout"/> object to be deleted.</param>
 /// <exception cref="ArgumentNullException">If <c>aFanWorkout</c> argument is <c>null</c>.</exception>
 public static void Delete(FanWorkout aFanWorkout)
 {
     if (aFanWorkout == null)
     {
         throw new ArgumentNullException("aFanWorkout");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("delete FAW_FanWorkout");
         if (aFanWorkout.WrtKey > 0 && aFanWorkout.FanKey > 0)
         {
             vStringBuilder.AppendLine("where  WRT_Key = @WRTKey");
             vStringBuilder.AppendLine("and    FAN_Key = @FANKey");
         }
         else if (aFanWorkout.WrtKey > 0)
         {
             vStringBuilder.AppendLine("where  WRT_Key = @WRTKey");
         }
         else if (aFanWorkout.FanKey > 0)
         {
             vStringBuilder.AppendLine("where  FAN_Key = @FANKey");
         }
         vSqlCommand.Parameters.AddWithValue("@WRTKey", aFanWorkout.WrtKey);
         vSqlCommand.Parameters.AddWithValue("@FANKey", aFanWorkout.FanKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
コード例 #2
0
 /// <summary>
 ///   Delete a <see cref="FanWorkout"/> object passed as an argument.
 /// </summary>
 /// <param name="aFanWorkout">The <see cref="FanWorkout"/> object to be deleted.</param>
 /// <exception cref="ArgumentNullException">If <c>aFanWorkout</c> argument is <c>null</c>.</exception>
 public static void Delete(FanWorkout aFanWorkout)
 {
     if (aFanWorkout == null)
     {
         throw new ArgumentNullException("aFanWorkout");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("delete FAW_FanWorkout");
         if (aFanWorkout.WrtKey > 0 && aFanWorkout.FanKey > 0)
         {
             vStringBuilder.AppendLine("where  WRT_Key = @WRTKey");
             vStringBuilder.AppendLine("and    FAN_Key = @FANKey");
         }
         else if (aFanWorkout.WrtKey > 0)
         {
             vStringBuilder.AppendLine("where  WRT_Key = @WRTKey");
         }
         else if (aFanWorkout.FanKey > 0)
         {
             vStringBuilder.AppendLine("where  FAN_Key = @FANKey");
         }
         vSqlCommand.Parameters.AddWithValue("@WRTKey", aFanWorkout.WrtKey);
         vSqlCommand.Parameters.AddWithValue("@FANKey", aFanWorkout.FanKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
コード例 #3
0
 /// <summary>
 ///   Update a <see cref="FanWorkout"/> passed as an argument .
 /// </summary>
 /// <param name="aFanWorkout">A <see cref="FanWorkout"/>.</param>
 public static void Update(FanWorkout aFanWorkout)
 {
     if (aFanWorkout == null)
     {
         throw new ArgumentNullException("aFanWorkout");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("update FAW_FanWorkout");
         vStringBuilder.AppendLine("set    FAW_DateCreated = @FAWDateCreated");
         vStringBuilder.AppendLine("where  WRT_Key = @WRTKey");
         vStringBuilder.AppendLine("and    FAN_Key = @FANKey");
         ObjectToData(vSqlCommand, aFanWorkout);
         vSqlCommand.Parameters.AddWithValue("@FAWDateCreated", aFanWorkout.FanWorkoutDateCreated);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
コード例 #4
0
 /// <summary>
 ///   The overloaded Load method that will return a specific <see cref="FanWorkout"/>, with keys in the <c>aFanWorkout</c> argument.
 /// </summary>
 /// <param name="aFanWorkout">A <see cref="FanWorkout"/>.</param>
 /// <exception cref="ArgumentNullException">If <c>aFanWorkout</c> argument is <c>null</c>.</exception>
 /// <exception cref="Exception">If no record is found.</exception>
 public static void Load(FanWorkout aFanWorkout)
 {
     if (aFanWorkout == null)
     {
         throw new ArgumentNullException("aFanWorkout");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         vStringBuilder.AppendLine("and t1.WRT_Key = @WRTKey");
         vStringBuilder.AppendLine("and t2.FAN_Key = @FANKey");
         vSqlCommand.Parameters.AddWithValue("@WRTKey", aFanWorkout.WrtKey);
         vSqlCommand.Parameters.AddWithValue("@FANKey", aFanWorkout.FanKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             if (!vSqlDataReader.HasRows)
             {
                 throw new Exception(String.Format("Expected WorkoutFAN not found: WRT_Key = {0}, FAN_Key = {1}", aFanWorkout.WrtKey, aFanWorkout.FanKey));
             }
             vSqlDataReader.Read();
             DataToObject(aFanWorkout, vSqlDataReader, true);
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
コード例 #5
0
ファイル: FanWorkoutData.cs プロジェクト: heinschulie/zfit
 /// <summary>
 ///   Load a <see cref="SqlDataReader"/> into a <see cref="FanWorkout"/> object.
 /// </summary>
 /// <param name="aFanWorkout">A <see cref="Workout"/> argument.</param>
 /// <param name="aSqlDataReader">A <see cref="SqlDataReader"/> argument.</param>
 public static void DataToObject(FanWorkout aFanWorkout, SqlDataReader aSqlDataReader, bool aIncludeAvatar)
 {
     aFanWorkout.WrtKey = Convert.ToInt32(aSqlDataReader["WRT_Key"]);
     aFanWorkout.WrtName = Convert.ToString(aSqlDataReader["WRT_Name"]);
     aFanWorkout.FanKey = Convert.ToInt32(aSqlDataReader["FAN_Key"]);
     aFanWorkout.FanName = Convert.ToString(aSqlDataReader["FAN_Name"]);
     aFanWorkout.FanSurname = Convert.ToString(aSqlDataReader["FAN_Surname"]);
     aFanWorkout.FanWorkoutDateCreated = (Convert.ToDateTime(aSqlDataReader["FAW_DateCreated"])).ToLongDateString();
 }
コード例 #6
0
 /// <summary>
 ///   Load a <see cref="SqlDataReader"/> into a <see cref="FanWorkout"/> object.
 /// </summary>
 /// <param name="aFanWorkout">A <see cref="Workout"/> argument.</param>
 /// <param name="aSqlDataReader">A <see cref="SqlDataReader"/> argument.</param>
 public static void DataToObject(FanWorkout aFanWorkout, SqlDataReader aSqlDataReader, bool aIncludeAvatar)
 {
     aFanWorkout.WrtKey                = Convert.ToInt32(aSqlDataReader["WRT_Key"]);
     aFanWorkout.WrtName               = Convert.ToString(aSqlDataReader["WRT_Name"]);
     aFanWorkout.FanKey                = Convert.ToInt32(aSqlDataReader["FAN_Key"]);
     aFanWorkout.FanName               = Convert.ToString(aSqlDataReader["FAN_Name"]);
     aFanWorkout.FanSurname            = Convert.ToString(aSqlDataReader["FAN_Surname"]);
     aFanWorkout.FanWorkoutDateCreated = (Convert.ToDateTime(aSqlDataReader["FAW_DateCreated"])).ToLongDateString();
 }
コード例 #7
0
        /// <summary>
        ///   The overloaded Load method that will return a specific <see cref="FanWorkout"/> object, with keys in <c>aFanWorkout</c>.
        /// </summary>
        /// <param name="aFanKey">A <see cref="FanKey"/> object.</param>
        /// <param name="aFanWorkout">A <see cref="FanWorkout"/>.</param>
        /// <exception cref="ArgumentNullException">If <c>aFanWorkout</c> is <c>null</c>.</exception>
        public static void Load(FanKey aFanKey, FanWorkout aFanWorkout)
        {
            if (aFanWorkout == null)
            {
                throw new ArgumentNullException("Load FanWorkout Business");
            }

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

            FanWorkoutData.Load(aFanWorkout);
        }
コード例 #8
0
 /// <summary>
 ///   The overloaded Load method that will fill the <c>FanWorkoutList</c> property a <see cref="FanWorkoutCollection"/> object as an
 ///   ordered <c>List</c> of <see cref="FanWorkout"/>, filtered by the filter properties of the passed <see cref="FanWorkoutCollection"/>.
 /// </summary>
 /// <param name="aFanWorkoutCollection">The <see cref="FanWorkoutCollection"/> object that must be filled.</param>
 /// <remarks>
 ///   The filter properties of the <see cref="FanWorkoutCollection"/> must be correctly completed by the calling application.
 /// </remarks>
 /// <exception cref="ArgumentNullException">If <c>aFanWorkoutCollection</c> argument is <c>null</c>.</exception>
 public static void Load(FanWorkoutCollection aFanWorkoutCollection)
 {
     if (aFanWorkoutCollection == null)
     {
         throw new ArgumentNullException("aFanWorkoutCollection");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         if (aFanWorkoutCollection.IsFiltered)
         {
             if (aFanWorkoutCollection.FanWorkoutFilter.FawFilter.WrtKey > 0)
             {
                 vStringBuilder.AppendLine("and t1.WRT_Key = @WRTKey");
                 vSqlCommand.Parameters.AddWithValue("@WRTKey", aFanWorkoutCollection.FanWorkoutFilter.FawFilter.WrtKey);
             }
             if (aFanWorkoutCollection.FanWorkoutFilter.FawFilter.FanKey > 0)
             {
                 vStringBuilder.AppendLine("and t2.FAN_Key = @FANKey");
                 vSqlCommand.Parameters.AddWithValue("@FANKey", aFanWorkoutCollection.FanWorkoutFilter.FawFilter.FanKey);
             }
             if (aFanWorkoutCollection.FanWorkoutFilter.FawFilter.WrtName != null)
             {
                 vStringBuilder.AppendFormat("and t1.WRT_Name like '%{0}%'", aFanWorkoutCollection.FanWorkoutFilter.FawFilter.WrtName);
             }
             if (aFanWorkoutCollection.FanWorkoutFilter.FawFilter.FanName != null)
             {
                 vStringBuilder.AppendFormat("and t2.FAN_Name like '%{0}%'", aFanWorkoutCollection.FanWorkoutFilter.FawFilter.FanName);
             }
         }
         vStringBuilder.AppendLine("order by t1.WRT_Name");
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             while (vSqlDataReader.Read())
             {
                 var vFanWorkout = new FanWorkout();
                 DataToObject(vFanWorkout, vSqlDataReader, false);
                 aFanWorkoutCollection.FanWorkoutList.Add(vFanWorkout);
             }
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
コード例 #9
0
        /// <summary>
        ///   The overloaded Load method that will return a specific <see cref="FanWorkout"/> object, with keys in <c>aFanWorkout</c>.
        /// </summary>
        /// <param name="aFanKey">A <see cref="FanKey"/> object.</param>
        /// <param name="aFanWorkout">A <see cref="FanWorkout"/>.</param>
        /// <exception cref="ArgumentNullException">If <c>aFanWorkout</c> is <c>null</c>.</exception>
        public static void Load(FanKey aFanKey, FanWorkout aFanWorkout)
        {
            if (aFanWorkout == null)
            {
                throw new ArgumentNullException("Load FanWorkout Business");
            }

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

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

            _isFiltered = (aSource as FanWorkoutCollection)._isFiltered;
            _fanWorkoutFilter = (aSource as FanWorkoutCollection)._fanWorkoutFilter;
            _fanWorkoutList.Clear();
            foreach (FanWorkout vFanWorkoutSource in (aSource as FanWorkoutCollection)._fanWorkoutList)
            {
                FanWorkout vFanWorkoutTarget = new FanWorkout();
                vFanWorkoutTarget.AssignFromSource(vFanWorkoutSource);
                _fanWorkoutList.Add(vFanWorkoutTarget);
            }
        }
コード例 #11
0
        /// <summary>
        ///    Assigns all <c>aSource</c> object's values to this instance of <see cref="FanWorkoutCollection"/>.
        /// </summary>
        /// <param name="aSource">A source object.</param>
        public override void AssignFromSource(object aSource)
        {
            if (!(aSource is FanWorkoutCollection))
            {
                throw new ArgumentException("Invalid assignment source", "FanWorkoutCollection");
            }

            _isFiltered       = (aSource as FanWorkoutCollection)._isFiltered;
            _fanWorkoutFilter = (aSource as FanWorkoutCollection)._fanWorkoutFilter;
            _fanWorkoutList.Clear();
            foreach (FanWorkout vFanWorkoutSource in (aSource as FanWorkoutCollection)._fanWorkoutList)
            {
                FanWorkout vFanWorkoutTarget = new FanWorkout();
                vFanWorkoutTarget.AssignFromSource(vFanWorkoutSource);
                _fanWorkoutList.Add(vFanWorkoutTarget);
            }
        }
コード例 #12
0
ファイル: FanWorkoutData.cs プロジェクト: heinschulie/zfit
 /// <summary>
 ///   Update a <see cref="FanWorkout"/> passed as an argument .
 /// </summary>
 /// <param name="aFanWorkout">A <see cref="FanWorkout"/>.</param>
 public static void Update(FanWorkout aFanWorkout)
 {
     if (aFanWorkout == null)
     {
         throw new ArgumentNullException("aFanWorkout");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("update FAW_FanWorkout");
         vStringBuilder.AppendLine("set    FAW_DateCreated = @FAWDateCreated");
         vStringBuilder.AppendLine("where  WRT_Key = @WRTKey");
         vStringBuilder.AppendLine("and    FAN_Key = @FANKey");
         ObjectToData(vSqlCommand, aFanWorkout);
         vSqlCommand.Parameters.AddWithValue("@FAWDateCreated", aFanWorkout.FanWorkoutDateCreated);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
コード例 #13
0
ファイル: FanWorkoutData.cs プロジェクト: heinschulie/zfit
 /// <summary>
 ///   Loads the <see cref="SqlCommand"/> parameters with values from an <see cref="FanWorkout"/>.
 /// </summary>
 /// <param name="aSqlCommand">A <see cref="SqlDataReader"/> argument.</param>
 /// <param name="aWorkout">A <see cref="FanWorkout"/> argument.</param>
 public static void ObjectToData(SqlCommand aSqlCommand, FanWorkout aFanWorkout)
 {
     aSqlCommand.Parameters.AddWithValue("@WRTKey", aFanWorkout.WrtKey);
     aSqlCommand.Parameters.AddWithValue("@FANKey", aFanWorkout.FanKey);
     aSqlCommand.Parameters.AddWithValue("@WRTFANDateCreated", DateTime.Parse(aFanWorkout.FanWorkoutDateCreated));
 }
コード例 #14
0
 /// <summary>
 ///   Loads the <see cref="SqlCommand"/> parameters with values from an <see cref="FanWorkout"/>.
 /// </summary>
 /// <param name="aSqlCommand">A <see cref="SqlDataReader"/> argument.</param>
 /// <param name="aWorkout">A <see cref="FanWorkout"/> argument.</param>
 public static void ObjectToData(SqlCommand aSqlCommand, FanWorkout aFanWorkout)
 {
     aSqlCommand.Parameters.AddWithValue("@WRTKey", aFanWorkout.WrtKey);
     aSqlCommand.Parameters.AddWithValue("@FANKey", aFanWorkout.FanKey);
     aSqlCommand.Parameters.AddWithValue("@WRTFANDateCreated", DateTime.Parse(aFanWorkout.FanWorkoutDateCreated));
 }
コード例 #15
0
 /// <summary>
 ///   Gets a specified <see cref="FanWorkout"/> by key.
 /// </summary>
 /// <param name="aFanToken">A <see cref="FanToken"/> object used for Access Control.</param>
 /// <param name="aFanWorkout"><see cref="FanWorkout"/> object.</param>
 public static void GetFanWorkout(FanToken aFanToken, FanWorkout aFanWorkout)
 {
     FanCallHandler.ServiceCall <FanWorkout>(aFanToken, "GetFanWorkout", aFanWorkout);
 }
コード例 #16
0
ファイル: FanImplementation.cs プロジェクト: heinschulie/zfit
 /// <summary>
 ///   Gets the <see cref="FanWorkout"/> by Key.
 /// </summary>
 /// <param name="aXmlArgument">XML Argument <see cref="string"/>.</param>
 /// <returns>FanWorkout as XML <see cref="string"/>.</returns>
 /// <exception cref="ArgumentNullException">If <c>aXmlArgument</c> is <c>null</c>.</exception>
 public static string GetFanWorkout(FanKey aFanKey, string aXmlArgument)
 {
     if (aXmlArgument == null)
     {
         throw new ArgumentNullException("aXmlArgument of GetFanWorkout");
     }
     FanWorkout vFanWorkout = new FanWorkout();
     vFanWorkout = XmlUtils.Deserialize<FanWorkout>(aXmlArgument);
     FanWorkoutBusiness.Load(aFanKey, vFanWorkout);
     return XmlUtils.Serialize<FanWorkout>(vFanWorkout, true);
 }
コード例 #17
0
ファイル: FanWorkoutData.cs プロジェクト: heinschulie/zfit
 /// <summary>
 ///   The overloaded Load method that will fill the <c>FanWorkoutList</c> property a <see cref="FanWorkoutCollection"/> object as an
 ///   ordered <c>List</c> of <see cref="FanWorkout"/>, filtered by the filter properties of the passed <see cref="FanWorkoutCollection"/>.
 /// </summary>
 /// <param name="aFanWorkoutCollection">The <see cref="FanWorkoutCollection"/> object that must be filled.</param>
 /// <remarks>
 ///   The filter properties of the <see cref="FanWorkoutCollection"/> must be correctly completed by the calling application.
 /// </remarks>
 /// <exception cref="ArgumentNullException">If <c>aFanWorkoutCollection</c> argument is <c>null</c>.</exception>
 public static void Load(FanWorkoutCollection aFanWorkoutCollection)
 {
     if (aFanWorkoutCollection == null)
     {
         throw new ArgumentNullException("aFanWorkoutCollection");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         if (aFanWorkoutCollection.IsFiltered)
         {
             if (aFanWorkoutCollection.FanWorkoutFilter.FawFilter.WrtKey > 0)
             {
                 vStringBuilder.AppendLine("and t1.WRT_Key = @WRTKey");
                 vSqlCommand.Parameters.AddWithValue("@WRTKey", aFanWorkoutCollection.FanWorkoutFilter.FawFilter.WrtKey);
             }
             if (aFanWorkoutCollection.FanWorkoutFilter.FawFilter.FanKey > 0)
             {
                 vStringBuilder.AppendLine("and t2.FAN_Key = @FANKey");
                 vSqlCommand.Parameters.AddWithValue("@FANKey", aFanWorkoutCollection.FanWorkoutFilter.FawFilter.FanKey);
             }
             if (aFanWorkoutCollection.FanWorkoutFilter.FawFilter.WrtName != null)
             {
                 vStringBuilder.AppendFormat("and t1.WRT_Name like '%{0}%'", aFanWorkoutCollection.FanWorkoutFilter.FawFilter.WrtName);
             }
             if (aFanWorkoutCollection.FanWorkoutFilter.FawFilter.FanName != null)
             {
                 vStringBuilder.AppendFormat("and t2.FAN_Name like '%{0}%'", aFanWorkoutCollection.FanWorkoutFilter.FawFilter.FanName);
             }
         }
         vStringBuilder.AppendLine("order by t1.WRT_Name");
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             while (vSqlDataReader.Read())
             {
                 var vFanWorkout = new FanWorkout();
                 DataToObject(vFanWorkout, vSqlDataReader, false);
                 aFanWorkoutCollection.FanWorkoutList.Add(vFanWorkout);
             }
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
コード例 #18
0
ファイル: FanWorkoutData.cs プロジェクト: heinschulie/zfit
 /// <summary>
 ///   The overloaded Load method that will return a specific <see cref="FanWorkout"/>, with keys in the <c>aFanWorkout</c> argument.
 /// </summary>
 /// <param name="aFanWorkout">A <see cref="FanWorkout"/>.</param>
 /// <exception cref="ArgumentNullException">If <c>aFanWorkout</c> argument is <c>null</c>.</exception>
 /// <exception cref="Exception">If no record is found.</exception>
 public static void Load(FanWorkout aFanWorkout)
 {
     if (aFanWorkout == null)
     {
         throw new ArgumentNullException("aFanWorkout");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         vStringBuilder.AppendLine("and t1.WRT_Key = @WRTKey");
         vStringBuilder.AppendLine("and t2.FAN_Key = @FANKey");
         vSqlCommand.Parameters.AddWithValue("@WRTKey", aFanWorkout.WrtKey);
         vSqlCommand.Parameters.AddWithValue("@FANKey", aFanWorkout.FanKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             if (!vSqlDataReader.HasRows)
             {
                 throw new Exception(String.Format("Expected WorkoutFAN not found: WRT_Key = {0}, FAN_Key = {1}", aFanWorkout.WrtKey, aFanWorkout.FanKey));
             }
             vSqlDataReader.Read();
             DataToObject(aFanWorkout, vSqlDataReader, true);
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
コード例 #19
0
 /// <summary>
 ///   Gets a specified <see cref="FanWorkout"/> by key.
 /// </summary>
 /// <param name="aFanToken">A <see cref="FanToken"/> object used for Access Control.</param>
 /// <param name="aFanWorkout"><see cref="FanWorkout"/> object.</param>
 public static void GetFanWorkout(FanToken aFanToken, FanWorkout aFanWorkout)
 {
     FanCallHandler.ServiceCall<FanWorkout>(aFanToken, "GetFanWorkout", aFanWorkout);
 }