public async Task <IActionResult> Edit(string id)
        {
            KBHelper      kBHelper      = new KBHelper(_appSettings);
            Knowledgebase knowledgebase = await kBHelper.GetKB(id);

            return(View(knowledgebase));
        }
        public async Task <IActionResult> Index()
        {
            ViewData["QnADeleteUrl"]       = _appSettings.QnAMaker.Host + _appSettings.QnAMaker.Service + _appSettings.QnAMaker.Methods.Delete;
            ViewData["QnASubScriptionKey"] = _appSettings.QnAMaker.SubscriptionKey;
            ViewData["QnAEndpointkeyUrl"]  = _appSettings.QnAMaker.Host + _appSettings.QnAMaker.Service + _appSettings.QnAMaker.Methods.EndPointKeys;
            ViewData["QnAGetUrl"]          = _appSettings.QnAMaker.Host + _appSettings.QnAMaker.Service + _appSettings.QnAMaker.Methods.Get;
            ViewData["BotBaseUrl"]         = _appSettings.BotApi.BaseUrl;
            try
            {
                KBHelper kBHelper = new KBHelper(_appSettings);
                KnowledgebaseResponse response = await kBHelper.GetKBsByUser();

                return(View(response.knowledgebases));
            }
            catch (Exception ex)
            {
                return(View(new List <Knowledgebase>()));
            }
        }
 public async Task <ActionResult> Create(CreateKBModel createKBModel)
 {
     try
     {
         CreateKBRequest createKBRequest = new CreateKBRequest();
         createKBRequest.name    = createKBModel.Name;
         createKBRequest.qnaList = new List <QnaList>()
         {
             new QnaList()
             {
                 id        = 0,
                 answer    = "Use this admin app to create the knowledge base",
                 source    = "Admin App",
                 questions = new List <string>()
                 {
                     "What admin app can do?"
                 },
                 metadata = new List <Metadata>()
                 {
                     new Metadata()
                     {
                         name  = "category",
                         value = "api"
                     }
                 }
             }
         };
         createKBRequest.urls = Uri.UnescapeDataString(createKBModel.Urls).Split(',').ToList <string>();
         //createKBRequest.urls = ExtractUrls(createKBModel.Urls, false);
         createKBRequest.files = new List <object>();
         string   kb           = JsonConvert.SerializeObject(createKBRequest);
         KBHelper kBHelper     = new KBHelper(_appSettings);
         var      headerValues = kBHelper.CreateKB(JsonConvert.SerializeObject(createKBRequest));
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
        public async Task <bool> Delete(string kbid)
        {
            KBHelper kBHelper = new KBHelper(_appSettings);

            return(await kBHelper.DeleteKB(kbid));
        }