Ejemplo n.º 1
0
        private async Task <ProjectionVersion> GetLiveVersion(Type projectionType)
        {
            var           projectionVersionManagerId = new ProjectionVersionManagerId(projectionType.GetContractId(), context.Tenant);
            ProjectionDto dto = await ExploreAsync(projectionVersionManagerId, typeof(ProjectionVersionsHandler)).ConfigureAwait(false);

            var state = dto?.State as ProjectionVersionsHandlerState;

            ProjectionVersion liveVersion = state is null ? null : state.AllVersions.GetLive();

            return(liveVersion);
        }
Ejemplo n.º 2
0
        public async Task <ProjectionDto> ExploreAsync(IBlobId id, Type projectionType)
        {
            var result           = new ProjectionDto();
            var projectionResult = await projections.GetAsync(id, projectionType);

            if (projectionResult.IsSuccess)
            {
                result.Name  = projectionType.Name;
                result.State = projectionResult.Data.State;
            }

            return(result);
        }
Ejemplo n.º 3
0
        public async Task <ProjectionDto> ExploreIncludingEventsAsync(IBlobId id, Type projectionType)
        {
            ProjectionDto result = await ExploreAsync(id, projectionType).ConfigureAwait(false);

            bool projectionHasState = result.State is null == false;

            if (projectionHasState)
            {
                ProjectionVersion liveVersion = await GetLiveVersion(projectionType);

                if (liveVersion is null == false)
                {
                    var commits = new List <ProjectionCommitDto>();
                    await foreach (var item in projectionStore.EnumerateProjectionAsync(liveVersion, id))
                    {
                        commits.Add(item.ToProjectionDto());
                    }

                    result.Commits = commits;
                }
            }

            return(result);
        }