Beispiel #1
0
        public DataAccessResponseType UpdatePlatformUserActiveState(string userId, bool isActive, string requesterId, RequesterType requesterType, string sharedClientKey)
        {
            // Ensure the clients are certified.
            if (sharedClientKey != Sahara.Core.Platform.Requests.RequestManager.SharedClientKey)
            {
                return(null);
            }

            #region Validate Request

            var requesterName  = string.Empty;
            var requesterEmail = string.Empty;

            var requestResponseType = RequestManager.ValidateRequest(requesterId,
                                                                     requesterType, out requesterName, out requesterEmail,
                                                                     Sahara.Core.Settings.Platform.Users.Authorization.Roles.SuperAdmin,
                                                                     null);

            if (!requestResponseType.isApproved)
            {
                //Request is not approved, send results:
                return(new DataAccessResponseType {
                    isSuccess = false, ErrorMessage = requestResponseType.requestMessage
                });
            }

            #endregion

            var result = PlatformUserManager.UpdateActiveState(userId, isActive);

            #region Log Platform Activity

            if (result.isSuccess)
            {
                try
                {
                    var user = PlatformUserManager.GetUser(userId);

                    var description = string.Empty;

                    if (isActive)
                    {
                        description = requesterName + " activated " + user.FullName + "'s account";
                    }
                    else
                    {
                        description = requesterName + " deactivated " + user.FullName + "'s account";
                    }

                    PlatformLogManager.LogActivity(
                        CategoryType.PlatformUser,
                        ActivityType.PlatformUser_Edited,
                        "Active state updated",
                        description,
                        null,
                        null,
                        requesterId,
                        requesterName,
                        requesterEmail
                        );
                }
                catch { }
            }

            #endregion

            return(result);
        }