Ejemplo n.º 1
0
 public EventStoreModule(IEventStoreApplicationService eventStoreService) : base("/eventsourcing/eventstore")
 {
     this.Get("/{aggregateid}", async(parameters) => {
         int version = 0;
         if (this.Request.Query.version.HasValue)
         {
             version = int.Parse(this.Request.Query.version);
         }
         var notifs = await eventStoreService.Get(Guid.Parse(parameters.aggregateId), version);
         return(new TextResponse(JsonConvert.SerializeObject(notifs)));
     }
              );
 }
Ejemplo n.º 2
0
        public TerminalModule(ITerminalQueryService terminalQueryService, IEventStoreApplicationService eventStoreApplicationService) : base("/cortex/terminals")
        {
            this.Get("/{aggregateid:guid}/events", async(parameters) =>
            {
                return(await NeuronModule.ProcessRequest(async() =>
                {
                    // TODO: validate if guid represents a terminal

                    var nv = await eventStoreApplicationService.Get(
                        parameters.aggregateid,
                        0
                        );

                    return new TextResponse(JsonConvert.SerializeObject(nv));
                }
                                                         ));
            }
                     );

            this.Get("/{terminalid:guid}", async(parameters) =>
            {
                return(await NeuronModule.ProcessRequest(async() =>
                {
                    var nv = await terminalQueryService.GetTerminalById(parameters.terminalid, NeuronModule.ParseNeuronQueryOrEmpty(this.Request.Url.Query), NeuronModule.GetUserId(this.Request));
                    return new TextResponse(JsonConvert.SerializeObject(nv));
                }
                                                         ));
            }
                     );

            this.Get(string.Empty, async(parameters) =>
            {
                return(await NeuronModule.ProcessRequest(async() =>
                {
                    var nv = await terminalQueryService.GetTerminals(NeuronModule.ParseNeuronQueryOrEmpty(this.Request.Url.Query), NeuronModule.GetUserId(this.Request));
                    return new TextResponse(JsonConvert.SerializeObject(nv));
                }
                                                         ));
            }
                     );
        }
Ejemplo n.º 3
0
        public NeuronModule(INeuronQueryService queryService, IEventStoreApplicationService eventStoreApplicationService) : base("/cortex/neurons")
        {
            this.Get("", async(parameters) =>
            {
                return(await NeuronModule.ProcessRequest(async() =>
                {
                    var nv = await queryService.GetNeurons(NeuronModule.ParseNeuronQueryOrEmpty(this.Request.Url.Query), NeuronModule.GetUserId(this.Request));
                    return new TextResponse(JsonConvert.SerializeObject(nv));
                }
                                                         ));
            }
                     );

            this.Get("/{neuronid:guid}", async(parameters) =>
            {
                return(await NeuronModule.ProcessRequest(async() =>
                {
                    var nv = await queryService.GetNeuronById(parameters.neuronid, NeuronModule.ParseNeuronQueryOrEmpty(this.Request.Url.Query), NeuronModule.GetUserId(this.Request));
                    return new TextResponse(JsonConvert.SerializeObject(nv));
                }
                                                         ));
            }
                     );

            this.Get("/{centralid:guid}/relatives", async(parameters) =>
            {
                return(await NeuronModule.ProcessRequest(async() =>
                {
                    var nv = await queryService.GetNeurons(
                        parameters.centralid,
                        NeuronModule.ParseNeuronQueryOrEmpty(this.Request.Url.Query),
                        NeuronModule.GetUserId(this.Request)
                        );

                    return new TextResponse(JsonConvert.SerializeObject(nv));
                }
                                                         ));
            }
                     );

            this.Get("/{centralid:guid}/relatives/{neuronid:guid}", async(parameters) =>
            {
                return(await NeuronModule.ProcessRequest(async() =>
                {
                    var nv = await queryService.GetNeuronById(
                        parameters.neuronid,
                        parameters.centralid,
                        NeuronModule.ParseNeuronQueryOrEmpty(this.Request.Url.Query),
                        NeuronModule.GetUserId(this.Request)
                        );
                    return new TextResponse(JsonConvert.SerializeObject(nv));
                }
                                                         ));
            }
                     );

            this.Get("/{aggregateid:guid}/events", async(parameters) =>
            {
                return(await NeuronModule.ProcessRequest(async() =>
                {
                    // TODO: validate if guid represents a neuron

                    var nv = await eventStoreApplicationService.Get(
                        parameters.aggregateid,
                        0
                        );

                    return new TextResponse(JsonConvert.SerializeObject(nv));
                }
                                                         ));
            }
                     );
        }