Exemple #1
0
        public static TransactionStatus fanRegister(Fan aFan)
        {
            ServerSession.ClearSessionBusiness(HttpContext.Current.Session);
            TransactionStatus vTransactionStatus = ServerSession.GetTransactionStatus(HttpContext.Current.Session);
            try
            {
                FanToken aFanToken = new FanToken();
                aFanToken.FanID = "Register";
                aFanToken.Password = "******";
                aFanToken.Url = "http://localhost/zfitsoap/zfitService.asmx";
                aFan.FanName = "new";
                aFan.FanSurname = "fanatic";
                FanServiceConsumer.AddFan(aFanToken, aFan);
                vTransactionStatus.TransactionResult = TransactionResult.OK;
                vTransactionStatus.Message = "You have been succesfully registered!";
                vTransactionStatus.TargetUrl = "/fandashboard.aspx";
                ServerSession.SetTransactionStatus(HttpContext.Current.Session, vTransactionStatus);
            }
            catch (TransactionStatusException tx)
            {
                vTransactionStatus.AssignFromSource(tx.TransactionStatus);
                return vTransactionStatus;
            }
            catch (Exception ex)
            {
                vTransactionStatus.TransactionResult = TransactionResult.GeneralException;
                vTransactionStatus.Message = ex.Message;
                vTransactionStatus.InnerMessage = ex.InnerException == null ? String.Empty : ex.InnerException.Message;
                return vTransactionStatus;
            }

            return vTransactionStatus;
        }
Exemple #2
0
        public static webObject editFan(Fan aFan)
        {
            FanToken vFanToken = ServerSession.GetFanToken(HttpContext.Current.Session);
            FanKey vFanKey = ServerSession.GetObject<FanKey>(HttpContext.Current.Session);
            aFan.FannKey = vFanKey.FannKey;

            ServerSession.ClearSessionBusiness(HttpContext.Current.Session);
            ServerSession.PutObject<FanKey>(HttpContext.Current.Session, vFanKey); // Review this element of pattern
            webObject vWebObject = new webObject();
            vWebObject.aTransactionStatus = ServerSession.GetTransactionStatus(HttpContext.Current.Session);
            try
            {
                FanServiceConsumer.EditFan(vFanToken, aFan);
                vWebObject.aTransactionStatus.TransactionResult = TransactionResult.OK;
                vWebObject.aTransactionStatus.Message = "Fan Edited";
                ServerSession.SetTransactionStatus(HttpContext.Current.Session, vWebObject.aTransactionStatus);
                vWebObject.AnObject = aFan;
            }
            catch (TransactionStatusException tx)
            {

                vWebObject.aTransactionStatus.AssignFromSource(tx.TransactionStatus);
                return vWebObject;
            }
            catch (Exception ex)
            {
                vWebObject.aTransactionStatus.TransactionResult = TransactionResult.GeneralException;
                vWebObject.aTransactionStatus.Message = "Edit of Fan unsuccesful" + ex.Message;
                vWebObject.aTransactionStatus.InnerMessage = ex.InnerException == null ? String.Empty : ex.InnerException.Message;
                return vWebObject;
            }
            return vWebObject;
        }
Exemple #3
0
        public static TransactionStatus fanLogon(Fan aFan)
        {
            ServerSession.ClearSessionBusiness(HttpContext.Current.Session);
            TransactionStatus vTransactionStatus = ServerSession.GetTransactionStatus(HttpContext.Current.Session);
            try
            {
                ServerSession.Logon(HttpContext.Current.Session, aFan);
                vTransactionStatus.TransactionResult = TransactionResult.OK;
                vTransactionStatus.Message = "Login succesful";
                vTransactionStatus.TargetUrl = "/fandashboard.aspx";
                ServerSession.SetTransactionStatus(HttpContext.Current.Session, vTransactionStatus);
            }
            catch (TransactionStatusException tx)
            {

                vTransactionStatus.AssignFromSource(tx.TransactionStatus);
                return vTransactionStatus;
            }
            catch (Exception ex)
            {
                vTransactionStatus.TransactionResult = TransactionResult.GeneralException;
                vTransactionStatus.Message = "Login Unsuccesful - please check your username and password are correct" + ex.Message;
                vTransactionStatus.InnerMessage = ex.InnerException == null ? String.Empty : ex.InnerException.Message;
                return vTransactionStatus;
            }

            return vTransactionStatus;
        }
