From f6a58fd8187022259809cb1be4d14196cd6aba82 Mon Sep 17 00:00:00 2001 From: Anthony RICHARD Date: Sun, 11 Jun 2023 18:40:40 +0200 Subject: [PATCH] check ajout et edit review quand note invalide --- Sources/Stim/ReviewPopUp.xaml.cs | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/Sources/Stim/ReviewPopUp.xaml.cs b/Sources/Stim/ReviewPopUp.xaml.cs index e898a72..395e479 100644 --- a/Sources/Stim/ReviewPopUp.xaml.cs +++ b/Sources/Stim/ReviewPopUp.xaml.cs @@ -36,21 +36,25 @@ public partial class ReviewPopUp : Popup bool isDouble = double.TryParse(Val.Text, NumberStyles.Float, CultureInfo.InvariantCulture, out double rate); if (!string.IsNullOrWhiteSpace(Entrytxt.Text) && isDouble) { - if (editing == true) - { - if (prevRev.Text != Entrytxt.Text) prevRev.EditReview(Entrytxt.Text); - prevRev.EditRate(rate); - (App.Current as App).Manager.SelectedGame.UpdateReviews(); - res = 2; - } + if (rate < 0 || rate > 5) Error.Text = "Note invalide"; else { - ((App)App.Current).Manager.CurrentUser.AddReview((App.Current as App).Manager.SelectedGame, rate, Entrytxt.Text); - res = 1; - } + if (editing == true) + { + if (prevRev.Text != Entrytxt.Text) prevRev.EditReview(Entrytxt.Text); + prevRev.EditRate(rate); + (App.Current as App).Manager.SelectedGame.UpdateReviews(); + res = 2; + } + else + { + ((App)App.Current).Manager.CurrentUser.AddReview((App.Current as App).Manager.SelectedGame, rate, Entrytxt.Text); + res = 1; + } - ((App)App.Current).Manager.SaveGames(); - Close(res); + ((App)App.Current).Manager.SaveGames(); + Close(res); + } } else Error.Text = "Champ vide ou invalide"; }