public async Task <IActionResult> PostChatBot([FromBody] Domain.ChatBot chatBot)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await _chatBotService.Create(chatBot);

            return(CreatedAtAction("GetChatBot", new { id = chatBot.ChatBotId }, chatBot));
        }
示例#2
0
        /// <summary>
        /// Fetches chatbot or creates if it doesn't exist
        /// </summary>
        /// <returns></returns>
        protected virtual async Task <Domain.ChatBot> GetChatBotAsync()
        {
            Domain.ChatBot chatBotModel = null;
            if (await _chatBotService.Exists(cb => cb.Name == this._chatBotName))
            {
                chatBotModel = await _chatBotService.FindBy(cb => cb.Name == this._chatBotName);
            }
            else
            {
                chatBotModel = await _chatBotService.Create(new Domain.ChatBot {
                    Name = this._chatBotName
                });
            }

            return(chatBotModel);
        }