Exemplo n.º 1
0
 /// <summary>
 ///   The overloaded Load method that will return a specific <see cref="FanSession"/>, with keys in the <c>aFanSession</c> argument.
 /// </summary>
 /// <param name="aFanSession">A <see cref="FanSession"/>.</param>
 /// <exception cref="ArgumentNullException">If <c>aFanSession</c> argument is <c>null</c>.</exception>
 /// <exception cref="Exception">If no record is found.</exception>
 public static void Load(FanSession aFanSession)
 {
     if (aFanSession == null)
     {
         throw new ArgumentNullException("aFanSession");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         vStringBuilder.AppendLine("and t3.WRT_Key = @WRTKey");
         vStringBuilder.AppendLine("and t3.FAN_Key = @FANKey");
         vStringBuilder.AppendLine("and t4.FSS_Key = @FSSKey");
         vSqlCommand.Parameters.AddWithValue("@WRTKey", aFanSession.WrtKey);
         vSqlCommand.Parameters.AddWithValue("@FANKey", aFanSession.FanKey);
         vSqlCommand.Parameters.AddWithValue("@FSSKey", aFanSession.FssKey);
         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}, FSS_Key = {2}", aFanSession.WrtKey, aFanSession.FanKey, aFanSession.FssKey));
             }
             vSqlDataReader.Read();
             DataToObject(aFanSession, vSqlDataReader, true);
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Exemplo n.º 2
0
        public static webObject deleteFanSession(FanSession aFanSession)
        {
            FanToken  vFanToken  = ServerSession.GetFanToken(HttpContext.Current.Session);
            webObject vWebObject = new webObject();

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

            try
            {
                FanServiceConsumer.DeleteFanSession(vFanToken, aFanSession);
                vWebObject.aTransactionStatus.TransactionResult = TransactionResult.OK;
                vWebObject.aTransactionStatus.Message           = "FanSession Deleted";
                ServerSession.SetTransactionStatus(HttpContext.Current.Session, vWebObject.aTransactionStatus);
                vWebObject.AnObject = aFanSession;
            }
            catch (TransactionStatusException tx)
            {
                vWebObject.aTransactionStatus.AssignFromSource(tx.TransactionStatus);
                return(vWebObject);
            }
            catch (Exception ex)
            {
                vWebObject.aTransactionStatus.TransactionResult = TransactionResult.GeneralException;
                vWebObject.aTransactionStatus.Message           = "Deletion of FanSession unsuccesful" + ex.Message;
                vWebObject.aTransactionStatus.InnerMessage      = ex.InnerException == null ? String.Empty : ex.InnerException.Message;
                return(vWebObject);
            }
            return(vWebObject);
        }
