示例#1
0
        public async Task <IHttpActionResult> Post(CreateZoneCommand command)
        {
            var response = await
                           Bus.Send <CreateZoneCommand, CreateZoneCommandResponse>(command);

            return(Ok(response));
        }
示例#2
0
        public async Task ShouldRequireUniqueTitle()
        {
            await SendAsync(new CreateZoneCommand { Title = "Zone" });

            var command = new CreateZoneCommand {
                Title = "Zone"
            };

            FluentActions.Invoking(() => SendAsync(command)).Should().Throw <ValidationException>();
        }
示例#3
0
        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());
        }
示例#5
0
        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);
        }
示例#6
0
 public async Task <ActionResult <int> > Create(CreateZoneCommand command)
 {
     return(await Mediator.Send(command));
 }
示例#7
0
        public async Task <IActionResult> Create([FromBody] CreateZoneCommand command)
        {
            await Mediator.Send(command);

            return(Ok(command));
        }
示例#8
0
        public void ShouldRequireMinimumFields()
        {
            var command = new CreateZoneCommand();

            FluentActions.Invoking(() => SendAsync(command)).Should().Throw <ValidationException>();
        }