public async Task <IHttpActionResult> DeleteCandidateTask(int id) { try { var result = _exerciseService.IsResultAssociatedWithTaskExist(id); if (result == true) { await _exerciseService.SoftDeleteCandidateExerciseAsync(id); } else { await _exerciseService.DeleteCandidateExerciseAsync(id); } return(StatusCode(HttpStatusCode.NoContent)); } catch (ExerciseNotFoundException) { return(BadRequest($"Task with {nameof(id)} = {id} not found")); } catch (Exception) { return(InternalServerError()); } }