Exemplo n.º 3
0
 /// <summary>
 ///   Delete a <see cref="FanSession"/> object passed as an argument.
 /// </summary>
 /// <param name="aFanSession">The <see cref="FanSession"/> object to be deleted.</param>
 /// <exception cref="ArgumentNullException">If <c>aFanSession</c> argument is <c>null</c>.</exception>
 public static void Delete(FanSession aFanSession)
 {
     if (aFanSession == null)
     {
         throw new ArgumentNullException("aFanSession");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("delete FSS_FanSession");
         vStringBuilder.AppendLine("where  WRT_Key = @WRTKey");
         vStringBuilder.AppendLine("and    FAN_Key = @FANKey");
         vStringBuilder.AppendLine("and    FSS_Key = @FSSKey");
         vSqlCommand.Parameters.AddWithValue("@WRTKey", aFanSession.WrtKey);
         vSqlCommand.Parameters.AddWithValue("@FANKey", aFanSession.FanKey);
         vSqlCommand.Parameters.AddWithValue("@FSSKey", aFanSession.FssKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Exemplo n.º 4
0
 /// <summary>
 ///   Update a <see cref="FanSession"/> passed as an argument .
 /// </summary>
 /// <param name="aFanSession">A <see cref="FanSession"/>.</param>
 public static void Update(FanSession aFanSession)
 {
     if (aFanSession == null)
     {
         throw new ArgumentNullException("aFanSession");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("update FSS_FanSession");
         vStringBuilder.AppendLine("set    CEL_Key = @CELKey,");
         vStringBuilder.AppendLine("       PRG_KEY = @PRGKEY,");
         vStringBuilder.AppendLine("       FSS_Lock = @FSSLock,");
         vStringBuilder.AppendLine("       FSS_DateDone = @FSSDateDone");
         vStringBuilder.AppendLine("where  WRT_Key = @WRTKey");
         vStringBuilder.AppendLine("and    FAN_Key = @FANKey");
         vStringBuilder.AppendLine("and    FSS_Key = @FSSKey");
         ObjectToData(vSqlCommand, aFanSession);
         vSqlCommand.Parameters.AddWithValue("@FSSKey", aFanSession.FssKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Exemplo n.º 5
0
 /// <summary>
 ///   Delete a <see cref="FanSession"/> object passed as an argument.
 /// </summary>
 /// <param name="aFanSession">The <see cref="FanSession"/> object to be deleted.</param>
 /// <exception cref="ArgumentNullException">If <c>aFanSession</c> argument is <c>null</c>.</exception>
 public static void Delete(FanSession aFanSession)
 {
     if (aFanSession == null)
     {
         throw new ArgumentNullException("aFanSession");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("delete FSS_FanSession");
         vStringBuilder.AppendLine("where  WRT_Key = @WRTKey");
         vStringBuilder.AppendLine("and    FAN_Key = @FANKey");
         vStringBuilder.AppendLine("and    FSS_Key = @FSSKey");
         vSqlCommand.Parameters.AddWithValue("@WRTKey", aFanSession.WrtKey);
         vSqlCommand.Parameters.AddWithValue("@FANKey", aFanSession.FanKey);
         vSqlCommand.Parameters.AddWithValue("@FSSKey", aFanSession.FssKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Exemplo n.º 6
0
        public static webObject addFanSession(FanSession aFanSession)
        {
            FanToken vFanToken = ServerSession.GetFanToken(HttpContext.Current.Session);
            FanKey vFanKey = ServerSession.GetObject<FanKey>(HttpContext.Current.Session);
            webObject vWebObject = new webObject();
            vWebObject.aTransactionStatus = ServerSession.GetTransactionStatus(HttpContext.Current.Session);

            try
            {
                FanServiceConsumer.AddFanSession(vFanToken, aFanSession);
                vWebObject.aTransactionStatus.TransactionResult = TransactionResult.OK;
                vWebObject.aTransactionStatus.Message = "FanSession Added";
                ServerSession.SetTransactionStatus(HttpContext.Current.Session, vWebObject.aTransactionStatus);
                vWebObject.AnObject = aFanSession;
            }
            catch (TransactionStatusException tx)
            {

                vWebObject.aTransactionStatus.AssignFromSource(tx.TransactionStatus);
                return vWebObject;
            }
            catch (Exception ex)
            {
                vWebObject.aTransactionStatus.TransactionResult = TransactionResult.GeneralException;
                vWebObject.aTransactionStatus.Message = "Addition of FanSession unsuccesful" + ex.Message;
                vWebObject.aTransactionStatus.InnerMessage = ex.InnerException == null ? String.Empty : ex.InnerException.Message;
                return vWebObject;
            }
            return vWebObject;
        }
Exemplo n.º 7
0
 /// <summary>
 ///   Loads the <see cref="SqlCommand"/> parameters with values from an <see cref="FanSession"/>.
 /// </summary>
 /// <param name="aSqlCommand">A <see cref="SqlDataReader"/> argument.</param>
 /// <param name="aWorkout">A <see cref="FanSession"/> argument.</param>
 public static void ObjectToData(SqlCommand aSqlCommand, FanSession aFanSession)
 {
     aSqlCommand.Parameters.AddWithValue("@WRTKey", aFanSession.WrtKey);
     aSqlCommand.Parameters.AddWithValue("@FANKey", aFanSession.FanKey);
     aSqlCommand.Parameters.AddWithValue("@CELKey", aFanSession.CelKey);
     aSqlCommand.Parameters.AddWithValue("@FSSLock", aFanSession.FssLock);
     aSqlCommand.Parameters.AddWithValue("@PRGKey", aFanSession.PrgKey);
     aSqlCommand.Parameters.AddWithValue("@FSSDateDone", DateTime.Parse(aFanSession.FanSessionDateDone));
 }
Exemplo n.º 8
0
        /// <summary>
        ///   The overloaded Load method that will return a specific <see cref="FanSession"/> object, with keys in <c>aFanSession</c>.
        /// </summary>
        /// <param name="aFanKey">A <see cref="FanKey"/> object.</param>
        /// <param name="aFanSession">A <see cref="FanSession"/>.</param>
        /// <exception cref="ArgumentNullException">If <c>aFanSession</c> is <c>null</c>.</exception>
        public static void Load(FanKey aFanKey, FanSession aFanSession)
        {
            if (aFanSession == null)
            {
                throw new ArgumentNullException("Load FanSession Business");
            }

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

            FanSessionData.Load(aFanSession);
        }
Exemplo n.º 9
0
        /// <summary>
        ///   Insert a <see cref="FanSession"/> object passed as an argument via Stored Procedure that returns the newly inserted <i>FanSession Key</i>.
        /// </summary>
        /// <param name="aFanKey">A <see cref="FanKey"/> object.</param>
        /// <param name="aFanSession">A <see cref="FanSession"/> object.</param>
        /// <exception cref="ArgumentNullException">If <c>aFanSession</c> argument is <c>null</c>.</exception>
        public static void Insert(FanKey aFanKey, FanSession aFanSession)
        {
            if (aFanSession == null)
            {
                throw new ArgumentNullException("Insert FanSession Business");
            }

            //if (!FanFunctionAccessData.HasModeAccess(aFanKey, "FanSession", AccessMode.Create))
            //{
            //    throw new ZpAccessException("Access Denied", String.Format("{0}", aFanKey.FannKey), AccessMode.Create, "FanSession");
            //}
            aFanSession.FanSessionDateDone = DateTime.Now.ToLongDateString();
            FanSessionData.Insert(aFanSession);
        }
Exemplo n.º 10
0
        /// <summary>
        ///   The overloaded Load method that will return a specific <see cref="FanSession"/> object, with keys in <c>aFanSession</c>.
        /// </summary>
        /// <param name="aFanKey">A <see cref="FanKey"/> object.</param>
        /// <param name="aFanSession">A <see cref="FanSession"/>.</param>
        /// <exception cref="ArgumentNullException">If <c>aFanSession</c> is <c>null</c>.</exception>
        public static void Load(FanKey aFanKey, FanSession aFanSession)
        {
            if (aFanSession == null)
            {
                throw new ArgumentNullException("Load FanSession Business");
            }

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

            FanSessionData.Load(aFanSession);
        }
Exemplo n.º 11
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();
     }
 }
Exemplo n.º 12
0
        /// <summary>
        ///   Insert a <see cref="FanSession"/> object passed as an argument via Stored Procedure that returns the newly inserted <i>FanSession Key</i>.
        /// </summary>
        /// <param name="aFanKey">A <see cref="FanKey"/> object.</param>
        /// <param name="aFanSession">A <see cref="FanSession"/> object.</param>
        /// <exception cref="ArgumentNullException">If <c>aFanSession</c> argument is <c>null</c>.</exception>
        public static void Insert(FanKey aFanKey, FanSession aFanSession)
        {
            if (aFanSession == null)
            {
                throw new ArgumentNullException("Insert FanSession Business");
            }

            //if (!FanFunctionAccessData.HasModeAccess(aFanKey, "FanSession", AccessMode.Create))
            //{
            //    throw new ZpAccessException("Access Denied", String.Format("{0}", aFanKey.FannKey), AccessMode.Create, "FanSession");
            //}
            aFanSession.FanSessionDateDone = DateTime.Now.ToLongDateString();
            FanSessionData.Insert(aFanSession);
        }
Exemplo n.º 13
0
 /// <summary>
 ///   Load a <see cref="SqlDataReader"/> into a <see cref="FanSession"/> object.
 /// </summary>
 /// <param name="aFanSession">A <see cref="Workout"/> argument.</param>
 /// <param name="aSqlDataReader">A <see cref="SqlDataReader"/> argument.</param>
 public static void DataToObject(FanSession aFanSession, SqlDataReader aSqlDataReader, bool aIncludeAvatar)
 {
     aFanSession.WrtKey             = Convert.ToInt32(aSqlDataReader["WRT_Key"]);
     aFanSession.WrtName            = Convert.ToString(aSqlDataReader["WRT_Name"]);
     aFanSession.FanKey             = Convert.ToInt32(aSqlDataReader["FAN_Key"]);
     aFanSession.FanName            = Convert.ToString(aSqlDataReader["FAN_Name"]);
     aFanSession.FanSurname         = Convert.ToString(aSqlDataReader["FAN_Surname"]);
     aFanSession.FssKey             = Convert.ToInt32(aSqlDataReader["FSS_Key"]);
     aFanSession.FanSessionDateDone = (Convert.ToDateTime(aSqlDataReader["FSS_DateDone"])).ToLongDateString();
     aFanSession.CelKey             = Convert.ToInt32(aSqlDataReader["CEL_Key"]);
     aFanSession.CelName            = Convert.ToString(aSqlDataReader["FAN_Surname"]);
     aFanSession.PrgKey             = Convert.ToInt32(aSqlDataReader["PRG_Key"]);
     aFanSession.PrgName            = Convert.ToString(aSqlDataReader["FAN_Surname"]);
     aFanSession.FssLock            = Convert.ToChar(aSqlDataReader["FSS_Lock"]) == 'Y' ? true : false;
 }
Exemplo n.º 14
0
 /// <summary>
 ///   Load a <see cref="SqlDataReader"/> into a <see cref="FanSession"/> object.
 /// </summary>
 /// <param name="aFanSession">A <see cref="Workout"/> argument.</param>
 /// <param name="aSqlDataReader">A <see cref="SqlDataReader"/> argument.</param>
 public static void DataToObject(FanSession aFanSession, SqlDataReader aSqlDataReader, bool aIncludeAvatar)
 {
     aFanSession.WrtKey = Convert.ToInt32(aSqlDataReader["WRT_Key"]);
     aFanSession.WrtName = Convert.ToString(aSqlDataReader["WRT_Name"]);
     aFanSession.FanKey = Convert.ToInt32(aSqlDataReader["FAN_Key"]);
     aFanSession.FanName = Convert.ToString(aSqlDataReader["FAN_Name"]);
     aFanSession.FanSurname = Convert.ToString(aSqlDataReader["FAN_Surname"]);
     aFanSession.FssKey = Convert.ToInt32(aSqlDataReader["FSS_Key"]);
     aFanSession.FanSessionDateDone = (Convert.ToDateTime(aSqlDataReader["FSS_DateDone"])).ToLongDateString();
     aFanSession.CelKey = Convert.ToInt32(aSqlDataReader["CEL_Key"]);
     aFanSession.CelName = Convert.ToString(aSqlDataReader["FAN_Surname"]);
     aFanSession.PrgKey = Convert.ToInt32(aSqlDataReader["PRG_Key"]);
     aFanSession.PrgName = Convert.ToString(aSqlDataReader["FAN_Surname"]);
     aFanSession.FssLock = Convert.ToChar(aSqlDataReader["FSS_Lock"]) == 'Y' ? true : false;
 }
Exemplo n.º 15
0
        /// <summary>
        ///    Assigns all <c>aSource</c> object's values to this instance of <see cref="FanSessionCollection"/>.
        /// </summary>
        /// <param name="aSource">A source object.</param>
        public override void AssignFromSource(object aSource)
        {
            if (!(aSource is FanSessionCollection))
            {
                throw new ArgumentException("Invalid assignment source", "FanSessionCollection");
            }

            _isFiltered = (aSource as FanSessionCollection)._isFiltered;
            _fanSessionFilter = (aSource as FanSessionCollection)._fanSessionFilter;
            _fanSessionList.Clear();
            foreach (FanSession vFanSessionSource in (aSource as FanSessionCollection)._fanSessionList)
            {
                FanSession vFanSessionTarget = new FanSession();
                vFanSessionTarget.AssignFromSource(vFanSessionSource);
                _fanSessionList.Add(vFanSessionTarget);
            }
        }
Exemplo n.º 16
0
        /// <summary>
        ///    Assigns all <c>aSource</c> object's values to this instance of <see cref="FanSessionCollection"/>.
        /// </summary>
        /// <param name="aSource">A source object.</param>
        public override void AssignFromSource(object aSource)
        {
            if (!(aSource is FanSessionCollection))
            {
                throw new ArgumentException("Invalid assignment source", "FanSessionCollection");
            }

            _isFiltered       = (aSource as FanSessionCollection)._isFiltered;
            _fanSessionFilter = (aSource as FanSessionCollection)._fanSessionFilter;
            _fanSessionList.Clear();
            foreach (FanSession vFanSessionSource in (aSource as FanSessionCollection)._fanSessionList)
            {
                FanSession vFanSessionTarget = new FanSession();
                vFanSessionTarget.AssignFromSource(vFanSessionSource);
                _fanSessionList.Add(vFanSessionTarget);
            }
        }
Exemplo n.º 17
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(FanSession aFanSession)
 {
     if (aFanSession == null)
     {
         throw new ArgumentNullException("aFanSession");
     }
     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("       (FAN_Key,");
         vStringBuilder.AppendLine("        WRT_Key,");
         vStringBuilder.AppendLine("        FSS_DateDone,");
         vStringBuilder.AppendLine("        CEL_Key,");
         vStringBuilder.AppendLine("        PRG_Key,");
         vStringBuilder.AppendLine("        FSS_Lock)");
         vStringBuilder.AppendLine("values");
         vStringBuilder.AppendLine("       (@FANKey,");
         vStringBuilder.AppendLine("        @WRTKey,");
         vStringBuilder.AppendLine("        @FSSDateDone,");
         vStringBuilder.AppendLine("        @CELKey,");
         vStringBuilder.AppendLine("        @PRGKey,");
         vStringBuilder.AppendLine("        @FSSLock)");
         vStringBuilder.AppendLine(";");
         vStringBuilder.AppendLine("select SCOPE_IDENTITY()");
         ObjectToData(vSqlCommand, aFanSession);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         aFanSession.FssKey = Convert.ToInt32(vSqlCommand.ExecuteScalar());
         vSqlCommand.Connection.Close();
     }
 }
Exemplo n.º 18
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(FanSession aFanSession)
 {
     if (aFanSession == null)
     {
         throw new ArgumentNullException("aFanSession");
     }
     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("       (FAN_Key,");
         vStringBuilder.AppendLine("        WRT_Key,");
         vStringBuilder.AppendLine("        FSS_DateDone,");
         vStringBuilder.AppendLine("        CEL_Key,");
         vStringBuilder.AppendLine("        PRG_Key,");
         vStringBuilder.AppendLine("        FSS_Lock)");
         vStringBuilder.AppendLine("values");
         vStringBuilder.AppendLine("       (@FANKey,");
         vStringBuilder.AppendLine("        @WRTKey,");
         vStringBuilder.AppendLine("        @FSSDateDone,");
         vStringBuilder.AppendLine("        @CELKey,");
         vStringBuilder.AppendLine("        @PRGKey,");
         vStringBuilder.AppendLine("        @FSSLock)");
         vStringBuilder.AppendLine(";");
         vStringBuilder.AppendLine("select SCOPE_IDENTITY()");
         ObjectToData(vSqlCommand, aFanSession);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         aFanSession.FssKey = Convert.ToInt32(vSqlCommand.ExecuteScalar());
         vSqlCommand.Connection.Close();
     }
 }
Exemplo n.º 19
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();
     }
 }
Exemplo n.º 20
0
 /// <summary>
 ///   The overloaded Load method that will return a specific <see cref="FanSession"/>, with keys in the <c>aFanSession</c> argument.
 /// </summary>
 /// <param name="aFanSession">A <see cref="FanSession"/>.</param>
 /// <exception cref="ArgumentNullException">If <c>aFanSession</c> argument is <c>null</c>.</exception>
 /// <exception cref="Exception">If no record is found.</exception>
 public static void Load(FanSession aFanSession)
 {
     if (aFanSession == null)
     {
         throw new ArgumentNullException("aFanSession");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL();
         vStringBuilder.AppendLine("and t3.WRT_Key = @WRTKey");
         vStringBuilder.AppendLine("and t3.FAN_Key = @FANKey");
         vStringBuilder.AppendLine("and t4.FSS_Key = @FSSKey");
         vSqlCommand.Parameters.AddWithValue("@WRTKey", aFanSession.WrtKey);
         vSqlCommand.Parameters.AddWithValue("@FANKey", aFanSession.FanKey);
         vSqlCommand.Parameters.AddWithValue("@FSSKey", aFanSession.FssKey);
         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}, FSS_Key = {2}", aFanSession.WrtKey, aFanSession.FanKey, aFanSession.FssKey));
             }
             vSqlDataReader.Read();
             DataToObject(aFanSession, vSqlDataReader, true);
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Exemplo n.º 21
0
 /// <summary>
 ///   Loads the <see cref="SqlCommand"/> parameters with values from an <see cref="FanSession"/>.
 /// </summary>
 /// <param name="aSqlCommand">A <see cref="SqlDataReader"/> argument.</param>
 /// <param name="aWorkout">A <see cref="FanSession"/> argument.</param>
 public static void ObjectToData(SqlCommand aSqlCommand, FanSession aFanSession)
 {
     aSqlCommand.Parameters.AddWithValue("@WRTKey", aFanSession.WrtKey);
     aSqlCommand.Parameters.AddWithValue("@FANKey", aFanSession.FanKey);
     aSqlCommand.Parameters.AddWithValue("@CELKey", aFanSession.CelKey);
     aSqlCommand.Parameters.AddWithValue("@FSSLock", aFanSession.FssLock);
     aSqlCommand.Parameters.AddWithValue("@PRGKey", aFanSession.PrgKey);
     aSqlCommand.Parameters.AddWithValue("@FSSDateDone", DateTime.Parse(aFanSession.FanSessionDateDone));
 }
Exemplo n.º 22
0
 /// <summary>
 ///   The <c>EditFanSession</c> implementation method deserializes an incoming XML Argument <see cref="string"/> as a new <see cref="FanSession"/> object.
 ///   It invokes the <c>Update</c> method of <see cref="FanSessionBusiness"/> with the newly deserialized <see cref="FanSession"/> object.
 ///   Finally, it returns the updated object unchanged as a serialized <see cref="string"/> of XML.
 /// </summary>
 /// <param name="aXmlArgument">XML Argument <see cref="string"/>.</param>
 /// <returns><see cref="FanSession"/> as XML <see cref="string"/>.</returns>
 /// <exception cref="ArgumentNullException">If <c>aXmlArgument</c> is <c>null</c>.</exception>
 public static string EditFanSession(FanKey aFanKey, string aXmlArgument)
 {
     if (aXmlArgument == null)
     {
         throw new ArgumentNullException("aXmlArgument of EditFanSession");
     }
     FanSession vFanSession = new FanSession();
     vFanSession = XmlUtils.Deserialize<FanSession>(aXmlArgument);
     FanSessionBusiness.Update(aFanKey, vFanSession);
     return XmlUtils.Serialize<FanSession>(vFanSession, true);
 }
Exemplo n.º 23
0
 /// <summary>
 /// Call the WebService with a request to Delete a FanSession
 /// </summary>
 /// <param name="aFanSession">The FanSession object to Delete</param>
 /// <param name="aFantoken">A fantoken.</param>
 public static void DeleteFanSession(FanToken aFantoken, FanSession aFanSession)
 {
     FanCallHandler.ServiceCall <FanSession>(aFantoken, "DeleteFanSession", aFanSession);
 }
Exemplo n.º 24
0
 /// <summary>
 ///   Gets a specified <see cref="FanSession"/> by key.
 /// </summary>
 /// <param name="aFanToken">A <see cref="FanToken"/> object used for Access Control.</param>
 /// <param name="aFanSession"><see cref="FanSession"/> object.</param>
 public static void GetFanSession(FanToken aFanToken, FanSession aFanSession)
 {
     FanCallHandler.ServiceCall <FanSession>(aFanToken, "GetFanSession", aFanSession);
 }
Exemplo n.º 25
0
 /// <summary>
 /// Call the WebService with a request to Add a FanSession
 /// </summary>
 /// <param name="aFanSession">The FanSession object to Add</param>
 /// <param name="aFantoken">A fantoken.</param>
 public static void AddFanSession(FanToken aFantoken, FanSession aFanSession)
 {
     FanCallHandler.ServiceCall<FanSession>(aFantoken, "AddFanSession", aFanSession);
 }
Exemplo n.º 26
0
 /// <summary>
 ///   Update a <see cref="FanSession"/> passed as an argument .
 /// </summary>
 /// <param name="aFanSession">A <see cref="FanSession"/>.</param>
 public static void Update(FanSession aFanSession)
 {
     if (aFanSession == null)
     {
         throw new ArgumentNullException("aFanSession");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("update FSS_FanSession");
         vStringBuilder.AppendLine("set    CEL_Key = @CELKey,");
         vStringBuilder.AppendLine("       PRG_KEY = @PRGKEY,");
         vStringBuilder.AppendLine("       FSS_Lock = @FSSLock,");
         vStringBuilder.AppendLine("       FSS_DateDone = @FSSDateDone");
         vStringBuilder.AppendLine("where  WRT_Key = @WRTKey");
         vStringBuilder.AppendLine("and    FAN_Key = @FANKey");
         vStringBuilder.AppendLine("and    FSS_Key = @FSSKey");
         ObjectToData(vSqlCommand, aFanSession);
         vSqlCommand.Parameters.AddWithValue("@FSSKey", aFanSession.FssKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }