public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } var Competency = await _context.Certificates.FindAsync(id); if (Competency == null) { return(NotFound()); } try { // _context.Certificates.Remove(Certificate); _jobCompetencyService.DeleteJobCompetency(Competency); //await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } catch (DbUpdateException ex) { _logger.LogError(ex, ErrorMessage); return(RedirectToAction("./Delete", new { id, saveChangesError = true })); } }