예제 #1
0
 public T Add <T>(IAddCommand <T> command)
 {
     if (command.RequiresTransaction && _transaction == null)
     {
         throw new Exception($"The command {command.GetType()} requires a transaction");
     }
     return(Retry.Invoke(() => command.Execute(_connection, _transaction), _options));
 }
예제 #2
0
        public async Task <IActionResult> Post([FromRoute] Guid storyId, [FromBody] NewFeatureRequest newFeatureRequest,
                                               [FromServices] IAddCommand <AddFeature, int> addFeatureCommand)
        {
            var addFeature = new AddFeature {
                Title   = newFeatureRequest.Title,
                StoryId = storyId
            };
            var newFeatureId = await addFeatureCommand.Execute(addFeature);

            return(Ok(newFeatureId));
        }
예제 #3
0
        public async Task <IActionResult> Post([FromRoute] Guid storyId, [FromBody] NewOptionRequest model,
                                               [FromServices] IAddCommand <NewOption, int> addOptionCommand)
        {
            var newOption = new NewOption {
                Title   = model.Title,
                StoryId = storyId
            };

            var newOptionId = await addOptionCommand.Execute(newOption);

            return(Ok(newOptionId));
        }
예제 #4
0
        public void ExecuteCommand(string[] args)
        {
            var arguments = Parser.Default.ParseArguments <
                Add,
                Get,
                Import>(args);

            arguments.MapResult(
                (Add arg) => _add.Execute(arg),
                (Get arg) => _get.Execute(arg),
                (Import arg) => _import.Execute(arg),
                errs => false
                );
        }
예제 #5
0
        public async Task <IActionResult> Post(
            [FromRoute] Guid storyId,
            [FromRoute] int featureId,
            [FromRoute] int optionId,
            [FromBody] NewOptionValueRequest optionValueRequest,
            [FromServices] IAddCommand <NewOptionValue, int> addCommand)
        {
            var model = mapper.Map <NewOptionValue>(optionValueRequest);

            model.StoryId   = storyId;
            model.FeatureId = featureId;
            model.OptionId  = optionId;
            var newOptionValueId = await addCommand.Execute(model);

            return(Ok(newOptionValueId));
        }
예제 #6
0
 public void Add(ICollection <string> args)
 {
     addCommand.Execute(args);
 }
예제 #7
0
 public async Task <IActionResult> Post([FromBody] NewStory model,
                                        [FromServices] IAddCommand <NewStory, Guid> addCommand)
 {
     return(Ok(await addCommand.Execute(model)));
 }