コード例 #1
0
        public IActionResult CreateIntent([FromRoute] string agentId, [FromBody] VmIntentDetail vmIntent)
        {
            if (agentId != vmIntent.AgentId)
            {
                return(BadRequest("AgentId is not matched with intent agentId."));
            }

            var agent  = new RasaAi(dc).LoadAgentById(dc, agentId);
            var intent = vmIntent.ToIntent();

            dc.DbTran(() => {
                intent.Id = agent.CreateIntent(dc, intent);
            });

            return(Ok(intent.Id));
        }
コード例 #2
0
        public IActionResult UpdateIntent([FromRoute] string intentId, [FromBody] VmIntentDetail vmIntent)
        {
            var agent = new RasaAi(dc);

            dc.DbTran(() => {
                var intent = agent.GetIntent(dc, intentId);

                // remove
                var originalIntent = dc.Table <Intent>().Find(intentId);
                dc.Table <Intent>().Remove(originalIntent);
                dc.SaveChanges();

                // add back
                intent             = vmIntent.ToIntent(intent);
                intent.UpdatedTime = DateTime.UtcNow;

                dc.Table <Intent>().Add(intent);
            });

            return(Ok(intentId));
        }