Exemple #4
0
 /// <summary>
 ///   Insert a <see cref="Fan"/> passed as an argument via Stored Procedure that returns the newly inserted Fan Key 
 /// </summary>
 /// <param name="aFan">A <see cref="Fan"/>.</param>
 /// <exception cref="ArgumentNullException">If <c>aFan</c> argument is <c>null</c>.</exception>
 public static void Insert(Fan aFan)
 {
     if (aFan == null)
     {
         throw new ArgumentNullException("aFan");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("insert into FAN_Fanatic");
         vStringBuilder.AppendLine("       (FAN_UserID, FAN_Password, FAN_Name, FAN_Surname, FAN_Email,");
         vStringBuilder.AppendLine("        FAN_Avatar)");
         vStringBuilder.AppendLine("values");
         vStringBuilder.AppendLine("       (@FANID, @FANPassword, @FANName, @FANSurname, @FANEmail,");
         vStringBuilder.AppendLine("        @FANAvatar)");
         vStringBuilder.AppendLine(";");
         vStringBuilder.AppendLine("select SCOPE_IDENTITY()");
         ObjectToData(vSqlCommand, aFan);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         aFan.FannKey = Convert.ToInt32(vSqlCommand.ExecuteScalar());
         vSqlCommand.Connection.Close();
     }
 }
 /// <summary>
 ///   The <c>AddFan</c> implementation method deserializes an incoming XML Argument <see cref="string"/> as a new <see cref="Fan"/> object.
 ///   It invokes the <c>Insert</c> method of <see cref="FanBusiness"/> with the newly deserialized <see cref="Fan"/> object.
 ///   Finally, it returns the inserted object (now with an assigned Fan Key) as a serialized <see cref="string"/> of XML.
 /// </summary>
 /// <param name="aXmlArgument">XML Argument <see cref="string"/>.</param>
 /// <returns><see cref="Fan"/> as XML <see cref="string"/>.</returns>
 /// <exception cref="ArgumentNullException">If <c>aXmlArgument</c> is <c>null</c>.</exception>
 public static string AddFan(FanKey aFanKey, string aXmlArgument)
 {
     if (aXmlArgument == null)
     {
         throw new ArgumentNullException("aXmlArgument of AddFan");
     }
     Fan vFan = new Fan();
     vFan = XmlUtils.Deserialize<Fan>(aXmlArgument);
     FanBusiness.Insert(aFanKey, vFan);
     return XmlUtils.Serialize<Fan>(vFan, true);
 }
Exemple #6
0
 /// <summary>
 ///   Load a <see cref="SqlDataReader"/> into a <see cref="Fan"/> object.
 /// </summary>
 /// <param name="aFan">A <see cref="Fan"/> argument.</param>
 /// <param name="aSqlDataReader">A <see cref="SqlDataReader"/> argument.</param>
 public static void DataToObject(Fan aFan, SqlDataReader aSqlDataReader, bool aIncludeAvatar)
 {
     aFan.FannKey     = Convert.ToInt32(aSqlDataReader["FAN_Key"]);
     aFan.FanUserID   = Convert.ToString(aSqlDataReader["FAN_UserID"]);
     aFan.FanPassword = Convert.ToString(aSqlDataReader["FAN_Password"]);
     aFan.FanName     = Convert.ToString(aSqlDataReader["FAN_Name"]);
     aFan.FanSurname  = Convert.ToString(aSqlDataReader["FAN_Surname"]);
     aFan.FanEmail    = Convert.ToString(aSqlDataReader["FAN_Email"]);
     if (aIncludeAvatar)
     {
         aFan.FanAvatar = CommonUtils.DbValueTo <byte[]>(aSqlDataReader["FAN_Avatar"], null);
     }
 }
