コード例 #1
0
        public async Task <IActionResult> OnGetAsync(long?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            SBCommands = await _context.SBCommands.FirstOrDefaultAsync(m => m.Id == id);

            if (SBCommands == null)
            {
                return(NotFound());
            }
            return(Page());
        }
コード例 #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"));
        }
コード例 #3
0
 private static void SimpleDBInit(SegasBotContext ctx, IServiceProvider services)
 {
     try
     {
         var testItem = new SBCommands()
         {
             Answers = "1"
         };
         ctx.SBCommands.Add(testItem);
         ctx.SaveChanges();
     }
     catch (Exception ex)
     {
         var logger = services.GetRequiredService <ILogger <Program> >();
         logger.LogError(ex, "An error occurred while seeding the database.");
     }
 }