예제 #1
0
        public IHttpActionResult Delete([FromUri] int accountSeqId)
        {
            if (accountSeqId <= 0)
            {
                throw new ArgumentNullException("accountSeqId", " must be a positive number!");
            }
            string mRetVal = "False";
            Logger mLog    = Logger.Instance();

            if (HttpContext.Current.Items["EditId"] != null)
            {
                int mEditId = int.Parse(HttpContext.Current.Items["EditId"].ToString());
                if (mEditId == accountSeqId)
                {
                    MSecurityInfo mSecurityInfo = new MSecurityInfo(FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_EditOtherAccount", true)), AccountUtility.CurrentProfile());
                    if (mSecurityInfo != null)
                    {
                        if (mSecurityInfo.MayDelete)
                        {
                            try
                            {
                                AccountUtility.Delete(accountSeqId);
                                mRetVal = "True";
                            }
                            catch (Exception ex)
                            {
                                mLog.Error(ex);
                                throw;
                            }
                        }
                        else
                        {
                            Exception mError = new Exception("The account (" + AccountUtility.CurrentProfile().Account + ") being used does not have the correct permissions to delete");
                            mLog.Error(mError);
                            return(this.InternalServerError(mError));
                        }
                    }
                    else
                    {
                        Exception mError = new Exception("Security Info can not be determined nothing has been deleted!!!!");
                        mLog.Error(mError);
                        return(this.InternalServerError(mError));
                    }
                }
                else
                {
                    Exception mError = new Exception("Identifier you have last looked at does not match the one passed in nothing has been saved!!!!");
                    mLog.Error(mError);
                    return(this.InternalServerError(mError));
                }
            }
            return(Ok(mRetVal));
        }