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()); }
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")); }
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."); } }