public async Task <IActionResult> Delete(int?id) { if (id == null) { return(NotFound()); } Vacancy vacancy = await _vacancy.FindByIdAsync((int)id); if (vacancy == null) { return(NotFound()); } try { await _vacancy.DeleteAsync(vacancy); } catch (DbUpdateException) { return(BadRequest(new { Code = "NotDeleted", Description = "Error deleting data" })); } return(RedirectToAction(nameof(Index))); }