示例#1
0
        public async Task <IActionResult> StopBot(int Id)
        {
            try
            {
                Models.User user = await db.Users.Include(x => x.Bots).ThenInclude(x => x.BotQueries)
                                   .ThenInclude(x => x.Response).FirstAsync(x => x.Name == User.Identity.Name);

                TelegramBot model;
                model           = user.Bots.First(x => x.Id == Id);
                model.IsStarted = false;
                db.Bots.Update(model);
                await db.SaveChangesAsync();

                BotHandler.StopHandle(model);
                return(new NoContentResult());
            }
            catch
            {
                return(View("Error", new ErrorModel("Bad bot index")));
            }
        }