Exemple #1
0
        public static webObject editFanSessionCollection(FanSessionCollection aFanSessionCollection)
        {
            FanToken  vFanToken  = ServerSession.GetFanToken(HttpContext.Current.Session);
            webObject vWebObject = new webObject();

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

            try
            {
                FanServiceConsumer.SaveFanSession(vFanToken, aFanSessionCollection);
                vWebObject.aTransactionStatus.TransactionResult = TransactionResult.OK;
                vWebObject.aTransactionStatus.Message           = "FanSessionCollection Edited";
                ServerSession.SetTransactionStatus(HttpContext.Current.Session, vWebObject.aTransactionStatus);
                vWebObject.AnObject = aFanSessionCollection;
            }
            catch (TransactionStatusException tx)
            {
                vWebObject.aTransactionStatus.AssignFromSource(tx.TransactionStatus);
                return(vWebObject);
            }
            catch (Exception ex)
            {
                vWebObject.aTransactionStatus.TransactionResult = TransactionResult.GeneralException;
                vWebObject.aTransactionStatus.Message           = "Edit of FanSessionCollection 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 fill the <c>FanSessionList</c> property a <see cref="FanSessionCollection"/> object as an
 ///   ordered <c>List</c> of <see cref="FanSession"/>, filtered by the filter properties of the passed <see cref="FanSessionCollection"/>.
 /// </summary>
 /// <param name="aFanSessionCollection">The <see cref="FanSessionCollection"/> object that must be filled.</param>
 /// <remarks>
 ///   The filter properties of the <see cref="FanSessionCollection"/> must be correctly completed by the calling application.
 /// </remarks>
 /// <exception cref="ArgumentNullException">If <c>aFanSessionCollection</c> argument is <c>null</c>.</exception>
 public static void Load(FanSessionCollection aFanSessionCollection)
 {
     if (aFanSessionCollection == null)
     {
         throw new ArgumentNullException("aFanSessionCollection");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         if (aFanSessionCollection.IsFiltered)
         {
             if (aFanSessionCollection.FanSessionFilter.FssFilter.WrtKey > 0)
             {
                 vStringBuilder.AppendLine("and t1.WRT_Key = @WRTKey");
                 vSqlCommand.Parameters.AddWithValue("@WRTKey", aFanSessionCollection.FanSessionFilter.FssFilter.WrtKey);
             }
             if (aFanSessionCollection.FanSessionFilter.FssFilter.FanKey > 0)
             {
                 vStringBuilder.AppendLine("and t2.FAN_Key = @FANKey");
                 vSqlCommand.Parameters.AddWithValue("@FANKey", aFanSessionCollection.FanSessionFilter.FssFilter.FanKey);
             }
             if (aFanSessionCollection.FanSessionFilter.FssFilter.WrtName != null)
             {
                 vStringBuilder.AppendFormat("and t1.WRT_Name like '%{0}%'", aFanSessionCollection.FanSessionFilter.FssFilter.WrtName);
             }
             if (aFanSessionCollection.FanSessionFilter.FssFilter.FanName != null)
             {
                 vStringBuilder.AppendFormat("and t2.FAN_Name like '%{0}%'", aFanSessionCollection.FanSessionFilter.FssFilter.FanName);
             }
         }
         vStringBuilder.AppendLine("order by t1.WRT_Name");
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             while (vSqlDataReader.Read())
             {
                 var vFanSession = new FanSession();
                 DataToObject(vFanSession, vSqlDataReader, false);
                 aFanSessionCollection.FanSessionList.Add(vFanSession);
             }
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
        /// <summary>
        ///   The overloaded Load method that will return a <see cref="FanSessionCollection"/>.
        /// </summary>
        /// <param name="aFanKey">A <see cref="FanKey"/> object.</param>
        /// <param name="aFanSessionCollection">A <see cref="FanSessionCollection"/> object.</param>
        /// <exception cref="ArgumentNullException">If <c>aFanSessionCollection</c> argument is <c>null</c>.</exception>
        public static void Load(FanKey aFanKey, FanSessionCollection aFanSessionCollection)
        {
            if (aFanSessionCollection == null)
            {
                throw new ArgumentNullException("Load FanSession Business");
            }

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

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

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

            FanSessionData.Load(aFanSessionCollection);
        }
Exemple #5
0
 /// <summary>
 ///   Insert a <see cref="FanSession"/> passed as an argument via Stored Procedure that returns the newly inserted FanSession Key
 /// </summary>
 /// <param name="aFanSession">A <see cref="FanSession"/>.</param>
 /// <exception cref="ArgumentNullException">If <c>aFanSession</c> argument is <c>null</c>.</exception>
 public static void Insert(FanSessionCollection aFanSessionCollection)
 {
     if (aFanSessionCollection == null)
     {
         throw new ArgumentNullException("aFanSessionCollection");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("insert into FSS_FanSession");
         vStringBuilder.AppendLine("       (WRT_Key,");
         vStringBuilder.AppendLine("        FAN_Key,");
         vStringBuilder.AppendLine("        CEL_Key,");
         vStringBuilder.AppendLine("        PRG_Key,");
         vStringBuilder.AppendLine("        FSS_Lock,");
         vStringBuilder.AppendLine("        FSS_DateDone)");
         vStringBuilder.AppendLine("values");
         vStringBuilder.AppendLine("       (@WRTKey,");
         vStringBuilder.AppendLine("       (@FANKey,");
         vStringBuilder.AppendLine("       (@CELKey,");
         vStringBuilder.AppendLine("       (@PRGKey,");
         vStringBuilder.AppendLine("       (@FSSLock,");
         vStringBuilder.AppendLine("        @FSSDateDone)");
         vStringBuilder.AppendLine(";");
         vSqlCommand.Parameters.Add("@WRTKey", SqlDbType.Int);
         vSqlCommand.Parameters.Add("@FANKey", SqlDbType.Int);
         vSqlCommand.Parameters.Add("@CELKey", SqlDbType.Int);
         vSqlCommand.Parameters.Add("@PRGKey", SqlDbType.Int);
         vSqlCommand.Parameters.Add("@FSSLock", SqlDbType.Char);
         vSqlCommand.Parameters.Add("@FSSDateDone", SqlDbType.DateTime);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         aFanSessionCollection.FanSessionList.ForEach(vFanSession =>
         {
             vSqlCommand.Parameters["@WRTKey"].Value      = vFanSession.WrtKey;
             vSqlCommand.Parameters["@FANKey"].Value      = vFanSession.FanKey;
             vSqlCommand.Parameters["@CELKey"].Value      = vFanSession.CelKey;
             vSqlCommand.Parameters["@PRGKey"].Value      = vFanSession.PrgKey;
             vSqlCommand.Parameters["@FSSLock"].Value     = vFanSession.FssLock;
             vSqlCommand.Parameters["@FSSDateDone"].Value = DateTime.Parse(vFanSession.FanSessionDateDone);
             vSqlCommand.ExecuteScalar();
         });
         vSqlCommand.Connection.Close();
     }
 }
Exemple #6
0
        /// <summary>
        /// Save a <see cref="FanSession" /> list passed as an argument.
        /// </summary>
        /// <param name="aFanKey">A <see cref="FanKey" /> object.</param>
        /// <param name="aFanSessionCollection">A cell fan collection.</param>
        /// <exception cref="Zephry.ZpAccessException">Access Denied; FanSession</exception>
        /// <exception cref="ArgumentNullException">If <c>aFanSession</c> argument is <c>null</c>.</exception>
        public static void Save(FanKey aFanKey, FanSessionCollection aFanSessionCollection)
        {
            if (aFanSessionCollection == null)
            {
                throw new ArgumentNullException("Update FanSessionCollection Business");
            }

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

            //Set Dates of new fanworkouts
            DateTime x;

            foreach (FanSession aFw in aFanSessionCollection.FanSessionList)
            {
                if (!(DateTime.TryParse(aFw.FanSessionDateDone, out x)))
                {
                    aFw.FanSessionDateDone = DateTime.Now.ToLongDateString();;
                }
            }
            FanSessionData.Save(aFanSessionCollection);
        }
Exemple #7
0
        public static webObject loadFanSessionCollection(FanSessionCollection aFanSessionCollection)
        {
            FanToken vFanToken = ServerSession.GetFanToken(HttpContext.Current.Session);
            FanKey vFanKey = ServerSession.GetObject<FanKey>(HttpContext.Current.Session);
            aFanSessionCollection.FanSessionFilter.FssFilter.FanKey = vFanKey.FannKey;
            webObject vWebObject = new webObject();
            vWebObject.aTransactionStatus = ServerSession.GetTransactionStatus(HttpContext.Current.Session);

            try
            {
                FanServiceConsumer.GetFanSessionCollection(vFanToken, aFanSessionCollection);
                vWebObject.aTransactionStatus.TransactionResult = TransactionResult.OK;
                vWebObject.aTransactionStatus.Message = "FanSessionCollection Loaded";
                ServerSession.SetTransactionStatus(HttpContext.Current.Session, vWebObject.aTransactionStatus);
                vWebObject.AnObject = aFanSessionCollection;
            }
            catch (TransactionStatusException tx)
            {
                vWebObject.aTransactionStatus.AssignFromSource(tx.TransactionStatus);
                return vWebObject;
            }
            catch (Exception ex)
            {
                vWebObject.aTransactionStatus.TransactionResult = TransactionResult.GeneralException;
                vWebObject.aTransactionStatus.Message = "Load of FanSessionCollection unsuccesful" + ex.Message;
                vWebObject.aTransactionStatus.InnerMessage = ex.InnerException == null ? String.Empty : ex.InnerException.Message;
                return vWebObject;
            }
            return vWebObject;
        }
Exemple #8
0
 public static void Save(FanSessionCollection aFanSessionCollection)
 {
     Delete(aFanSessionCollection.FanSessionFilter.FssFilter);
     Insert(aFanSessionCollection);
 }
 /// <summary>
 /// Saves the provider suburb.
 /// </summary>
 /// <param name="aFanKey">A user key.</param>
 /// <param name="aXmlArgument">A XML argument.</param>
 /// <returns>A string of XML representing a FanSessionCollection</returns>
 /// <exception cref="System.ArgumentNullException">aXmlArgument of SaveFanSession</exception>
 public static string SaveFanSession(FanKey aFanKey, string aXmlArgument)
 {
     if (aXmlArgument == null)
     {
         throw new ArgumentNullException("aXmlArgument of SaveFanSession");
     }
     FanSessionCollection vFanSessionCollection = new FanSessionCollection();
     vFanSessionCollection = XmlUtils.Deserialize<FanSessionCollection>(aXmlArgument);
     FanSessionBusiness.Save(aFanKey, vFanSessionCollection);
     return XmlUtils.Serialize<FanSessionCollection>(vFanSessionCollection, true);
 }
 /// <summary>
 /// Add a <see cref="FanSession" />.
 /// </summary>
 /// <param name="aFanToken">A <see cref="FanToken" /> object used for Access Control.</param>
 /// <param name="aFanSessionCollection">A provider suburb collection.</param>
 public static void SaveFanSession(FanToken aFanToken, FanSessionCollection aFanSessionCollection)
 {
     FanCallHandler.ServiceCall <FanSessionCollection>(aFanToken, "SaveFanSession", aFanSessionCollection);
 }
        /// <summary>
        /// Save a <see cref="FanSession" /> list passed as an argument.
        /// </summary>
        /// <param name="aFanKey">A <see cref="FanKey" /> object.</param>
        /// <param name="aFanSessionCollection">A cell fan collection.</param>
        /// <exception cref="Zephry.ZpAccessException">Access Denied; FanSession</exception>
        /// <exception cref="ArgumentNullException">If <c>aFanSession</c> argument is <c>null</c>.</exception>
        public static void Save(FanKey aFanKey, FanSessionCollection aFanSessionCollection)
        {
            if (aFanSessionCollection == null)
            {
                throw new ArgumentNullException("Update FanSessionCollection Business");
            }

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

            //Set Dates of new fanworkouts
            DateTime x;
            foreach (FanSession aFw in aFanSessionCollection.FanSessionList)
            {
                if (!(DateTime.TryParse(aFw.FanSessionDateDone, out x)))
                {
                    aFw.FanSessionDateDone = DateTime.Now.ToLongDateString(); ;
                }
            }
            FanSessionData.Save(aFanSessionCollection);
        }
Exemple #12
0
 public static void Save(FanSessionCollection aFanSessionCollection)
 {
     Delete(aFanSessionCollection.FanSessionFilter.FssFilter);
     Insert(aFanSessionCollection);
 }
Exemple #13
0
 /// <summary>
 ///   The overloaded Load method that will fill the <c>FanSessionList</c> property a <see cref="FanSessionCollection"/> object as an
 ///   ordered <c>List</c> of <see cref="FanSession"/>, filtered by the filter properties of the passed <see cref="FanSessionCollection"/>.
 /// </summary>
 /// <param name="aFanSessionCollection">The <see cref="FanSessionCollection"/> object that must be filled.</param>
 /// <remarks>
 ///   The filter properties of the <see cref="FanSessionCollection"/> must be correctly completed by the calling application.
 /// </remarks>
 /// <exception cref="ArgumentNullException">If <c>aFanSessionCollection</c> argument is <c>null</c>.</exception>
 public static void Load(FanSessionCollection aFanSessionCollection)
 {
     if (aFanSessionCollection == null)
     {
         throw new ArgumentNullException("aFanSessionCollection");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         if (aFanSessionCollection.IsFiltered)
         {
             if (aFanSessionCollection.FanSessionFilter.FssFilter.WrtKey > 0)
             {
                 vStringBuilder.AppendLine("and t1.WRT_Key = @WRTKey");
                 vSqlCommand.Parameters.AddWithValue("@WRTKey", aFanSessionCollection.FanSessionFilter.FssFilter.WrtKey);
             }
             if (aFanSessionCollection.FanSessionFilter.FssFilter.FanKey > 0)
             {
                 vStringBuilder.AppendLine("and t2.FAN_Key = @FANKey");
                 vSqlCommand.Parameters.AddWithValue("@FANKey", aFanSessionCollection.FanSessionFilter.FssFilter.FanKey);
             }
             if (aFanSessionCollection.FanSessionFilter.FssFilter.WrtName != null)
             {
                 vStringBuilder.AppendFormat("and t1.WRT_Name like '%{0}%'", aFanSessionCollection.FanSessionFilter.FssFilter.WrtName);
             }
             if (aFanSessionCollection.FanSessionFilter.FssFilter.FanName != null)
             {
                 vStringBuilder.AppendFormat("and t2.FAN_Name like '%{0}%'", aFanSessionCollection.FanSessionFilter.FssFilter.FanName);
             }
         }
         vStringBuilder.AppendLine("order by t1.WRT_Name");
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             while (vSqlDataReader.Read())
             {
                 var vFanSession = new FanSession();
                 DataToObject(vFanSession, vSqlDataReader, false);
                 aFanSessionCollection.FanSessionList.Add(vFanSession);
             }
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Exemple #14
0
 /// <summary>
 ///   Insert a <see cref="FanSession"/> passed as an argument via Stored Procedure that returns the newly inserted FanSession Key 
 /// </summary>
 /// <param name="aFanSession">A <see cref="FanSession"/>.</param>
 /// <exception cref="ArgumentNullException">If <c>aFanSession</c> argument is <c>null</c>.</exception>
 public static void Insert(FanSessionCollection aFanSessionCollection)
 {
     if (aFanSessionCollection == null)
     {
         throw new ArgumentNullException("aFanSessionCollection");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("insert into FSS_FanSession");
         vStringBuilder.AppendLine("       (WRT_Key,");
         vStringBuilder.AppendLine("        FAN_Key,");
         vStringBuilder.AppendLine("        CEL_Key,");
         vStringBuilder.AppendLine("        PRG_Key,");
         vStringBuilder.AppendLine("        FSS_Lock,");
         vStringBuilder.AppendLine("        FSS_DateDone)");
         vStringBuilder.AppendLine("values");
         vStringBuilder.AppendLine("       (@WRTKey,");
         vStringBuilder.AppendLine("       (@FANKey,");
         vStringBuilder.AppendLine("       (@CELKey,");
         vStringBuilder.AppendLine("       (@PRGKey,");
         vStringBuilder.AppendLine("       (@FSSLock,");
         vStringBuilder.AppendLine("        @FSSDateDone)");
         vStringBuilder.AppendLine(";");
         vSqlCommand.Parameters.Add("@WRTKey", SqlDbType.Int);
         vSqlCommand.Parameters.Add("@FANKey", SqlDbType.Int);
         vSqlCommand.Parameters.Add("@CELKey", SqlDbType.Int);
         vSqlCommand.Parameters.Add("@PRGKey", SqlDbType.Int);
         vSqlCommand.Parameters.Add("@FSSLock", SqlDbType.Char);
         vSqlCommand.Parameters.Add("@FSSDateDone", SqlDbType.DateTime);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         aFanSessionCollection.FanSessionList.ForEach(vFanSession =>
         {
             vSqlCommand.Parameters["@WRTKey"].Value = vFanSession.WrtKey;
             vSqlCommand.Parameters["@FANKey"].Value = vFanSession.FanKey;
             vSqlCommand.Parameters["@CELKey"].Value = vFanSession.CelKey;
             vSqlCommand.Parameters["@PRGKey"].Value = vFanSession.PrgKey;
             vSqlCommand.Parameters["@FSSLock"].Value = vFanSession.FssLock;
             vSqlCommand.Parameters["@FSSDateDone"].Value = DateTime.Parse(vFanSession.FanSessionDateDone);
             vSqlCommand.ExecuteScalar();
         });
         vSqlCommand.Connection.Close();
     }
 }
 /// <summary>
 /// Add a <see cref="FanSession" />.
 /// </summary>
 /// <param name="aFanToken">A <see cref="FanToken" /> object used for Access Control.</param>
 /// <param name="aFanSessionCollection">A provider suburb collection.</param>
 public static void SaveFanSession(FanToken aFanToken, FanSessionCollection aFanSessionCollection)
 {
     FanCallHandler.ServiceCall<FanSessionCollection>(aFanToken, "SaveFanSession", aFanSessionCollection);
 }