public async Task MergeUsers()

in src/YouTrackSharp/Management/UserManagementService.cs [183:219]


        public async Task MergeUsers(string usernameToMerge, string targetUser, bool promoteBan = true)
        {
            var source = await GetUser(usernameToMerge);
            var target = await GetUser(targetUser);

            if (source == null)
            {
                throw new YouTrackErrorException(Strings.Exception_BadRequest, (int)HttpStatusCode.BadRequest,
                    "Could not find user with login " + usernameToMerge,
                    null, null);
            }
            
            if (target == null)
            {
                throw new YouTrackErrorException(Strings.Exception_BadRequest, (int)HttpStatusCode.BadRequest,
                    "Could not find target user with login " + targetUser,
                    null, null);
            }

            var users = new List<HubApiUser>()
            {
                new HubApiUser() {Id = source.RingId},
                new HubApiUser() {Id = target.RingId}
            };
            var client = await _connection.GetAuthenticatedApiClient();
            
            if (target.Banned || !(promoteBan && source.Banned))
            {
                await client.HubUsersMergePostAsync("id", targetUser, target.FullName, target.Email, target.Banned,
                    target.BanBadge, target.BanReason, target.RingId, users);
            }
            else
            {
                await client.HubUsersMergePostAsync("id", targetUser, target.FullName, target.Email, source.Banned,
                    source.BanBadge, source.BanReason, target.RingId, users);
            }
        }