public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Maincategory = await _context.Maincategories.FirstOrDefaultAsync(m => m.Id == id); if (Maincategory == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Maincategory = await _context.Maincategories.FindAsync(id); if (Maincategory != null) { _context.Maincategories.Remove(Maincategory); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }