From 74eb9e2a50380cb151a905bb55015f1ff89e1f67 Mon Sep 17 00:00:00 2001 From: Augustin AFFOGNON Date: Mon, 24 Oct 2022 02:09:09 +0200 Subject: [PATCH] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'Sources/BowlingMap?= =?UTF-8?q?ing/JoueurDbDataManager.cs'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/BowlingMaping/JoueurDbDataManager.cs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Sources/BowlingMaping/JoueurDbDataManager.cs b/Sources/BowlingMaping/JoueurDbDataManager.cs index 6c041b0..ea505a4 100644 --- a/Sources/BowlingMaping/JoueurDbDataManager.cs +++ b/Sources/BowlingMaping/JoueurDbDataManager.cs @@ -41,13 +41,23 @@ namespace BowlingMaping public bool Delete(Joueur _joueur) { bool result = false; - using (var context = new BowlingContext()) + + + try{ + using (var context = new BowlingContext()) + { + JoueurEntity entity = context.Joueurs.Find(_joueur.Id); + context.Joueurs.Remove(entity); + result = context.SaveChanges() == 1; + } + return result; + + }catch (SqlException) { - JoueurEntity entity = context.Joueurs.Find(_joueur.Id); - context.Joueurs.Remove(entity); - result = context.SaveChanges() == 1; + WriteLine("Votre base de données n'existe pas."); } - return result; + + } ///