public void Desactivate(int id) { var exo = _exerciceRepository.FindBy(id); _sourceRepository.Delete(exo.Sources); exo.Sources.Clear(); _exerciceRepository.Delete(exo); }
/// <summary> /// Delete exercice /// </summary> /// <param name="no">Id exercice</param> public void DeleteExercice(int no) { // charger l'exercice Exercice exercice = _exerciceRepository.Get(no); if (exercice == null) { throw new InvalidOperationException("Exercice invalide!"); } if (Exercice.Id == no) { throw new ApplicationException("Impossible du supprimer l'exercice courant"); } // check if exercice has declaration //if (_declarationRepository.ExerciceHasDeclaration(no)) // throw new InvalidOperationException("Opération invalide! l'exercice contient des déclarations"); if (Societe.CurrentExerciceNo == no) { throw new InvalidOperationException("Exercice est en cours d'utilisation!"); } // remove exercice _exerciceRepository.Delete(no); }