Пример #1
0
        /// <summary>
        /// Delete the user's profile picture from the server.
        /// </summary>
        /// <param name="userID">A string containing phone number as user id.</param>
        /// <returns>true if the profile picture is successfully deleted from the server; otherwise, false.</returns>
        public bool DeleteAvatar(string userID)
        {
            #region log user request and response

            /***********************************************
            *  To log user request and response
            ***********************************************/
            if (_logRequestResponse)
            {
                LogManager.CurrentInstance.InfoLogger.LogInfo(
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType,
                    "Request ===> userID : " + userID);
            }

            #endregion

            if (!NeeoUtility.IsNullOrEmpty(userID))
            {
                try
                {
                    NeeoUser user = new NeeoUser(userID);
                    if (user.DeleteUserAvatar(NeeoUtility.ConvertToFileName(userID)))
                    {
                        return(true);
                    }
                    else
                    {
                        NeeoUtility.SetServiceResponseHeaders(CustomHttpStatusCode.FileSystemException);
                        return(false);
                    }
                }
                catch (ApplicationException appExp)
                {
                    NeeoUtility.SetServiceResponseHeaders((CustomHttpStatusCode)(Convert.ToInt32(appExp.Message)));
                }
                catch (Exception exp)
                {
                    LogManager.CurrentInstance.ErrorLogger.LogError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, exp.Message, exp);
                    NeeoUtility.SetServiceResponseHeaders(CustomHttpStatusCode.UnknownError);
                }
                return(false);
            }
            else
            {
                NeeoUtility.SetServiceResponseHeaders(CustomHttpStatusCode.InvalidArguments);
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// Delete the user's profile picture from the server.
        /// </summary>
        /// <param name="uID">A string containing phone number as user id.</param>
        /// <returns>true if the profile picture is successfully deleted from the server; otherwise, false.</returns>
        public bool DeleteAvatar(string uID)
        {
            uID = (uID != null) ? uID.Trim() : uID;
            #region log user request and response

            /***********************************************
            *  To log user request and response
            ***********************************************/
            if (_logRequestResponse)
            {
                LogManager.CurrentInstance.InfoLogger.LogInfo(
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType,
                    "Request ===> userID : " + uID);
            }

            #endregion

            #region Verify User
            //var request = OperationContext.Current.IncomingMessageProperties[HttpRequestMessageProperty.Name] as HttpRequestMessageProperty;
            //string keyFromClient = request.Headers["key"];
            //if (NeeoUtility.AuthenticateUserRequest(uID, keyFromClient))
            //{
            #endregion

            if (!NeeoUtility.IsNullOrEmpty(uID))
            {
                try
                {
                    NeeoUser user = new NeeoUser(uID);
                    if (user.DeleteUserAvatar())
                    {
                        return(true);
                    }
                    else
                    {
                        NeeoUtility.SetServiceResponseHeaders(CustomHttpStatusCode.FileSystemException);
                        return(false);
                    }
                }
                catch (ApplicationException appExp)
                {
                    NeeoUtility.SetServiceResponseHeaders((CustomHttpStatusCode)(Convert.ToInt32(appExp.Message)));
                }
                catch (Exception exp)
                {
                    LogManager.CurrentInstance.ErrorLogger.LogError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, exp.Message, exp);
                    NeeoUtility.SetServiceResponseHeaders(CustomHttpStatusCode.UnknownError);
                }
                return(false);
            }
            else
            {
                NeeoUtility.SetServiceResponseHeaders(CustomHttpStatusCode.InvalidArguments);
                return(false);
            }
            //}
            //else
            //{
            //    NeeoUtility.SetServiceResponseHeaders((CustomHttpStatusCode)HttpStatusCode.Unauthorized);

            //    return false;
            //}
        }