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)); }
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)); }
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)); }
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 ); }
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)); }
public void Add(ICollection <string> args) { addCommand.Execute(args); }
public async Task <IActionResult> Post([FromBody] NewStory model, [FromServices] IAddCommand <NewStory, Guid> addCommand) { return(Ok(await addCommand.Execute(model))); }