Пример #1
0
        public DataAccessResponseType UpdatePlatformUserFullName(string userId, string newFirstName, string newLastName, 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 user = PlatformUserManager.GetUser(userId);

            var result = PlatformUserManager.UpdateFullName(userId, newFirstName, newLastName);

            #region Log Platform Activity

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

                    if (userId == requesterId)
                    {
                        logDescription = requesterName + " has updated their name to " + newFirstName + " " + newLastName;
                    }
                    else
                    {
                        logDescription = requesterName + " updated " + user.FullName + "'s name to " + newFirstName + " " + newLastName;
                    }

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

            #endregion

            return(result);
        }