public async Task <UseCaseResult> Handle([NotNull] MemberList request, CancellationToken cancellationToken) { if (request == null) { throw new ArgumentNullException(nameof(request)); } var allowSeeDetails = await currentUser.GetIsTauchboldOrAdminAsync(); var divers = await diverRepository.GetAllTauchboldeUsersAsync(); request.OutputPort?.Output(new MemberListOutput( allowSeeDetails, divers .Where(d => d.MemberSince.HasValue) .Select(d => new MemberListOutput.Member( d.Id, d.User.Email, d.AvatarId, d.Realname, d.MemberSince.Value, d.Education, d.Experience, d.Slogan, d.WebsiteUrl, d.TwitterHandle, d.FacebookId)))); return(UseCaseResult.Success()); }
public async Task <UseCaseResult> Handle([NotNull] GetMemberManagement request, CancellationToken cancellationToken) { if (request == null) { throw new ArgumentNullException(nameof(request)); } if (!await currentUser.GetIsAdminAsync()) { logger.LogError("Use [{currentUserName}] has no access for getting member-management information!", currentUser.Username); return(UseCaseResult.AccessDenied()); } var profiles = (await diverRepository.GetAllDiversAsync()).ToList(); var allMembers = await diverRepository.GetAllTauchboldeUsersAsync(); var allUsers = userManager.Users .Where(u => allMembers.All(d => d.UserId != u.Id)) .Select(u => u.UserName); request.OutputPort?.Output( new MemberManagementOutput(await MapMembersAsync(profiles), allUsers)); return(UseCaseResult.Success()); }
public GetMassMailDetailsInteractorTests() { A.CallTo(() => diverRepository.GetAllTauchboldeUsersAsync(A <bool> ._)) .ReturnsLazily(() => Task.FromResult <ICollection <Diver> >( DiverFactory.GetTauchbolde().ToList())); interactor = new GetMassMailDetailsInteractor(diverRepository); }
public async Task <List <Diver> > GetAllTauchboldeButDeclinedParticipantsAsync( Guid currentDiverId, Guid eventId) { var declinedParticipants = (await participantRepository.GetParticipantsForEventByStatusAsync(eventId, ParticipantStatus.Declined)) .Where(p => p.ParticipatingDiver.Id != currentDiverId); var result = (await diverRepository .GetAllTauchboldeUsersAsync()) .Where(u => declinedParticipants.All(p => p.ParticipatingDiver.Id != u.Id)) .ToList(); return(result); }
public async Task <UseCaseResult> Handle([NotNull] GetMassMailDetails request, CancellationToken cancellationToken) { if (request == null) { throw new ArgumentNullException(nameof(request)); } var members = await diverRepository.GetAllTauchboldeUsersAsync(); var output = new GetMassMailDetailsOutput( members.Select(m => new GetMassMailDetailsOutput.MailRecipient( m.Fullname, m.User.Email))); request.OutputPort?.Output(output); return(UseCaseResult.Success()); }
public async Task Handle([NotNull] LogbookEntryPublishedEvent notification, CancellationToken cancellationToken) { if (notification == null) { throw new ArgumentNullException(nameof(notification)); } var recipients = await diverRepository.GetAllTauchboldeUsersAsync(); var logbookEntry = await logbookEntryRepository.FindByIdAsync(notification.LogbookEntryId); var author = await diverRepository.FindByIdAsync(logbookEntry.OriginalAuthorId); var message = $"Neuer Logbucheintrag '{logbookEntry.Title}' von {author.Realname}."; await notificationPublisher.PublishAsync( NotificationType.NewLogbookEntry, message, recipients, relatedLogbookEntryId : notification.LogbookEntryId); }