Example #1
0
        private async Task <Either <ActionResult, MetaGuidanceViewModel> > BuildViewModel(Release release)
        {
            var subjectIds = (await _fileRepository.ListDataFiles(release.Id))
                             .Where(f => f.SubjectId.HasValue)
                             .Select(f => f.SubjectId.Value)
                             .ToList();

            return(await _metaGuidanceSubjectService.GetSubjects(release.Id, subjectIds)
                   .OnSuccess(subjects => new MetaGuidanceViewModel
            {
                Id = release.Id,
                Content = release.MetaGuidance ?? "",
                Subjects = subjects
            }));
        }
Example #2
0
        public async Task <Either <ActionResult, MetaGuidanceViewModel> > Get(string publicationPath, string releasePath)
        {
            var publicationTask = _fileStorageService.GetDeserialized <CachedPublicationViewModel>(publicationPath);
            var releaseTask     = _fileStorageService.GetDeserialized <CachedReleaseViewModel>(releasePath);

            await Task.WhenAll(publicationTask, releaseTask);

            if (releaseTask.Result.IsRight && publicationTask.Result.IsRight)
            {
                return(await _metaGuidanceSubjectService.GetSubjects(releaseTask.Result.Right.Id)
                       .OnSuccess(
                           subjects =>
                           new MetaGuidanceViewModel(
                               releaseTask.Result.Right,
                               publicationTask.Result.Right,
                               subjects
                               )
                           ));
            }

            return(new Either <ActionResult, MetaGuidanceViewModel>(new NotFoundResult()));
        }