예제 #1
0
        public HttpResponseMessage Create([FromBody] RegistreerDeelnemerCommand command)
        {
            var deelnemer = new PensioenSysteem.Domain.Deelnemer.Deelnemer();
            deelnemer.Registreer(command);

            var repo = new EventSourcedAggregateRepository<PensioenSysteem.Domain.Deelnemer.Deelnemer>(
                new FileEventStore(new RabbitMQEventPublisher()));
            repo.Save(deelnemer, -1);

            return new HttpResponseMessage(HttpStatusCode.Created);
        }
예제 #2
0
        public void Save(TAggregate aggregate)
        {
            cache.AddOrUpdate(
                aggregate.AggregateId,
                aggregate,
                (id, current) => current.Revision <= aggregate.Revision ? aggregate : current);

            AggregateRepository <TAggregate> repository =
                new EventSourcedAggregateRepository <TAggregate>(aggregateEventStore);

            repository.Save(aggregate);
        }
        public HttpResponseMessage Create([FromBody] RegistreerDeelnemerCommand command)
        {
            var deelnemer = new PensioenSysteem.Domain.Deelnemer.Deelnemer();

            deelnemer.Registreer(command);

            var repo = new EventSourcedAggregateRepository <PensioenSysteem.Domain.Deelnemer.Deelnemer>(
                new FileEventStore(new RabbitMQEventPublisher()));

            repo.Save(deelnemer, -1);

            return(new HttpResponseMessage(HttpStatusCode.Created));
        }
        public HttpResponseMessage Create([FromBody] RegistreerArbeidsverhoudingCommand command)
        {
            var arbeidsverhouding = new PensioenSysteem.Domain.Arbeidsverhouding.Arbeidsverhouding();

            arbeidsverhouding.Registreer(command);

            var repo = new EventSourcedAggregateRepository <PensioenSysteem.Domain.Arbeidsverhouding.Arbeidsverhouding>(
                new FileEventStore(new RabbitMQEventPublisher()));

            repo.Save(arbeidsverhouding, -1);

            return(new HttpResponseMessage(HttpStatusCode.Created));
        }
예제 #5
0
        public HttpResponseMessage Verhuis(Guid id, [FromBody] VerhuisDeelnemerCommand command)
        {
            var repo = new EventSourcedAggregateRepository<PensioenSysteem.Domain.Deelnemer.Deelnemer>(
                new FileEventStore(new RabbitMQEventPublisher()));

            Domain.Deelnemer.Deelnemer deelnemer;
            try
            {
                deelnemer = repo.GetById(id);
            }
            catch (AggregateNotFoundException ex)
            {
                return new HttpResponseMessage(HttpStatusCode.NotFound);
            }

            deelnemer.Verhuis(command);

            repo.Save(deelnemer, command.Version);

            return new HttpResponseMessage(HttpStatusCode.OK);
        }
        public HttpResponseMessage Verhuis(Guid id, [FromBody] VerhuisDeelnemerCommand command)
        {
            var repo = new EventSourcedAggregateRepository <PensioenSysteem.Domain.Deelnemer.Deelnemer>(
                new FileEventStore(new RabbitMQEventPublisher()));

            Domain.Deelnemer.Deelnemer deelnemer;
            try
            {
                deelnemer = repo.GetById(id);
            }
            catch (AggregateNotFoundException ex)
            {
                return(new HttpResponseMessage(HttpStatusCode.NotFound));
            }

            deelnemer.Verhuis(command);

            repo.Save(deelnemer, command.Version);

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }