Esempio n. 1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.SBCommands.Add(SBCommands);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Esempio n. 2
0
        public async Task <IActionResult> OnPostAsync(long?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            SBCommands = await _context.SBCommands.FindAsync(id);

            if (SBCommands != null)
            {
                _context.SBCommands.Remove(SBCommands);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Esempio n. 3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            //BotHome.GetBotHomeInstance.BotReaction = Reaction;
            //BotHome.GetBotHomeInstance.ReactionChance = ReactionChance;

            _context.Attach(SBCommands).State = EntityState.Modified;

            try
            {
                var result = _context.SBCommands.SingleOrDefault(r => r.ChatId == "1");
                if (result != null)
                {
                    result.BotReaction    = Reaction ? "TRUE" : "FALSE";
                    result.ReactionChance = ReactionChance;
                }

                int i = await _context.SaveChangesAsync();

                if (0 < i)
                {
                    BotHome.GetBotHomeInstance.ReInitDataReader(_context);
                }
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SBCommandsExists(SBCommands.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }