예제 #1
0
        public ListAllLogbookEntriesInteractorTests()
        {
            A.CallTo(() => repository.GetAllEntriesAsync(false))
            .ReturnsLazily(call => Task.FromResult(new List <LogbookEntry>
            {
                new LogbookEntry {
                    Id = new Guid("05CFFBD4-356C-405C-9BF3-9A756722E9C8")
                },
            } as ICollection <LogbookEntry>));

            A.CallTo(() => repository.GetAllEntriesAsync(true))
            .ReturnsLazily(call => Task.FromResult(new List <LogbookEntry>
            {
                new LogbookEntry {
                    Id = new Guid("05CFFBD4-356C-405C-9BF3-9A756722E9C8")
                },
                new LogbookEntry {
                    Id = new Guid("12818D43-F0BF-4762-8A7E-F1023B81FEA4")
                },
            } as ICollection <LogbookEntry>));

            interactor = new ListAllLogbookEntriesInteractor(repository, currentUser);
        }
        public async Task <UseCaseResult> Handle([NotNull] ListAllLogbookEntries request, CancellationToken cancellationToken)
        {
            var canEdit = await currentUser.GetIsTauchboldOrAdminAsync();

            var allEntries = await logbookEntryRepository.GetAllEntriesAsync(canEdit);

            var output = new ListAllLogbookEntriesOutputPort(allEntries.Select(l =>
                                                                               new ListAllLogbookEntriesOutputPort.LogbookItem(
                                                                                   l.Id, l.Title, l.TeaserText, l.TeaserImageThumb, l.IsPublished, l.Text)),
                                                             canEdit);

            request.OutputPort.Output(output);

            return(UseCaseResult.Success());
        }
        public async Task <UseCaseResult <IEnumerable <LogbookEntry> > > Handle([NotNull] SummaryListLogbookEntries request, CancellationToken cancellationToken)
        {
            var allEntries = await logbookEntryRepository.GetAllEntriesAsync(false);

            return(UseCaseResult <IEnumerable <LogbookEntry> > .Success(allEntries));
        }