public static Dimension CreateDimensionFrom(CreateDimensionCommand command) { var groups = command.Groups.Select(CreateDimensionGroupFrom); var dimension = new Dimension(command.LeafCategoryId, groups); return(dimension); }
public Guid Post(CreateDimensionCommand command) { var id = Guid.Empty; this._listener.Subscribe(new ActionHandler <DimensionCreated>(a => { id = a.Id; })); _commandBus.Dispatch(command); return(id); }
public async Task <IActionResult> Create(CreateDimensionCommand command) { var id = 0; _eventListener.Subscribe(new ActionHandler <EntityCreated>(a => { id = a.Id; })); await _bus.Dispatch(command); return(Ok(id)); }
public async Task WhenISubmitTheDimension() { var leafCategoryId = ScenarioContext.Get <int>("leaf-category-Id"); var command = new CreateDimensionCommand { LeafCategoryId = leafCategoryId, Groups = new List <DimensionGroupCommand> { new DimensionGroupCommand() { Title = "Twin Size", Items = new List <DimensionItemCommand> { new DimensionItemCommand { Title = "Overall Product Weight", UnitOfMeasurementType = 1 }, new DimensionItemCommand { Title = "Overall Product Height", UnitOfMeasurementType = 2 }, } }, new DimensionGroupCommand() { Title = "Full Size", Items = new List <DimensionItemCommand> { new DimensionItemCommand { Title = "Overall Product Weight", UnitOfMeasurementType = 1 }, new DimensionItemCommand { Title = "Overall Product Height", UnitOfMeasurementType = 2 }, } }, } }; ScenarioContext.Add("dimension", command); var id = await _dimensionTask.CreateDimension(command); ScenarioContext.Add("dimension-Id", id); }
public void HandleCreate_should_add_dimension_to_repository() { const string time = "Time"; var aggregate = new EventAggregator(); var dto = new CreateDimensionCommand { Name = time }; var repository = Substitute.For <IDimensionRepository>(); var service = new DimensionCommandHandlers(repository, aggregate); var expectedDimension = new Dimension(time, aggregate); service.Handle(dto); repository.Received(1).Add(expectedDimension); }
public void HandleCreate_should_add_dimension_to_repository() { const string time = "Time"; var aggregate = new EventAggregator(); var command = new CreateDimensionCommand { Name = time }; var expectedDimension = new Dimension(time, aggregate); var repository = Substitute.For <IDimensionRepository>(); var commandHandler = new DimensionCommandHandlers(repository, aggregate); commandHandler.Handle(command); repository.Received(1) .Add(Verify.That <Dimension>( a => a.Should().BeEquivalentTo(expectedDimension, z => z.Excluding(b => b.Id).ComparingByMembers <Dimension>()))); }
public Guid Post(CreateDimensionCommand command) { return(_facade.Create(command)); }
internal async Task <int> CreateDimension(CreateDimensionCommand command) { var response = await _httpClient.Post <CreateDimensionCommand, int>("api/dimensions", command); return(response); }