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);
            }
        }
Esempio 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));
     });
 }
Esempio 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);
        }
Esempio 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>));
        }
Esempio 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());
        }
Esempio 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));
        }
Esempio n. 9
0
 public ILocationModel Any(CreateLocation request)
 {
     return(workflow.Create(request));
 }
 public async Task <IActionResult> Create([FromBody] CreateLocation locationModel)
 {
     return(Json(
                await _locationRepository.Put(locationModel,
                                              _userRepository.GetById(_accessTokenService.GetIdFromToken(this.User)))));
 }
Esempio n. 11
0
        public async Task <ActionResult <Location> > Create([FromBody] CreateLocation request)
        {
            var location = await mediator.Send(request);

            return(location);
        }