示例#1
0
        /// <inheritdoc />
        public async Task <ClubMembersDTO> AddFollowerAsync(int ClubId, string userId)
        {
            var oldClubMember = await _repositoryWrapper.ClubMembers
                                .GetFirstOrDefaultAsync(i => i.UserId == userId);

            if (oldClubMember != null)
            {
                _repositoryWrapper.ClubMembers.Delete(oldClubMember);
                await _repositoryWrapper.SaveAsync();
            }

            var oldClubAdmins = await _repositoryWrapper.ClubAdministration
                                .GetAllAsync(i => i.UserId == userId && (DateTime.Now < i.EndDate || i.EndDate == null));

            foreach (var admin in oldClubAdmins)
            {
                await _ClubAdministrationService.RemoveAdministratorAsync(admin.ID);
            }

            var ClubMember = new ClubMembers()
            {
                ClubId     = ClubId,
                IsApproved = false,
                UserId     = userId,
                User       = await _userManager.FindByIdAsync(userId)
            };

            await _repositoryWrapper.ClubMembers.CreateAsync(ClubMember);

            await _repositoryWrapper.SaveAsync();

            return(_mapper.Map <ClubMembers, ClubMembersDTO>(ClubMember));
        }
示例#2
0
        public async Task <IActionResult> RemoveAdmin(int adminId)
        {
            await _ClubAdministrationService.RemoveAdministratorAsync(adminId);

            _logger.LogInformation($"Admin with ID {{{adminId}}} was removed.");

            return(Ok());
        }