/// <summary>The get story.</summary> /// <param name="storyName">The story name.</param> /// <returns>The <see cref="ReadModel.Story"/>.</returns> public Story GetStory(string storyName) { if (string.IsNullOrWhiteSpace(storyName)) { throw new ArgumentNullException("storyName"); } // Get the story. Model.Story storyModel = this.storyRepository.GetStoryByName(storyName); if (storyModel == null) { throw new ArgumentException(string.Format("The story {0} doesn't exist.", storyName)); } var story = Mapper.Map <Story>(storyModel); return(story); }
/// <summary>The get next problem.</summary> /// <param name="storyName">The story name.</param> /// <param name="options">The options.</param> /// <returns>The <see cref="ReadModel.Problem"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when an argument is null.</exception> /// <exception cref="BusinessValidationException">Thrown when arguments do not pass validation.</exception> /// <exception cref="ArgumentException">Thrown when the story doesn't exist.</exception> public Problem GetNextProblem(string storyName, IList <int> options) { if (string.IsNullOrWhiteSpace(storyName)) { throw new ArgumentNullException("storyName"); } if (options == null) { throw new ArgumentNullException("options"); } // Check basic options validity. var optionsValidator = new OptionsValidator(); ValidationResults optionsValidationResults = optionsValidator.Validate(options); if (!optionsValidationResults.IsValid) { throw new BusinessValidationException(optionsValidationResults); } // Get the story. Model.Story story = this.storyRepository.GetStoryByName(storyName); if (story == null) { throw new ArgumentException(string.Format("The story {0} doesn't exist.", storyName)); } var optionsStoryValidator = new OptionsStoryValidator(story); ValidationResults optionsStoryvalidationResults = optionsStoryValidator.Validate(options); if (!optionsStoryvalidationResults.IsValid) { throw new BusinessValidationException(optionsStoryvalidationResults); } Model.Problem firstProblem = story.Steps.First(step => step.Number == 1).Problems.First(); Problem problem = this.GetProblem(firstProblem, options, 0); return(problem); }