From a980e0399f904b30149b5524adcb812f8d9ec3b8 Mon Sep 17 00:00:00 2001 From: BelsethUwU Date: Sun, 11 Jun 2023 16:11:23 +0200 Subject: [PATCH] fix : Username change bug --- Sources/Stim/ProfilPage.xaml.cs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Sources/Stim/ProfilPage.xaml.cs b/Sources/Stim/ProfilPage.xaml.cs index f66916c..0c6601f 100644 --- a/Sources/Stim/ProfilPage.xaml.cs +++ b/Sources/Stim/ProfilPage.xaml.cs @@ -23,7 +23,28 @@ public partial class ProfilPage : ContentPage { var newName = await this.ShowPopupAsync(new EntryPopup("Username")); if (string.IsNullOrWhiteSpace(newName as string)) await this.ShowPopupAsync(new MessagePopup("Nom d'utilisateur invalide")); - else ((App)App.Current).Manager.CurrentUser.Username = (newName as string); + else + { + if (((App)App.Current).Manager.SearchUser(newName as string) is User) + { + await this.ShowPopupAsync(new MessagePopup("Nom d'utilisateur déjà utilisé")); + } + else + { + string oldName = ((App)App.Current).Manager.CurrentUser.Username; + ((App)App.Current).Manager.CurrentUser.Username = (newName as string); + foreach (Game g in ((App)App.Current).Manager.GameList) + { + foreach(Review r in g.Reviews) + { + if (r.AuthorName==oldName as string) + { + r.AuthorName= newName as string; + } + } + } + } + } } public async void PopUpBio(object sender, EventArgs e) {