示例#1
0
        public async Task Get()
        {
            var firstId = await _service.Put(
                new StateMachineInputDto()
            {
                Name = "first name", Body = "first body"
            });

            var secondId = await _service.Put(
                new StateMachineInputDto()
            {
                Name = "second name", Body = "second body"
            });

            var first = await _service.Get("first name");

            var second = await _service.Get("second name");

            var third = await _service.Get("third name");

            Assert.True(first != null);
            Assert.Equal(firstId, first.Id);
            Assert.Equal("first name", first.Name);
            Assert.Equal("first body", first.Body);
            Assert.True(second != null);
            Assert.Equal(secondId, second.Id);
            Assert.Equal("second name", second.Name);
            Assert.Equal("second body", second.Body);
            Assert.True(third == null);
        }
示例#2
0
        public async Task <IActionResult> ChangeState([FromBody] PayloadModel <ServiceState> model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (model.Message == ServiceState.Subscribed)
            {
                var stateContext = stateMachineService.Get(model.AgentId);

                await stateContext.Start(model.BotId, model.AgentId);
            }

            return(Ok());
        }
示例#3
0
        public async Task <ApiResponse <StateMachineOutputDto> > Get(string name)
        {
            var dto = await _stateMachineService.Get(name);

            if (dto == null)
            {
                return(ApiResponse.NotFound(Response, "state machine not found", dto));
            }
            return(ApiResponse.OK(dto));
        }