public static dynamic UpdateLogSetting(UpdateLogSettingsRequest request, UserInfo UserInfo)
            {
                dynamic Result = new ExpandoObject();

                try
                {
                    request.LogTypePortalID = UserInfo.IsSuperUser ? request.LogTypePortalID : UserInfo.PortalID.ToString();
                    LogTypeConfigInfo configInfo = _controller.GetLogTypeConfig(request.ID);
                    if (!UserInfo.IsSuperUser &&
                        (!int.TryParse(configInfo.LogTypePortalID, out int settingPortalId) ||
                         !int.TryParse(request.LogTypePortalID, out int requestPortalId) || requestPortalId != settingPortalId))
                    {
                        Result.Status = "Unauthorized";
                        return(Result);
                    }
                    LogTypeConfigInfo logTypeConfigInfo = JObject.FromObject(request).ToObject <LogTypeConfigInfo>();
                    _controller.UpdateLogTypeConfig(logTypeConfigInfo);
                    return(GetSingleLogSetting(UserInfo, request.ID));
                }
                catch (Exception ex)
                {
                    Result.Status = ex.Message;
                    DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                }
                return(Result);
            }
        public HttpResponseMessage UpdateLogSetting([FromBody] UpdateLogSettingsRequest request)
        {
            try
            {
                request.LogTypePortalID = this.UserInfo.IsSuperUser ? request.LogTypePortalID : this.PortalId.ToString();

                int requestPortalId;
                int settingPortalId;
                var configInfo = this._controller.GetLogTypeConfig(request.ID);
                if (!this.UserInfo.IsSuperUser &&
                    (!int.TryParse(configInfo.LogTypePortalID, out settingPortalId) ||
                     !int.TryParse(request.LogTypePortalID, out requestPortalId) || requestPortalId != settingPortalId))
                {
                    return(this.Request.CreateResponse(HttpStatusCode.Unauthorized));
                }

                var logTypeConfigInfo = JObject.FromObject(request).ToObject <LogTypeConfigInfo>();
                this._controller.UpdateLogTypeConfig(logTypeConfigInfo);
                return(this.GetLogSetting(request.ID));
            }
            catch (Exception exc)
            {
                Logger.Error(exc);
                return(this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
 public HttpResponseMessage UpdateLogSetting([FromBody] UpdateLogSettingsRequest request)
 {
     try
     {
         var logTypeConfigInfo = JObject.FromObject(request).ToObject <LogTypeConfigInfo>();
         _controller.UpdateLogTypeConfig(logTypeConfigInfo);
         return(GetLogSetting(request.ID));
     }
     catch (Exception exc)
     {
         Logger.Error(exc);
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
     }
 }
Example #4
0
        public HttpResponseMessage AddLogSetting([FromBody] UpdateLogSettingsRequest request)
        {
            try
            {
                request.LogTypePortalID = UserInfo.IsSuperUser ? request.LogTypePortalID : PortalId.ToString();

                var logTypeConfigInfo = JObject.FromObject(request).ToObject <LogTypeConfigInfo>();
                _controller.AddLogTypeConfig(logTypeConfigInfo);
                return(GetLatestLogSetting());
            }
            catch (Exception exc)
            {
                Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
Example #5
0
        public HttpResponseMessage AddLogSetting([FromBody] UpdateLogSettingsRequest request)
        {
            try
            {
                if (!this.UserInfo.IsSuperUser)
                {
                    return(this.Request.CreateResponse(HttpStatusCode.Unauthorized));
                }

                var logTypeConfigInfo = JObject.FromObject(request).ToObject <LogTypeConfigInfo>();
                this._controller.AddLogTypeConfig(logTypeConfigInfo);
                return(this.GetLatestLogSetting());
            }
            catch (Exception exc)
            {
                Logger.Error(exc);
                return(this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
        public HttpResponseMessage AddLogSetting([FromBody] UpdateLogSettingsRequest request)
        {
            try
            {
                var isAdmin = this.UserInfo.Roles.Contains(this.PortalSettings.AdministratorRoleName);
                if (isAdmin)
                {
                    return(this.Request.CreateResponse(HttpStatusCode.Unauthorized));
                }
                request.LogTypePortalID = this.UserInfo.IsSuperUser ? request.LogTypePortalID : this.PortalId.ToString();

                var logTypeConfigInfo = JObject.FromObject(request).ToObject <LogTypeConfigInfo>();
                this._controller.AddLogTypeConfig(logTypeConfigInfo);
                return(this.GetLatestLogSetting());
            }
            catch (Exception exc)
            {
                Logger.Error(exc);
                return(this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
 public dynamic AddLogSetting([FromBody] UpdateLogSettingsRequest request)
 {
     return(Managers.LogsManager.AddLogSetting(PortalSettings, UserInfo, request));
 }
 public dynamic UpdateLogSetting([FromBody] UpdateLogSettingsRequest request)
 {
     return(Managers.LogsManager.UpdateLogSetting(request, UserInfo));
 }
            public static dynamic AddLogSetting(PortalSettings PortalSettings, UserInfo UserInfo, UpdateLogSettingsRequest request)
            {
                dynamic Result = new ExpandoObject();

                try
                {
                    bool isAdmin = UserInfo.Roles.Contains(PortalSettings.AdministratorRoleName);
                    if (isAdmin)
                    {
                        Result.Status = "Unauthorized";
                        return(Result);
                    }
                    request.LogTypePortalID = UserInfo.IsSuperUser ? request.LogTypePortalID : PortalSettings.PortalId.ToString();
                    LogTypeConfigInfo logTypeConfigInfo = JObject.FromObject(request).ToObject <LogTypeConfigInfo>();
                    _controller.AddLogTypeConfig(logTypeConfigInfo);
                    Result.Status = "Success";
                }
                catch (Exception ex)
                {
                    Result.Status = ex.Message;
                    DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                }
                return(Result);
            }