public IActionResult BotList() { int _sol_id = 100; var bot = new BotListRequest(); bot.SolutionId = _sol_id; List <ChatBot> Bots = ServiceClient.Get <BotListResponse>(bot).Data; string _html = string.Empty; string BotTile = @" <form method='post' action='../Boti/addBot'> <div class='botlist-box' tabindex='1'> <div class='Bot-tile'> <h4>@Name@</h4> <div class='bottile-icon'></div> <div class='sitename'>@WebsiteURL@</div> <div class='pull-left'> <div class='created-lbl'>@CreatedBy@</div> <div class='created-date'>@CreatedAt@</div> </div> <div class='pull-right'> <div class='modified-lbl'>@LastModifiedBy@</div> <div class='modified-date'>@LastModifiedAt@</div> </div> </div> </div> <input type='hidden' value='@Name@' name='_name' /> <input type='hidden' value='@fullname@' name='_fullname' /> <input type='hidden' value='@WebsiteURL@' name='_url' /> <input type='hidden' value='@ViewBag.chatid' name='_chat_id' /> <input type='hidden' value='@welcomeMsg@' name='_wel_msg' /> <input type='hidden' value='@ViewBag.solid' name='_sol_id' /> <input type='hidden' value='@chatid@' name='chatid' /> <input type='hidden' value='@botid@' name='botid' /> </form>"; foreach (ChatBot chatbot in Bots) { _html += BotTile.Replace("@Name@", chatbot.Name) .Replace("@fullname@", chatbot.FullName) .Replace("@WebsiteURL@", chatbot.WebsiteURL) .Replace("@LastModifiedBy@", chatbot.LastModifiedBy) .Replace("@LastModifiedAt@", chatbot.LastModifiedAt.ToString()) .Replace("@CreatedBy@", chatbot.CreatedBy) .Replace("@CreatedAt@", chatbot.CreatedAt.ToString()) .Replace("@welcomeMsg@", chatbot.WelcomeMsg) .Replace("@chatid@", chatbot.ChatId) .Replace("@botid@", chatbot.BotId) .Replace("@ViewBag.solid", "100"); } ViewBag.tileshtml = _html; return(View()); }
public object Get(BotListRequest request) { List <ChatBot> res = new List <ChatBot>(); string sql = @" SELECT id, name, url, botid, (SELECT firstname FROM eb_users WHERE id = eb_bots.created_by) AS created_by, created_at, (SELECT firstname FROM eb_users WHERE id = eb_bots.modified_by) AS modified_by, modified_at, welcome_msg FROM eb_bots WHERE solution_id = @solid;" ; parameters.Add(this.TenantDbFactory.ObjectsDB.GetNewParameter("@solid", System.Data.DbType.Int32, 100));//request.SolutionId)); var dt = this.TenantDbFactory.ObjectsDB.DoQuery(sql, parameters.ToArray()); foreach (var dr in dt.Rows) { ChatBot bot = new ChatBot { BotId = dr[0].ToString(), Name = dr[1].ToString(), WebsiteURL = dr[2].ToString(), ChatId = dr[3].ToString(), CreatedBy = dr[4].ToString(), CreatedAt = Convert.ToDateTime(dr[5]), LastModifiedBy = dr[6].ToString(), LastModifiedAt = Convert.ToDateTime(dr[7]), WelcomeMsg = dr[8].ToString() }; res.Add(bot); } return(new BotListResponse { Data = res }); }