public async Task <IActionResult> GetChatBot([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var chatBot = await _chatBotService.FindBy(m => m.ChatBotId == id);

            if (chatBot == null)
            {
                return(NotFound());
            }

            return(Ok(chatBot));
        }
Beispiel #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);
        }