public async Task <IHttpActionResult> Post(CreateZoneCommand command) { var response = await Bus.Send <CreateZoneCommand, CreateZoneCommandResponse>(command); return(Ok(response)); }
public async Task ShouldRequireUniqueTitle() { await SendAsync(new CreateZoneCommand { Title = "Zone" }); var command = new CreateZoneCommand { Title = "Zone" }; FluentActions.Invoking(() => SendAsync(command)).Should().Throw <ValidationException>(); }
public void Post([FromBody] CreateZoneDto createZoneDto) { var zoneCommand = new CreateZoneCommand() { Level = createZoneDto.Level, Name = createZoneDto.Name, ZoneType = ZoneType.FromName(createZoneDto.ZoneType) }; _createZoneCommandHandler.Handle(zoneCommand); }
public async Task <CreateZoneCommandResponse> Handle(CreateZoneCommand command) { var city = await _cityRepository.AsQuery().SingleOrDefaultAsync(p => p.Id == command.CityId); if (city == null) { throw new DomainException("شهر یافت نشد"); } var zone = new Zone(command.Title); city.Zones.Add(zone); return(new CreateZoneCommandResponse()); }
public async Task ShouldCreateZone() { var userId = await RunAsDefaultUserAsync(); var command = new CreateZoneCommand { Title = "Zone" }; var id = await SendAsync(command); var list = await FindAsync <Zone>(id); list.Should().NotBeNull(); list.Title.Should().Be(command.Title); list.CreatedBy.Should().Be(userId); list.Created.Should().BeCloseTo(DateTime.Now, 10000); }
public async Task <ActionResult <int> > Create(CreateZoneCommand command) { return(await Mediator.Send(command)); }
public async Task <IActionResult> Create([FromBody] CreateZoneCommand command) { await Mediator.Send(command); return(Ok(command)); }
public void ShouldRequireMinimumFields() { var command = new CreateZoneCommand(); FluentActions.Invoking(() => SendAsync(command)).Should().Throw <ValidationException>(); }