diff --git a/src/MangaMap/AppShell.xaml b/src/MangaMap/AppShell.xaml
index dfd5cfb..0482728 100644
--- a/src/MangaMap/AppShell.xaml
+++ b/src/MangaMap/AppShell.xaml
@@ -56,6 +56,11 @@
Title="Modification oeuvre"
ContentTemplate="{DataTemplate Views:modifyOeuvre}"
Route="modifyOeuvrePage"/>
+
+
diff --git a/src/MangaMap/AppShell.xaml.cs b/src/MangaMap/AppShell.xaml.cs
index 141d1f9..72a06fe 100644
--- a/src/MangaMap/AppShell.xaml.cs
+++ b/src/MangaMap/AppShell.xaml.cs
@@ -28,5 +28,6 @@ public partial class AppShell : Shell
Routing.RegisterRoute("connexionAdminPagedetails", typeof(loginAdminPage));
Routing.RegisterRoute("createPagedetails", typeof(createOeuvre));
Routing.RegisterRoute("modifyPagedetails", typeof(modifyOeuvre));
+ Routing.RegisterRoute("loginModifyPagedetails", typeof(loginModifyPage));
}
}
diff --git a/src/MangaMap/Views/loginModifyPage.xaml b/src/MangaMap/Views/loginModifyPage.xaml
new file mode 100644
index 0000000..316eaac
--- /dev/null
+++ b/src/MangaMap/Views/loginModifyPage.xaml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/MangaMap/Views/loginModifyPage.xaml.cs b/src/MangaMap/Views/loginModifyPage.xaml.cs
new file mode 100644
index 0000000..a328775
--- /dev/null
+++ b/src/MangaMap/Views/loginModifyPage.xaml.cs
@@ -0,0 +1,128 @@
+using Models;
+using System.Text.RegularExpressions;
+
+namespace MangaMap.Views;
+
+public partial class loginModifyPage : ContentPage
+{
+ ///
+ /// Référence au gestionnaire de l'application.
+ ///
+ public Manager my_manager => (App.Current as App).MyManager;
+ public Utilisateur utilisateurModify;
+
+ public loginModifyPage(Utilisateur u)
+ {
+ utilisateurModify = u;
+
+ InitializeComponent();
+ }
+
+ ///
+ /// Gestionnaire d'événement lorsqu'un utilisateur clique sur le bouton "Inscription".
+ ///
+ /// L'objet qui a déclenché l'événement.
+ /// Arguments de l'événement.
+ async void OnModifiedClicked(object sender, System.EventArgs e)
+ {
+ // Récupérer les valeurs des entrées
+ string nom = nameEntry.Text;
+ string prenom = firstNameEntry.Text;
+ int age = Convert.ToInt32(ageEntry.Text);
+ string email = emailEntry.Text;
+ string pseudo = usernameEntry.Text;
+ string password = passwordEntry.Text;
+ string confirmPassword = confirmPasswordEntry.Text;
+
+ foreach (Utilisateur u in my_manager.Utilisateurs)
+ {
+ if (u.Email == email || u.Pseudo == pseudo)
+ {
+ await DisplayAlert("Erreur", "L'utilisateur existe déjà.", "OK");
+ return;
+ }
+ }
+
+ // Vérifier si les mots de passe correspondent
+ if (password != confirmPassword)
+ {
+ await DisplayAlert("Erreur", "Les mots de passe ne correspondent pas", "OK");
+ return;
+ }
+
+ if (nom != null)
+ utilisateurModify.nom = nom;
+
+ if (prenom != null)
+ utilisateurModify.prenom = prenom;
+
+ if (age > 0)
+ utilisateurModify.age = age;
+
+ if (email != null)
+ {
+ // Vérifier que l'e-mail a la bonne forme
+ if (!Regex.IsMatch(email, @"^[^@\s]+@[^@\s]+\.[^@\s]+$"))
+ {
+ await DisplayAlert("Erreur", "L'e-mail n'est pas valide.", "OK");
+ return;
+ }
+ utilisateurModify.Email = email;
+ }
+
+ if (pseudo != null)
+ utilisateurModify.Pseudo = pseudo;
+
+ if (password != null)
+ {
+ if (IsPasswordStrong(password) == false)
+ {
+ await DisplayAlert("Erreur", "Le mot de passe n'est pas assez fort", "OK");
+ return;
+ }
+
+ utilisateurModify.MotDePasse = password;
+ }
+
+ my_manager.sauvegarder();
+ await Shell.Current.GoToAsync("//page/homePage");
+ return;
+ }
+
+ ///
+ /// Vérifie si un mot de passe est suffisamment fort.
+ ///
+ /// Le mot de passe à vérifier.
+ /// True si le mot de passe est suffisamment fort, sinon False.
+ bool IsPasswordStrong(string password)
+ {
+ // Vérifier si le mot de passe est assez long
+ if (password.Length < 8)
+ {
+ return false;
+ }
+
+ // Vérifier si le mot de passe contient au moins une majuscule, une minuscule et un chiffre
+ bool hasUppercase = false;
+ bool hasLowercase = false;
+ bool hasDigit = false;
+
+ foreach (char c in password)
+ {
+ if (char.IsUpper(c))
+ {
+ hasUppercase = true;
+ }
+ else if (char.IsLower(c))
+ {
+ hasLowercase = true;
+ }
+ else if (char.IsDigit(c))
+ {
+ hasDigit = true;
+ }
+ }
+
+ return hasUppercase && hasLowercase && hasDigit;
+ }
+}
\ No newline at end of file
diff --git a/src/MangaMap/Views/modifyOeuvre.xaml.cs b/src/MangaMap/Views/modifyOeuvre.xaml.cs
index c20ec6f..53de746 100644
--- a/src/MangaMap/Views/modifyOeuvre.xaml.cs
+++ b/src/MangaMap/Views/modifyOeuvre.xaml.cs
@@ -7,14 +7,14 @@ public partial class modifyOeuvre : ContentPage
public Manager my_manager => (App.Current as App).MyManager;
public Oeuvre oeuvreModifie { get; set; }
- public modifyOeuvre(Oeuvre anime)
- {
- oeuvreModifie = anime;
+ public modifyOeuvre(Oeuvre anime)
+ {
+ oeuvreModifie = anime;
- InitializeComponent();
+ InitializeComponent();
- BindingContext = oeuvreModifie;
- }
+ BindingContext = oeuvreModifie;
+ }
///
/// Gère l'événement de clic sur le bouton de modification d'une oeuvre.
@@ -29,26 +29,31 @@ public partial class modifyOeuvre : ContentPage
int nbEp = Convert.ToInt32(nbEpisodeEntry.Text);
string description = descriptionEntry.Text;
- if (nbEp < 0)
+ if (nom != null)
{
- await DisplayAlert("Erreur", "Il faut avoir au moins 1 épisode pour l'application.", "OK");
+ foreach (Oeuvre o in my_manager.Oeuvres)
+ {
+ if (o.Nom == nom)
+ {
+ await DisplayAlert("Erreur", "Ce nom existe déjà pour une autre oeuvre.", "OK");
+ return;
+ }
+
+ oeuvreModifie.Nom = nom;
+ }
+
+ if (type != null)
+ oeuvreModifie.Type = type;
+
+ if (description != null)
+ oeuvreModifie.Description = description;
+
+ if (nbEp > 0)
+ oeuvreModifie.NbEpisodes = nbEp;
+
+ my_manager.sauvegarder();
+ await Navigation.PushAsync(new homePage());
return;
}
-
- if (nom != null)
- oeuvreModifie.Nom = nom;
-
- if (type != null)
- oeuvreModifie.Type = type;
-
- if (description != null)
- oeuvreModifie.Description = description;
-
- if (nbEp > 0)
- oeuvreModifie.NbEpisodes = nbEp;
-
- my_manager.sauvegarder();
- await Navigation.PushAsync(new homePage());
- return;
}
}
\ No newline at end of file
diff --git a/src/MangaMap/Views/settingsPage.xaml b/src/MangaMap/Views/settingsPage.xaml
index e49719d..31d58ff 100644
--- a/src/MangaMap/Views/settingsPage.xaml
+++ b/src/MangaMap/Views/settingsPage.xaml
@@ -9,14 +9,16 @@
-
+
+
+
-
+
diff --git a/src/MangaMap/Views/settingsPage.xaml.cs b/src/MangaMap/Views/settingsPage.xaml.cs
index 6f48345..4b820ad 100644
--- a/src/MangaMap/Views/settingsPage.xaml.cs
+++ b/src/MangaMap/Views/settingsPage.xaml.cs
@@ -95,4 +95,16 @@ public partial class settingsPage : ContentPage
await DisplayAlert("Erreur", "L'oeuvre n'existe pas.", "OK");
return;
}
+
+ private async void ModifyAccountClicked(object sender, System.EventArgs e)
+ {
+ if (my_manager.UtilisateurActuel.Email == null)
+ {
+ await DisplayAlert("Erreur", "Vous n'êtes pas connecté.", "OK");
+ return;
+ }
+
+ await Navigation.PushAsync(new loginModifyPage(my_manager.UtilisateurActuel));
+ return;
+ }
}
\ No newline at end of file
diff --git a/src/Models/Utilisateur.cs b/src/Models/Utilisateur.cs
index f9a59a7..b3f2332 100644
--- a/src/Models/Utilisateur.cs
+++ b/src/Models/Utilisateur.cs
@@ -34,7 +34,7 @@ namespace Models
/// Obtient ou définit l'âge de l'utilisateur.
///
[DataMember]
- public int age { get; private set; }
+ public int age { get; set; }
///
/// Obtient ou définit la liste des oeuvres en visionnage de l'utilisateur.