Example #1
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));
                }
                                                         ));
            }
                     );
        }
Example #2
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));
                }
                                                         ));
            }
                     );
        }