/// <summary>
 /// Instantiates an instance of <see cref="ImprovementMetadata" />
 /// </summary>
 /// <param name="tenant">The tenant</param>
 /// <param name="recipe">The type of the recipe that describes the build steps</param>
 /// <param name="improvement">The id of the improvment</param>
 /// <param name="improvementFor">The id of the improvable being improved</param>
 /// <param name="version">The version of the software that is associated with this improvement</param>
 public ImprovementMetadata(TenantId tenant, RecipeType recipe, ImprovementId improvement, ImprovableId improvementFor, Version version)
 {
     Tenant         = tenant;
     Recipe         = recipe;
     Improvement    = improvement;
     ImprovementFor = improvementFor;
     Version        = version;
 }
        public void HandleFailedStep(
            RecipeType recipeType,
            StepNumber stepNumber,
            ImprovementId improvement,
            ImprovableId improvable,
            VersionString version)
        {
            var context = _improvementContextFactory.GetFor(improvable, version);
            var recipe  = _recipeLocator.GetByName(recipeType);
            var steps   = recipe.GetStepsFor(context).ToArray();
            var step    = steps[stepNumber];
            var events  = step.GetFailedEventsFor(context);

            events = events.Concat(new[] { new StepFailed(stepNumber) });
            ApplyEventsFor(context, events);
        }
        /// <inheritdoc />
        public void HandleSuccessfulStep(
            RecipeType recipeType,
            StepNumber stepNumber,
            ImprovementId improvement,
            ImprovableId improvable,
            Concepts.Version version)
        {
            var context = _improvementContextFactory.GetFor(improvable, version);
            var recipe  = _recipeLocator.GetByType(recipeType);
            var steps   = recipe.GetStepsFor(context).ToArray();
            var step    = steps[stepNumber];
            var events  = step.GetSucceededEventsFor(context);

            events = events.Concat(new[] { new StepSucceeded(stepNumber) });
            ApplyEventsFor(context, events);
        }
        void SetImprovmentResult(ImprovementId id, bool succeeded)
        {
            var request = new CommandRequest(_executionContextManager.Current.CorrelationId, _nullCommandArtifactId, ArtifactGeneration.First, new Dictionary <string, object>());

            using (var commandContext = _commandContextManager.EstablishForCommand(request))
            {
                var improvement = _repository.Get(id);
                if (succeeded)
                {
                    improvement.Complete();
                }
                else
                {
                    improvement.Fail();
                }
            }
        }
 /// <inheritdoc />
 public void HandleFailure(
     ImprovementId improvement)
 {
     SetImprovmentResult(improvement, succeeded: false);
 }
 /// <inheritdoc />
 public void HandleSuccess(
     ImprovementId improvement)
 {
     SetImprovmentResult(improvement, succeeded: true);
 }
 private bool NotBeAnExistingImprovement(ImprovementId id)
 {
     return(!_improvementExists(id));
 }