Exemple #1
0
        public static webObject loadWorkoutCollection(Workout aWorkout)
        {
            WorkoutCollection vWorkoutCollection = new WorkoutCollection();

            vWorkoutCollection.WorkoutFilter.WrtFilter.AssignFromSource(aWorkout);

            FanToken  vFanToken  = ServerSession.GetFanToken(HttpContext.Current.Session);
            webObject vWebObject = new webObject();

            vWebObject.aTransactionStatus = ServerSession.GetTransactionStatus(HttpContext.Current.Session);

            try
            {
                FanServiceConsumer.GetWorkoutCollection(vFanToken, vWorkoutCollection);
                vWebObject.aTransactionStatus.TransactionResult = TransactionResult.OK;
                vWebObject.aTransactionStatus.Message           = "WorkoutCollection Loaded";
                ServerSession.SetTransactionStatus(HttpContext.Current.Session, vWebObject.aTransactionStatus);
                vWebObject.AnObject = vWorkoutCollection;
            }
            catch (TransactionStatusException tx)
            {
                vWebObject.aTransactionStatus.AssignFromSource(tx.TransactionStatus);
                return(vWebObject);
            }
            catch (Exception ex)
            {
                vWebObject.aTransactionStatus.TransactionResult = TransactionResult.GeneralException;
                vWebObject.aTransactionStatus.Message           = "Load of WorkoutCollection unsuccesful" + ex.Message;
                vWebObject.aTransactionStatus.InnerMessage      = ex.InnerException == null ? String.Empty : ex.InnerException.Message;
                return(vWebObject);
            }
            return(vWebObject);
        }
Exemple #2
0
        /// <summary>
        ///   The overloaded Load method that will return a <see cref="WorkoutCollection"/>.
        /// </summary>
        /// <param name="aFanKey">A <see cref="FanKey"/> object.</param>
        /// <param name="aWorkoutCollection">A <see cref="WorkoutCollection"/> object.</param>
        /// <exception cref="ArgumentNullException">If <c>aWorkoutCollection</c> argument is <c>null</c>.</exception>
        public static void Load(FanKey aFanKey, WorkoutCollection aWorkoutCollection)
        {
            if (aWorkoutCollection == null)
            {
                throw new ArgumentNullException("Load Workout Business");
            }

            //if (!FanFunctionAccessData.HasModeAccess(aFanKey, "Workout", AccessMode.List))
            //{
            //    throw new ZpAccessException("Access Denied", String.Format("{0}", aFanKey.WorkoutnKey), AccessMode.List, "Workout");
            //}

            WorkoutData.Load(aWorkoutCollection);
        }
Exemple #3
0
        /// <summary>
        ///   The overloaded Load method that will return a <see cref="WorkoutCollection"/>.
        /// </summary>
        /// <param name="aFanKey">A <see cref="FanKey"/> object.</param>
        /// <param name="aWorkoutCollection">A <see cref="WorkoutCollection"/> object.</param>
        /// <exception cref="ArgumentNullException">If <c>aWorkoutCollection</c> argument is <c>null</c>.</exception>
        public static void Load(FanKey aFanKey, WorkoutCollection aWorkoutCollection)
        {
            if (aWorkoutCollection == null)
            {
                throw new ArgumentNullException("Load Workout Business");
            }

            //if (!FanFunctionAccessData.HasModeAccess(aFanKey, "Workout", AccessMode.List))
            //{
            //    throw new ZpAccessException("Access Denied", String.Format("{0}", aFanKey.WorkoutnKey), AccessMode.List, "Workout");
            //}

            WorkoutData.Load(aWorkoutCollection);
        }
