Esempio n. 1
0
        public DataAccessResponseType UpdatePlatformUserEmail(string userId, string newEmail, 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.UpdateEmail(userId, newEmail);

            #region Log Platoform Activity

            if (result.isSuccess)
            {
                try
                {
                    var logDescription = string.Empty;

                    if (userId == requesterId)
                    {
                        logDescription = requesterName + " has updated their email to " + newEmail;
                    }
                    else
                    {
                        var user = PlatformUserManager.GetUser(userId);
                        logDescription = requesterName + " updated " + user.FullName + "'s email to " + newEmail;
                    }

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

            #endregion

            return(result);
        }