//renvoie true si il a pu créer le championnat et en out le guid de ce nouveau championnat public Boolean enregistrerNewChampionnat(int annee, out Guid championnatId) { Boolean _return = false; championnatId = Guid.Empty; using (FifaManagerEphecEntities ctx = new FifaManagerEphecEntities(_Connection)) { try { //vérifie si un championnat existe déjà pour l'année annee et la crée si non. if (this.ListAll().Where(x => x.annee == annee).FirstOrDefault() == null) { ctx.Championnats_Add(annee); using (TransactionScope scope = new TransactionScope()) { ctx.SaveChanges(); championnatId = this.getChampionnat(annee).championnatId; scope.Complete(); } _return = true; } if (!_return) { BusinessError oErreur = new BusinessError("Ce championnat existe déjà"); throw oErreur; } return(_return); } catch (Exception ex) { if (ex.InnerException != null && ex.InnerException is SqlException) { TechnicalError oErreur = new TechnicalError((SqlException)ex.InnerException); throw oErreur; } else { throw ex; } } } }