Exemple #4
0
 /// <summary>
 ///   The overloaded Load method that will fill the <c>WorkoutList</c> property a <see cref="WorkoutCollection"/> object as an
 ///   ordered <c>List</c> of <see cref="Workout"/>, filtered by the filter properties of the passed <see cref="WorkoutCollection"/>.
 /// </summary>
 /// <param name="aWorkoutCollection">The <see cref="WorkoutCollection"/> object that must be filled.</param>
 /// <remarks>
 ///   The filter properties of the <see cref="WorkoutCollection"/> must be correctly completed by the calling application.
 /// </remarks>
 /// <exception cref="ArgumentNullException">If <c>aWorkoutCollection</c> argument is <c>null</c>.</exception>
 public static void Load(WorkoutCollection aWorkoutCollection)
 {
     if (aWorkoutCollection == null)
     {
         throw new ArgumentNullException("aWorkoutCollection");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         if (aWorkoutCollection.IsFiltered)
         {
             if (aWorkoutCollection.WorkoutFilter.WrtFilter.WrtName != null)
             {
                 vStringBuilder.AppendFormat("where t1.WRT_Name is like '%{0}%", aWorkoutCollection.WorkoutFilter.WrtFilter.WrtName);
             }
             if (aWorkoutCollection.WorkoutFilter.WrtFilter.CelKey > 0)
             {
                 vStringBuilder.AppendLine("and t4.CEL_Key = @CELKey");
                 vSqlCommand.Parameters.AddWithValue("@CELKey", aWorkoutCollection.WorkoutFilter.WrtFilter.CelKey);
             }
             if (aWorkoutCollection.WorkoutFilter.WrtFilter.FedKey > 0)
             {
                 vStringBuilder.AppendFormat("and t3.FED_Key = @FEDKey", aWorkoutCollection.WorkoutFilter.WrtFilter.FedKey);
             }
             if (aWorkoutCollection.WorkoutFilter.WrtFilter.WrtOwnerKey > 0)
             {
                 vStringBuilder.AppendFormat("and t2.FAN_Key = @FANKey", aWorkoutCollection.WorkoutFilter.WrtFilter.WrtOwnerKey);
             }
         }
         vStringBuilder.AppendLine("order by t1.WRT_Name");
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             while (vSqlDataReader.Read())
             {
                 var vWorkout = new Workout();
                 DataToObject(vWorkout, vSqlDataReader);
                 aWorkoutCollection.WorkoutList.Add(vWorkout);
             }
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Exemple #5
0
        public static webObject loadWorkoutCollection(Workout aWorkout)
        {
            WorkoutCollection vWorkoutCollection = new WorkoutCollection();
            vWorkoutCollection.WorkoutFilter.WrtFilter.AssignFromSource(aWorkout);

            FanToken vFanToken = ServerSession.GetFanToken(HttpContext.Current.Session);
            webObject vWebObject = new webObject();
            vWebObject.aTransactionStatus = ServerSession.GetTransactionStatus(HttpContext.Current.Session);

            try
            {
                FanServiceConsumer.GetWorkoutCollection(vFanToken, vWorkoutCollection);
                vWebObject.aTransactionStatus.TransactionResult = TransactionResult.OK;
                vWebObject.aTransactionStatus.Message = "WorkoutCollection Loaded";
                ServerSession.SetTransactionStatus(HttpContext.Current.Session, vWebObject.aTransactionStatus);
                vWebObject.AnObject = vWorkoutCollection;
            }
            catch (TransactionStatusException tx)
            {

                vWebObject.aTransactionStatus.AssignFromSource(tx.TransactionStatus);
                return vWebObject;
            }
            catch (Exception ex)
            {
                vWebObject.aTransactionStatus.TransactionResult = TransactionResult.GeneralException;
                vWebObject.aTransactionStatus.Message = "Load of WorkoutCollection unsuccesful" + ex.Message;
                vWebObject.aTransactionStatus.InnerMessage = ex.InnerException == null ? String.Empty : ex.InnerException.Message;
                return vWebObject;
            }
            return vWebObject;
        }
 /// <summary>
 ///   The <c>GetWorkoutCollection</c> implementation method deserializes an incoming XML Argument <see cref="string"/> as a new <see cref="WorkoutCollection"/> object.
 ///   It invokes the <c>Insert</c> method of <see cref="WorkoutBusiness"/> with the newly deserialized <see cref="WorkoutCollection"/> 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="WorkoutCollection"/> as XML <see cref="string"/>.</returns>
 /// <exception cref="ArgumentNullException">If <c>aXmlArgument</c> is <c>null</c>.</exception>
 public static string GetWorkoutCollection(FanKey aFanKey, string aXmlArgument)
 {
     if (aXmlArgument == null)
     {
         throw new ArgumentNullException("aXmlArgument of GetWorkoutCollection");
     }
     WorkoutCollection vWorkoutCollection = new WorkoutCollection();
     vWorkoutCollection = XmlUtils.Deserialize<WorkoutCollection>(aXmlArgument);
     WorkoutBusiness.Load(aFanKey, vWorkoutCollection);
     return XmlUtils.Serialize<WorkoutCollection>(vWorkoutCollection, true);
 }
Exemple #7
0
 /// <summary>
 ///   The overloaded Load method that will fill the <c>WorkoutList</c> property a <see cref="WorkoutCollection"/> object as an
 ///   ordered <c>List</c> of <see cref="Workout"/>, filtered by the filter properties of the passed <see cref="WorkoutCollection"/>.
 /// </summary>
 /// <param name="aWorkoutCollection">The <see cref="WorkoutCollection"/> object that must be filled.</param>
 /// <remarks>
 ///   The filter properties of the <see cref="WorkoutCollection"/> must be correctly completed by the calling application.
 /// </remarks>
 /// <exception cref="ArgumentNullException">If <c>aWorkoutCollection</c> argument is <c>null</c>.</exception>
 public static void Load(WorkoutCollection aWorkoutCollection)
 {
     if (aWorkoutCollection == null)
     {
         throw new ArgumentNullException("aWorkoutCollection");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         if (aWorkoutCollection.IsFiltered)
         {
             if (aWorkoutCollection.WorkoutFilter.WrtFilter.WrtName != null)
             {
                 vStringBuilder.AppendFormat("where t1.WRT_Name is like '%{0}%", aWorkoutCollection.WorkoutFilter.WrtFilter.WrtName);
             }
             if (aWorkoutCollection.WorkoutFilter.WrtFilter.CelKey > 0)
             {
                 vStringBuilder.AppendLine("and t4.CEL_Key = @CELKey");
                 vSqlCommand.Parameters.AddWithValue("@CELKey", aWorkoutCollection.WorkoutFilter.WrtFilter.CelKey);
             }
             if (aWorkoutCollection.WorkoutFilter.WrtFilter.FedKey > 0)
             {
                 vStringBuilder.AppendFormat("and t3.FED_Key = @FEDKey", aWorkoutCollection.WorkoutFilter.WrtFilter.FedKey);
             }
             if (aWorkoutCollection.WorkoutFilter.WrtFilter.WrtOwnerKey > 0)
             {
                 vStringBuilder.AppendFormat("and t2.FAN_Key = @FANKey", aWorkoutCollection.WorkoutFilter.WrtFilter.WrtOwnerKey);
             }
         }
         vStringBuilder.AppendLine("order by t1.WRT_Name");
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             while (vSqlDataReader.Read())
             {
                 var vWorkout = new Workout();
                 DataToObject(vWorkout, vSqlDataReader);
                 aWorkoutCollection.WorkoutList.Add(vWorkout);
             }
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
 /// <summary>
 /// Gets a FanCollection
 /// </summary>
 /// <param name="aFantoken">A fantoken.</param>
 /// <param name="aWorkoutCollection">A user collection.</param>
 public static void GetWorkoutCollection(FanToken aFantoken, WorkoutCollection aWorkoutCollection)
 {
     FanCallHandler.ServiceCall <WorkoutCollection>(aFantoken, "GetWorkoutCollection", aWorkoutCollection);
 }
 /// <summary>
 /// Gets a FanCollection
 /// </summary>
 /// <param name="aFantoken">A fantoken.</param>
 /// <param name="aWorkoutCollection">A user collection.</param>
 public static void GetWorkoutCollection(FanToken aFantoken, WorkoutCollection aWorkoutCollection)
 {
     FanCallHandler.ServiceCall<WorkoutCollection>(aFantoken, "GetWorkoutCollection", aWorkoutCollection);
 }