Exemple #7
0
 /// <summary>
 ///   Load a <see cref="SqlDataReader"/> into a <see cref="Fan"/> object.
 /// </summary>
 /// <param name="aFan">A <see cref="Fan"/> argument.</param>
 /// <param name="aSqlDataReader">A <see cref="SqlDataReader"/> argument.</param>
 public static void DataToObject(Fan aFan, SqlDataReader aSqlDataReader, bool aIncludeAvatar)
 {
     aFan.FannKey = Convert.ToInt32(aSqlDataReader["FAN_Key"]);
     aFan.FanUserID = Convert.ToString(aSqlDataReader["FAN_UserID"]);
     aFan.FanPassword = Convert.ToString(aSqlDataReader["FAN_Password"]);
     aFan.FanName = Convert.ToString(aSqlDataReader["FAN_Name"]);
     aFan.FanSurname = Convert.ToString(aSqlDataReader["FAN_Surname"]);
     aFan.FanEmail = Convert.ToString(aSqlDataReader["FAN_Email"]);
     if (aIncludeAvatar)
     {
         aFan.FanAvatar = CommonUtils.DbValueTo<byte[]>(aSqlDataReader["FAN_Avatar"], null);
     }
 }
Exemple #8
0
        /// <summary>
        ///   Insert a <see cref="Fan"/> object passed as an argument via Stored Procedure that returns the newly inserted <i>Fan Key</i>.
        /// </summary>
        /// <param name="aFanKey">A <see cref="FanKey"/> object.</param>
        /// <param name="aFan">A <see cref="Fan"/> object.</param>
        /// <exception cref="ArgumentNullException">If <c>aFan</c> argument is <c>null</c>.</exception>
        public static void Insert(FanKey aFanKey, Fan aFan)
        {
            if (aFan == null)
            {
                throw new ArgumentNullException("Insert Fan Business");
            }

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

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

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

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

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

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

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

            FanData.Load(aFan);
        }
Exemple #12
0
 /// <summary>
 ///   Loads the <see cref="SqlCommand"/> parameters with values from an <see cref="Fan"/>.
 /// </summary>
 /// <param name="aSqlCommand">A <see cref="SqlDataReader"/> argument.</param>
 /// <param name="aFan">A <see cref="Fan"/> argument.</param>
 public static void ObjectToData(SqlCommand aSqlCommand, Fan aFan)
 {
     aSqlCommand.Parameters.AddWithValue("@FANID", aFan.FanUserID);
     aSqlCommand.Parameters.AddWithValue("@FANPassword", aFan.FanPassword);
     aSqlCommand.Parameters.AddWithValue("@FANName", aFan.FanName);
     aSqlCommand.Parameters.AddWithValue("@FANSurname", aFan.FanSurname);
     aSqlCommand.Parameters.AddWithValue("@FANEmail", aFan.FanEmail);
     if (aFan.FanAvatar == null)
     {
         aSqlCommand.Parameters.Add("@FANAvatar", SqlDbType.Image).Value = DBNull.Value;
     }
     else
     {
         aSqlCommand.Parameters.AddWithValue("@FANAvatar", aFan.FanAvatar);
     }
 }
Exemple #13
0
        /// <summary>
        ///    Assigns all <c>aSource</c> object's values to this instance of <see cref="FanCollection"/>.
        /// </summary>
        /// <param name="aSource">A source object.</param>
        public override void AssignFromSource(object aSource)
        {
            if (!(aSource is FanCollection))
            {
                throw new ArgumentException("Invalid assignment source", "FanCollection");
            }

            _isFiltered = (aSource as FanCollection)._isFiltered;

            _fanList.Clear();
            foreach (Fan vFanSource in (aSource as FanCollection)._fanList)
            {
                Fan vFanTarget = new Fan();
                vFanTarget.AssignFromSource(vFanSource);
                _fanList.Add(vFanTarget);
            }
        }
Exemple #14
0
        /// <summary>
        ///    Assigns all <c>aSource</c> object's values to this instance of <see cref="FanCollection"/>.
        /// </summary>
        /// <param name="aSource">A source object.</param>
        public override void AssignFromSource(object aSource)
        {
            if (!(aSource is FanCollection))
            {
                throw new ArgumentException("Invalid assignment source", "FanCollection");
            }

            _isFiltered = (aSource as FanCollection)._isFiltered;

            _fanList.Clear();
            foreach (Fan vFanSource in (aSource as FanCollection)._fanList)
            {
                Fan vFanTarget = new Fan();
                vFanTarget.AssignFromSource(vFanSource);
                _fanList.Add(vFanTarget);
            }
        }
