public async Task RemoveMemberAsync_Valid_Test()
        {
            // Arrange
            _repoWrapper
            .Setup(x => x.CityMembers.Delete(It.IsAny <CityMembers>()));
            _repoWrapper
            .Setup(x => x.SaveAsync());

            // Act
            await _cityParticipantsService.RemoveMemberAsync(new CityMembers());

            // Assert
            _repoWrapper.Verify();
        }
Esempio n. 2
0
        /// <inheritdoc />
        public async Task ChangeAsync(string userId)
        {
            User user = await _userManager.FindByIdAsync(userId);

            var currentRoles = await _userManager.GetRolesAsync(user);

            if (currentRoles.Count > 0)
            {
                var userRoles = await _userManager.GetRolesAsync(user);

                await _userManager.RemoveFromRolesAsync(user, userRoles);
            }

            var cityMember = await _repoWrapper.CityMembers.GetFirstOrDefaultAsync(m => m.UserId == userId);

            if (cityMember != null)
            {
                await _cityParticipants.RemoveMemberAsync(cityMember);
            }

            var clubMember = await _repoWrapper.ClubMembers.GetFirstOrDefaultAsync(m => m.UserId == userId);

            if (clubMember != null)
            {
                await _clubParticipants.RemoveMemberAsync(clubMember);
            }

            var regionAdmin = await _repoWrapper.RegionAdministration.GetFirstOrDefaultAsync(a => a.UserId == userId);

            if (regionAdmin != null)
            {
                await _regionService.DeleteAdminByIdAsync(regionAdmin.ID);
            }

            await _userManager.AddToRoleAsync(user, "Колишній член пласту");
        }