public async Task <Location> Put(CreateLocation locationModel, User creator)
        {
            var locationEntity = Mapper.Map <Location>(locationModel);

            locationEntity.CreatedBy = creator;
            return(await Put(locationEntity));
        }
        public async Task GetLocationAsync(CancellationToken cancellationToken)
        {
            while (!cancellationToken.IsCancellationRequested)
            {
                var payload = await _openNotifyService.GetLocationAsync().ConfigureAwait(false);

                var cmd = new CreateLocation(Guid.NewGuid(), payload);
                await _commandDispatcher.Dispatch(cmd);
            }
        }
Exemplo n.º 3
0
 public void ChangeCurrentRegion()
 {
     Driver.Manage().Window.Maximize();
     TakeScreenshotWhenTestFailed(() =>
     {
         var location  = CreateLocation.WithRegion();
         MainPage page = new MainPage(Driver)
                         .ChangeRegion(location);
         Assert.IsTrue(page.IsNewRegion(location));
     });
 }
Exemplo n.º 4
0
        public void DeserializedEventAdapterAsFulyTypedTest()
        {
            string aggregateId      = "Box";
            int    aggregateVersion = 2;
            string aggregateType    = typeof(Location).FullName;
            string commandId        = Guid.NewGuid().ToString();
            string correlationId    = commandId;

            CreateLocation createLocation = new CreateLocation(aggregateId);

            var eventAdapter = EventFactory.Default.CreateEvent(aggregateId, aggregateVersion, aggregateType, commandId, correlationId, createLocation);

            var fullyTypedEventAdapter = eventAdapter.AsFullyTypedEvent(eventAdapter.EventBody);

            Assert.IsTrue(fullyTypedEventAdapter.EventBody.Location == aggregateId);
        }
        public void write_projection_with_training_id()
        {
            var dispatcher = new EventDispatcher();
            var projection = new SessionTestProjection();

            dispatcher.Register(projection);
            var eventBus = new EventBus(dispatcher, new FakeEventStore());

            var trainerId = Guid.NewGuid();

            var trainer  = new CreateTrainer(eventBus, new FakeTrainerQueries()).Execute("BOUDOUX", "Aurelien", "*****@*****.**");
            var location = new CreateLocation(eventBus, new FakeLocationQueries()).Execute("Paris", "test", 5);

            new PlanSession(eventBus).Execute(trainerId, new DateTime(2017, 12, 20), 3, 3, location.AggregateId, trainer.AggregateId);
            projection.Planned.TrainingId.Should().Be(trainerId);
        }
Exemplo n.º 6
0
        public void CreateCommandAdapterTest()
        {
            string aggregateId   = "Box";
            string aggregateType = typeof(Location).FullName;
            string commandId     = Guid.NewGuid().ToString();
            string correlationId = commandId;

            CreateLocation createLocationCommand = new CreateLocation(aggregateId);

            string jsonCommand = new CommandSerialization().SerializeCommand(createLocationCommand);

            var commandAdapter = new CommandSerialization().DeserializeCommand(commandId, correlationId, aggregateId, jsonCommand);

            Assert.IsInstanceOfType(commandAdapter, typeof(ICommand));
            Assert.IsInstanceOfType(commandAdapter, typeof(ICommand <CreateLocation>));
        }
Exemplo n.º 7
0
        public static Location CreateLocation(string name, string markedCode = null, int?sortNumber = null, long?parentId = null, int?childCount = null)
        {
            var cmd = new CreateLocation(name);

            if (markedCode != null)
            {
                cmd.MarkedCode = markedCode;
            }
            if (sortNumber != null)
            {
                cmd.SortNumber = sortNumber;
            }
            if (parentId != null)
            {
                cmd.ParentId = parentId;
            }
            return(cmd.Execute());
        }
Exemplo n.º 8
0
        public void CommandReturnsAssociatedEvent()
        {
            var aggregateRoot = new Location();
            var command       = new CreateLocation("locationName");

            var contextMap = new BoundedContextModel().WithAssemblyContaining <Location>();

            var aggregateAdapter = AggregateAdapterFactory.Default.CreateAggregate(contextMap, aggregateRoot);
            var commandAdapter   = CommandFactory.Default.CreateCommand <CreateLocation>("command1", "correlationId", "aggregateId", command);

            var events = aggregateAdapter.ProcessCommand(commandAdapter);

            Assert.IsNotNull(events);

            var locationCreatedDomainEvent = events.ToList().FirstOrDefault();

            Assert.IsInstanceOfType(locationCreatedDomainEvent, typeof(IEvent));
            Assert.IsInstanceOfType((locationCreatedDomainEvent as IEvent).EventBody, typeof(LocationCreated));
        }
Exemplo n.º 9
0
 public ILocationModel Any(CreateLocation request)
 {
     return(workflow.Create(request));
 }
Exemplo n.º 10
0
 public async Task <IActionResult> Create([FromBody] CreateLocation locationModel)
 {
     return(Json(
                await _locationRepository.Put(locationModel,
                                              _userRepository.GetById(_accessTokenService.GetIdFromToken(this.User)))));
 }
Exemplo n.º 11
0
        public async Task <ActionResult <Location> > Create([FromBody] CreateLocation request)
        {
            var location = await mediator.Send(request);

            return(location);
        }