Exemple #15
0
        /// <summary>
        ///   The overloaded Load method that will return a <see cref="Fan"/> object specified by a FanID.
        /// </summary>
        /// <param name="aFanKey">A <see cref="FanKey"/> object.</param>
        /// <param name="aFan">A <see cref="Fan"/> object.</param>
        /// <param name="aFanID">A FanID <see cref="string"/>.</param>
        /// <exception cref="ArgumentNullException">If <c>aFan</c> argument is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException">If <c>aFanID</c> argument is <c>null</c>, empty or whitespace.</exception>
        public static void LoadByID(FanKey aFanKey, Fan aFan)
        {
            if (aFan == null)
            {
                throw new ArgumentNullException("LoadByID Fan Business");
            }
            if (String.IsNullOrWhiteSpace(aFan.FanUserID))
            {
                throw new ArgumentNullException("Empty ID in LoadByID Fan Business");
            }

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

            FanData.LoadById(aFan);
        }
Exemple #16
0
        //The following body of code is commented out as this is a public system. Once Admin interface is built
        //we will return to a regular broadcast.

        /// <summary>
        /// Initializes the session with the Session token file located
        /// </summary>
        /// <returns></returns>
        //private static UserKey InitializeSession(UserToken aUserToken)
        //{
        //    var vUserKey = new UserKey();

        //    //The following body of code is commented out as this is a public system. Once PublicInterface is built
        //    //we will return to a regular broadcast.

        //    var vUser = new User() { UsrID = aUserToken.UserID };
        //    UserBusiness.LoadByID(vUserKey, vUser);
        //    if (String.Compare(vUser.UsrPassword, aUserToken.Password, false) != 0)
        //    {
        //        throw new Exception("User Authentication Exception");
        //    }
        //    vUserKey.UsrKey = vUser.UsrKey;

        //    return vUserKey;
        //}

        // ***********************

        // Overload for InitializeSession to accommodate FanKey as opposed to UserKey...
        /// <summary>
        /// Initializes the session with the Session token file located
        /// </summary>
        /// <returns></returns>
        private static FanKey InitializeSession(FanToken aFanToken)
        {
            var vFanKey = new FanKey();

            var vFan = new Fan()
            {
                FanID = aFanToken.FanID
            };

            FanBusiness.LoadByID(vFanKey, vFan);
            if (String.Compare(vFan.FanPassword, aFanToken.Password, false) != 0)
            {
                throw new Exception("User Authentication Exception");
            }
            vFanKey.FannKey = vFan.FannKey;

            return(vFanKey);
        }
