/// <inheritdoc /> public async Task <IEnumerable <BuildReadModel> > Handle(Query request, CancellationToken cancellationToken) { LifeCycleState state = stateMapper.MapFromSuffixes(request.Suffixes); IList <BuildReadModel> builds = await buildRepository .QueryAll(x => x.DistributionId == request.DistributionId && x.Number == request.BuildNumber && x.SourceType == request.SourceType && x.LifeCycleState == state, cancellationToken); HashSet <string> setSuffixes = request.Suffixes.ToHashSet(StringComparer.OrdinalIgnoreCase); return(builds.Where(b => setSuffixes.SetEquals(b.Suffixes))); }
/// <inheritdoc /> protected override Task UpdateBuild(Build build, UpdateBuild command) { Logger.LogInformation( "Received command UpdateBuild with " + $"BuildId: {command.BuildId}, " + $"Location: {command.Location}, " + $"ReleaseNumber: {command.ReleaseNumber}, " + $"Number: {command.Number}, " + $"Suffixes: {command.Suffixes?.JoinWith(",")}."); LifeCycleState newState = lifeCycleStateMapper.MapFromSuffixes(command.Suffixes.ToArray()); Logger.LogInformation($"Suffixes were mapped to {newState} for Location: {command.Location}."); UpdateBuildCore(build, command, newState); Logger.LogInformation($"Build aggregate Id: {command.BuildId} has been updated successfully. NewPath: {command.Location}"); return(Task.CompletedTask); }
/// <inheritdoc /> protected override async Task HandleCore(CreateBuild command) { logger.LogInformation($"Received command CreateBuild: {command}"); LifeCycleState lifeCycleState = lifeCycleStateMapper.MapFromSuffixes(command.Suffixes); logger.LogInformation($"Suffixes were mapped to {lifeCycleState}. {command}."); Build aggregate = new ( command.BuildDate, command.Number, command.ReleaseNumber, command.DistributionId, command.Location, command.SourceType, lifeCycleState, command.Suffixes); await aggregateRepository.Add(aggregate); logger.LogInformation($"Build aggregate Id:{aggregate.Id} has been created successfully. {command}"); }