public IHttpActionResult Save(UIMessageProfile profile) { if (profile == null) { throw new ArgumentNullException("profile", "uiProfile cannot be a null reference (Nothing in Visual Basic)!"); } string mRetVal = "False"; MAccountProfile mCurrentAccountProfile = AccountUtility.CurrentProfile(); Logger mLog = Logger.Instance(); MMessageProfile mProfileToSave = populateProfile(profile, mCurrentAccountProfile); if (HttpContext.Current.Items["EditId"] != null) { int mEditId = int.Parse(HttpContext.Current.Items["EditId"].ToString()); if (mEditId == profile.Id) { MSecurityInfo mSecurityInfo = new MSecurityInfo(FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_EditMessages", true)), AccountUtility.CurrentProfile()); if (mSecurityInfo != null) { if (mEditId != 1) { if (mSecurityInfo.MayEdit) { MessageUtility.Save(mProfileToSave); mLog.Debug("Saved message " + profile.Name + " by " + mCurrentAccountProfile.Account); mRetVal = "true"; } else { Exception mError = new Exception("The account (" + AccountUtility.CurrentProfile().Account + ") being used does not have the correct permissions to edit"); mLog.Error(mError); return(this.InternalServerError(mError)); } } else { if (mSecurityInfo.MayAdd) { MessageUtility.Save(mProfileToSave); mLog.Debug("Added message " + profile.Name + " by " + mCurrentAccountProfile.Account); mRetVal = "true"; } else { Exception mError = new Exception("The account (" + AccountUtility.CurrentProfile().Account + ") being used does not have the correct permissions to add"); mLog.Error(mError); return(this.InternalServerError(mError)); } } } else { Exception mError = new Exception("Security Info is not in context nothing has been saved!!!!"); 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)); }