Exemple #17
0
 /// <summary>
 ///   Delete a <see cref="Fan"/> object passed as an argument.
 /// </summary>
 /// <param name="aFan">The <see cref="Fan"/> object to be deleted.</param>
 /// <exception cref="ArgumentNullException">If <c>aFan</c> argument is <c>null</c>.</exception>
 public static void Delete(Fan aFan)
 {
     if (aFan == null)
     {
         throw new ArgumentNullException("aFan");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("delete FAN_Fanatic");
         vStringBuilder.AppendLine("where  FAN_Key = @FANKey");
         vSqlCommand.Parameters.AddWithValue("@FANKey", aFan.FannKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Exemple #18
0
 /// <summary>
 ///   Delete a <see cref="Fan"/> object passed as an argument.
 /// </summary>
 /// <param name="aFan">The <see cref="Fan"/> object to be deleted.</param>
 /// <exception cref="ArgumentNullException">If <c>aFan</c> argument is <c>null</c>.</exception>
 public static void Delete(Fan aFan)
 {
     if (aFan == null)
     {
         throw new ArgumentNullException("aFan");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("delete FAN_Fanatic");
         vStringBuilder.AppendLine("where  FAN_Key = @FANKey");
         vSqlCommand.Parameters.AddWithValue("@FANKey", aFan.FannKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Exemple #19
0
        public static webObject loadFan(Fan aFan)
        {
            FanToken vFanToken = ServerSession.GetFanToken(HttpContext.Current.Session);
            FanKey   vFanKey   = ServerSession.GetObject <FanKey>(HttpContext.Current.Session);

            aFan.FannKey     = vFanKey.FannKey;
            aFan.FanUserID   = vFanToken.FanID;
            aFan.FanPassword = vFanToken.Password;

            ServerSession.ClearSessionBusiness(HttpContext.Current.Session);
            ServerSession.PutObject <FanKey>(HttpContext.Current.Session, vFanKey); // Review this element of pattern
            webObject vWebObject = new webObject();

            vWebObject.aTransactionStatus = ServerSession.GetTransactionStatus(HttpContext.Current.Session);
            try
            {
                FanServiceConsumer.GetFan(vFanToken, aFan);
                vWebObject.aTransactionStatus.TransactionResult = TransactionResult.OK;
                vWebObject.aTransactionStatus.Message           = "Fan Loaded";
                ServerSession.SetTransactionStatus(HttpContext.Current.Session, vWebObject.aTransactionStatus);
                vWebObject.AnObject = aFan;
            }
            catch (TransactionStatusException tx)
            {
                vWebObject.aTransactionStatus.AssignFromSource(tx.TransactionStatus);
                return(vWebObject);
            }
            catch (Exception ex)
            {
                vWebObject.aTransactionStatus.TransactionResult = TransactionResult.GeneralException;
                vWebObject.aTransactionStatus.Message           = "Load of Fan unsuccesful" + ex.Message;
                vWebObject.aTransactionStatus.InnerMessage      = ex.InnerException == null ? String.Empty : ex.InnerException.Message;
                return(vWebObject);
            }
            return(vWebObject);
        }
Exemple #20
0
 /// <summary>
 ///   Update a <see cref="Fan"/> passed as an argument .
 /// </summary>
 /// <param name="aFan">A <see cref="Fan"/>.</param>
 public static void Update(Fan aFan)
 {
     if (aFan == null)
     {
         throw new ArgumentNullException("aFan");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = new StringBuilder();
         vStringBuilder.AppendLine("update FAN_Fanatic");
         vStringBuilder.AppendLine("set    FAN_UserID = @FANID,");
         vStringBuilder.AppendLine("       FAN_Password = @FANPassword,");
         vStringBuilder.AppendLine("       FAN_Name = @FANName,");
         vStringBuilder.AppendLine("       FAN_Surname = @FANSurname,");
         vStringBuilder.AppendLine("       FAN_Email = @FANEmail,");
         vStringBuilder.AppendLine("       FAN_Avatar = @FANAvatar");
         vStringBuilder.AppendLine("where  FAN_Key = @FANKey");
         ObjectToData(vSqlCommand, aFan);
         vSqlCommand.Parameters.AddWithValue("@FANKey", aFan.FannKey);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         vSqlCommand.ExecuteNonQuery();
         vSqlCommand.Connection.Close();
     }
 }
Exemple #21
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Fan vFan = new Fan();
     vFan.FanUserID = "*****@*****.**";
     vFan.FanPassword = "******";
     ServerSession.Logon(HttpContext.Current.Session, vFan);
     FanKey vFanKey = new FanKey();
     vFanKey.FannKey = vFan.FannKey;
     ServerSession.PutObject<FanKey>(HttpContext.Current.Session, vFanKey);
 }
Exemple #22
0
 /// <summary>
 ///   Gets the <see cref="Fan"/> by FanID.
 /// </summary>
 /// <param name="aXmlArgument">XML Argument <see cref="string"/>.</param>
 /// <returns>Fan as XML <see cref="string"/>.</returns>
 /// <exception cref="ArgumentNullException">If <c>aXmlArgument</c> is <c>null</c>.</exception>
 public static string GetFanByID(FanKey aFanKey, string aXmlArgument)
 {
     if (aXmlArgument == null)
     {
         throw new ArgumentNullException("aXmlArgument of GetFanByID");
     }
     Fan vFan = new Fan();
     vFan = XmlUtils.Deserialize<Fan>(aXmlArgument);
     FanBusiness.LoadByID(vFan, vFan);
     return XmlUtils.Serialize<Fan>(vFan, true);
 }
        /// <summary>
        ///   Get a specified <see cref="RoleFunctionEditor"/>.
        /// </summary>
        /// <param name="aRoleFunctionEditor">A <see cref="RoleFunctionEditor"/> object.</param>
        /// <param name="aFanToken">A fantoken.</param>
        //public static void GetRoleFunctionEditor(FanToken aFanToken, RoleFunctionEditor aRoleFunctionEditor)
        //{
        //    FanCallHandler.ServiceCall<RoleFunctionEditor>(aFanToken, "GetRoleFunctionEditor", aRoleFunctionEditor);
        //}

        /// <summary>
        ///   Put a specified <see cref="RoleFunctionEditor"/>.
        /// </summary>
        /// <param name="aRoleFunctionEditor">A <see cref="RoleFunctionEditor"/> object.</param>
        /// <param name="aFanToken">A fantoken.</param>
        //public static void PutRoleFunctionEditor(FanToken aFanToken, RoleFunctionEditor aRoleFunctionEditor)
        //{
        //    FanCallHandler.ServiceCall<RoleFunctionEditor>(aFanToken, "PutRoleFunctionEditor", aRoleFunctionEditor);
        //}

        #endregion

        #region Fan Service Calls

        /// <summary>
        /// Call the WebService with a request to return a Fan with a specified FanID
        /// </summary>
        /// <param name="aFan">The Fan object to return</param>
        /// <param name="aFanToken">A fantoken.</param>
        public static void GetFanByID(FanToken aFanToken, Fan aFan)
        {
            FanCallHandler.ServiceCall <Fan>(aFanToken, "GetFanByID", aFan);
        }
 /// <summary>
 /// Call the WebService with a request to Delete a Fan
 /// </summary>
 /// <param name="aFan">The Fan object to Delete</param>
 /// <param name="aFanToken">A fantoken.</param>
 public static void DeleteFan(FanToken aFanToken, Fan aFan)
 {
     FanCallHandler.ServiceCall <Fan>(aFanToken, "DeleteFan", aFan);
 }
 /// <summary>
 /// Call the WebService with a request to Edit a Fan
 /// </summary>
 /// <param name="aFan">The Fan object to Edit</param>
 /// <param name="aFanToken">A fantoken.</param>
 public static void EditFan(FanToken aFanToken, Fan aFan)
 {
     FanCallHandler.ServiceCall <Fan>(aFanToken, "EditFan", aFan);
 }
Exemple #26
0
 /// <summary>
 ///   The overloaded Load method that will fill the <c>FanList</c> property a <see cref="FanCollection"/> object as an
 ///   ordered <c>List</c> of <see cref="Fan"/>, filtered by the filter properties of the passed <see cref="FanCollection"/>.
 /// </summary>
 /// <param name="aFanCollection">The <see cref="FanCollection"/> object that must be filled.</param>
 /// <remarks>
 ///   The filter properties of the <see cref="FanCollection"/> must be correctly completed by the calling application.
 /// </remarks>
 /// <exception cref="ArgumentNullException">If <c>aFanCollection</c> argument is <c>null</c>.</exception>
 public static void Load(FanCollection aFanCollection)
 {
     if (aFanCollection == null)
     {
         throw new ArgumentNullException("aFanCollection");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL(false);
         //if (aFanCollection.IsFiltered)
         //{
         //    vStringBuilder.AppendLine("where t1.FAN_WebContact = 'Y'");
         //}
         vStringBuilder.AppendLine("order by t1.FAN_UserID");
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             while (vSqlDataReader.Read())
             {
                 var vFan = new Fan();
                 DataToObject(vFan, vSqlDataReader, false);
                 aFanCollection.FanList.Add(vFan);
             }
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Exemple #27
0
        //The following body of code is commented out as this is a public system. Once Admin interface is built
        //we will return to a regular broadcast.
        /// <summary>
        /// Initializes the session with the Session token file located 
        /// </summary>
        /// <returns></returns>
        //private static UserKey InitializeSession(UserToken aUserToken)
        //{
        //    var vUserKey = new UserKey();
        //    //The following body of code is commented out as this is a public system. Once PublicInterface is built
        //    //we will return to a regular broadcast.
        //    var vUser = new User() { UsrID = aUserToken.UserID };
        //    UserBusiness.LoadByID(vUserKey, vUser);
        //    if (String.Compare(vUser.UsrPassword, aUserToken.Password, false) != 0)
        //    {
        //        throw new Exception("User Authentication Exception");
        //    }
        //    vUserKey.UsrKey = vUser.UsrKey;
        //    return vUserKey;
        //}
        // ***********************
        // Overload for InitializeSession to accommodate FanKey as opposed to UserKey...
        /// <summary>
        /// Initializes the session with the Session token file located 
        /// </summary>
        /// <returns></returns>
        private static FanKey InitializeSession(FanToken aFanToken)
        {
            var vFanKey = new FanKey();

            var vFan = new Fan() { FanID = aFanToken.FanID };
            FanBusiness.LoadByID(vFanKey, vFan);
            if (String.Compare(vFan.FanPassword, aFanToken.Password, false) != 0)
            {
                throw new Exception("User Authentication Exception");
            }
            vFanKey.FannKey = vFan.FannKey;

            return vFanKey;
        }
Exemple #28
0
 /// <summary>
 /// Loads the Fan by the FanID of the argument Fan.
 /// </summary>
 /// <param name="aFan">A user.</param>
 public static void LoadById(Fan aFan)
 {
     if (aFan == null)
     {
         throw new ArgumentNullException("aFan");
     }
     using (var vSqlCommand = new SqlCommand()
     {
         CommandType = CommandType.Text,
         Connection = new SqlConnection(Connection.Instance.SqlConnectionString)
     })
     {
         var vStringBuilder = BuildSQL(true);
         vStringBuilder.AppendLine("where FAN_UserID = @FANID");
         vSqlCommand.Parameters.AddWithValue("@FANID", aFan.FanUserID);
         vSqlCommand.CommandText = vStringBuilder.ToString();
         vSqlCommand.Connection.Open();
         using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader())
         {
             if (!(vSqlDataReader.HasRows))
             {
                 throw new Exception(String.Format("Expected Fan not found: FAN_ID = {0}", aFan.FanUserID));
             }
             vSqlDataReader.Read();
             DataToObject(aFan, vSqlDataReader, true);
             vSqlDataReader.Close();
         }
         vSqlCommand.Connection.Close();
     }
 }
Exemple #29
0
 /// <summary>
 ///   Loads the <see cref="SqlCommand"/> parameters with values from an <see cref="Fan"/>.
 /// </summary>
 /// <param name="aSqlCommand">A <see cref="SqlDataReader"/> argument.</param>
 /// <param name="aFan">A <see cref="Fan"/> argument.</param>
 public static void ObjectToData(SqlCommand aSqlCommand, Fan aFan)
 {
     aSqlCommand.Parameters.AddWithValue("@FANID", aFan.FanUserID);
     aSqlCommand.Parameters.AddWithValue("@FANPassword", aFan.FanPassword);
     aSqlCommand.Parameters.AddWithValue("@FANName", aFan.FanName);
     aSqlCommand.Parameters.AddWithValue("@FANSurname", aFan.FanSurname);
     aSqlCommand.Parameters.AddWithValue("@FANEmail", aFan.FanEmail);
     if (aFan.FanAvatar == null)
     {
         aSqlCommand.Parameters.Add("@FANAvatar", SqlDbType.Image).Value = DBNull.Value;
     }
     else
     {
         aSqlCommand.Parameters.AddWithValue("@FANAvatar", aFan.FanAvatar);
     }
 }
 /// <summary>
 /// Call the WebService with a request to Add a Fan
 /// </summary>
 /// <param name="aFan">The Fan object to Add</param>
 /// <param name="aFanToken">A fantoken.</param>
 public static void AddFan(FanToken aFanToken, Fan aFan)
 {
     FanCallHandler.ServiceCall<Fan>(aFanToken, "AddFan", aFan);
 }
Exemple #31
0
        /// <summary>
        ///   The overloaded Load method that will return a <see cref="Fan"/> object specified by a FanID.
        /// </summary>
        /// <param name="aFanKey">A <see cref="FanKey"/> object.</param>
        /// <param name="aFan">A <see cref="Fan"/> object.</param>
        /// <param name="aFanID">A FanID <see cref="string"/>.</param>
        /// <exception cref="ArgumentNullException">If <c>aFan</c> argument is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException">If <c>aFanID</c> argument is <c>null</c>, empty or whitespace.</exception>
        public static void LoadByID(FanKey aFanKey, Fan aFan)
        {
            if (aFan == null)
            {
                throw new ArgumentNullException("LoadByID Fan Business");
            }
            if (String.IsNullOrWhiteSpace(aFan.FanUserID))
            {
                throw new ArgumentNullException("Empty ID in LoadByID Fan Business");
            }

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

            FanData.LoadById(aFan);
        }
 /// <summary>
 /// Call the WebService with a request to return a Fan with a specified FanID
 /// </summary>
 /// <param name="aFan">The Fan object to return</param>
 /// <param name="aFanToken">A fantoken.</param>
 public static void GetFanByID(FanToken aFanToken, Fan aFan)
 {
     FanCallHandler.ServiceCall<Fan>(aFanToken, "GetFanByID", aFan);
 }