From 8e56d0cc0f85b954a937f6c43153f01af1e7c8f9 Mon Sep 17 00:00:00 2001 From: V J Date: Thu, 1 Jun 2023 15:29:08 +0200 Subject: [PATCH] ajout des admins + modifications pour avoir des listes dinamiques --- MangaMap/AppShell.xaml | 10 +++++ MangaMap/AppShell.xaml.cs | 2 + MangaMap/CustomHeader.xaml.cs | 3 +- MangaMap/MangaMap.csproj | 12 ++++++ MangaMap/Model/Manager.cs | 3 ++ MangaMap/Model/Oeuvre.cs | 9 +++++ MangaMap/Model/Utilisateur.cs | 25 ++++++------ MangaMap/Views/CreateOeuvre.xaml.cs | 52 +++++++++++++++++++++++++ MangaMap/Views/createOeuvre.xaml | 21 ++++++++++ MangaMap/Views/listPage.xaml | 55 +++++++++++++++++++++++---- MangaMap/Views/listPage.xaml.cs | 14 ++++++- MangaMap/Views/loginAdminPage.xaml | 25 ++++++++++++ MangaMap/Views/loginAdminPage.xaml.cs | 47 +++++++++++++++++++++++ MangaMap/Views/settingsPage.xaml | 4 +- MangaMap/Views/settingsPage.xaml.cs | 15 +++++++- 15 files changed, 271 insertions(+), 26 deletions(-) create mode 100644 MangaMap/Views/CreateOeuvre.xaml.cs create mode 100644 MangaMap/Views/createOeuvre.xaml create mode 100644 MangaMap/Views/loginAdminPage.xaml create mode 100644 MangaMap/Views/loginAdminPage.xaml.cs diff --git a/MangaMap/AppShell.xaml b/MangaMap/AppShell.xaml index b79ea35..e9552e2 100644 --- a/MangaMap/AppShell.xaml +++ b/MangaMap/AppShell.xaml @@ -41,6 +41,16 @@ Title="Fiche Exemple" ContentTemplate="{DataTemplate Views:ficheAnime}" Route="fichePage"/> + + + + diff --git a/MangaMap/AppShell.xaml.cs b/MangaMap/AppShell.xaml.cs index 0ba5f75..ce60124 100644 --- a/MangaMap/AppShell.xaml.cs +++ b/MangaMap/AppShell.xaml.cs @@ -14,5 +14,7 @@ public partial class AppShell : Shell Routing.RegisterRoute("settingsPagedetails", typeof(settingsPage)); Routing.RegisterRoute("listPagedetails", typeof(listPage)); Routing.RegisterRoute("fichePagedetails", typeof(ficheAnime)); + Routing.RegisterRoute("connexionAdminPagedetails", typeof(loginAdminPage)); + Routing.RegisterRoute("createPagedetails", typeof(createOeuvre)); } } diff --git a/MangaMap/CustomHeader.xaml.cs b/MangaMap/CustomHeader.xaml.cs index 62e1b05..b771b2c 100644 --- a/MangaMap/CustomHeader.xaml.cs +++ b/MangaMap/CustomHeader.xaml.cs @@ -26,6 +26,7 @@ public partial class NewContent1 : ContentView async void ListButton_Clicked(object sender, System.EventArgs e) { - await Shell.Current.GoToAsync("//page/secondaire/listPage"); + //await Shell.Current.GoToAsync("//page/secondaire/listPage"); + await Navigation.PushAsync(new listPage()); } } \ No newline at end of file diff --git a/MangaMap/MangaMap.csproj b/MangaMap/MangaMap.csproj index c3948aa..5d2ca9a 100644 --- a/MangaMap/MangaMap.csproj +++ b/MangaMap/MangaMap.csproj @@ -72,6 +72,12 @@ CustomHeader.xaml + + createOeuvre.xaml + + + loginAdminPage.xaml + signUpPage.xaml @@ -87,6 +93,9 @@ MSBuild:Compile + + MSBuild:Compile + MSBuild:Compile @@ -96,6 +105,9 @@ MSBuild:Compile + + MSBuild:Compile + MSBuild:Compile diff --git a/MangaMap/Model/Manager.cs b/MangaMap/Model/Manager.cs index 1aa5f8d..cdfd6e1 100644 --- a/MangaMap/Model/Manager.cs +++ b/MangaMap/Model/Manager.cs @@ -15,12 +15,14 @@ namespace MangaMap.Model public List Oeuvres { get; private set; } public Utilisateur UtilisateurActuel { get; set; } + public bool isAdmin { get; set; } public Manager(IPersistanceManager Pers) { Admins = new List(); Utilisateurs = new List(); Oeuvres = new List(); UtilisateurActuel = new Utilisateur(); + isAdmin = false; Persistance = Pers; } @@ -31,6 +33,7 @@ namespace MangaMap.Model Utilisateurs = new List(); Oeuvres = new List(); UtilisateurActuel = new Utilisateur(); + isAdmin = false; } /*public Utilisateur charger() diff --git a/MangaMap/Model/Oeuvre.cs b/MangaMap/Model/Oeuvre.cs index 5090ec9..52f1016 100644 --- a/MangaMap/Model/Oeuvre.cs +++ b/MangaMap/Model/Oeuvre.cs @@ -36,6 +36,15 @@ namespace MangaMap.Model Affiche = affiche; } + public Oeuvre(string nom, string type, string description, int nbEpisode, string affiche) + { + Nom = nom; + Type = type; + Description = description; + NbEpisodes = nbEpisode; + Affiche = affiche; + } + public void AjouterEpisode(int nb) { NbEpisodes = NbEpisodes + nb; diff --git a/MangaMap/Model/Utilisateur.cs b/MangaMap/Model/Utilisateur.cs index 1c209e2..1624bfe 100644 --- a/MangaMap/Model/Utilisateur.cs +++ b/MangaMap/Model/Utilisateur.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Runtime.Serialization; using System.Text; @@ -17,13 +18,13 @@ namespace MangaMap.Model [DataMember] public int age { get; private set; } [DataMember] - public List ListeOeuvreEnVisionnage { get; set; } + public ObservableCollection ListeOeuvreEnVisionnage { get; set; } [DataMember] - public List ListeOeuvreDejaVu { get; set; } + public ObservableCollection ListeOeuvreDejaVu { get; set; } [DataMember] - public List ListeOeuvrePourPlusTard { get; set; } + public ObservableCollection ListeOeuvrePourPlusTard { get; set; } [DataMember] - public List ListeOeuvreFavorites { get; set; } + public ObservableCollection ListeOeuvreFavorites { get; set; } public Utilisateur(string email, string pseudo, string mdp, string nom, string prenom, int age) { @@ -34,17 +35,17 @@ namespace MangaMap.Model this.prenom = prenom; this.age = age; - ListeOeuvreEnVisionnage = new List(); - ListeOeuvreDejaVu = new List(); - ListeOeuvrePourPlusTard = new List(); - ListeOeuvreFavorites = new List(); + ListeOeuvreEnVisionnage = new ObservableCollection(); + ListeOeuvreDejaVu = new ObservableCollection(); + ListeOeuvrePourPlusTard = new ObservableCollection(); + ListeOeuvreFavorites = new ObservableCollection(); } public Utilisateur() { - ListeOeuvreEnVisionnage = new List(); - ListeOeuvreDejaVu = new List(); - ListeOeuvrePourPlusTard = new List(); - ListeOeuvreFavorites = new List(); + ListeOeuvreEnVisionnage = new ObservableCollection(); + ListeOeuvreDejaVu = new ObservableCollection(); + ListeOeuvrePourPlusTard = new ObservableCollection(); + ListeOeuvreFavorites = new ObservableCollection(); } public void SupprimerUtilisateur() diff --git a/MangaMap/Views/CreateOeuvre.xaml.cs b/MangaMap/Views/CreateOeuvre.xaml.cs new file mode 100644 index 0000000..62ad23e --- /dev/null +++ b/MangaMap/Views/CreateOeuvre.xaml.cs @@ -0,0 +1,52 @@ +using System.Text.RegularExpressions; +using MangaMap.Model; +using static System.Runtime.InteropServices.JavaScript.JSType; + +namespace MangaMap.Views; + +public partial class createOeuvre : ContentPage +{ + public Manager my_manager => (App.Current as App).MyManager; + + public createOeuvre() + { + InitializeComponent(); + } + + async void AddClicked(object sender, System.EventArgs e) + { + // Récupérer les valeurs des entrées + string nom = nameEntry.Text; + string type = typeEntry.Text; + int nbEp = Convert.ToInt32(nbEpisodeEntry.Text); + string description = descriptionEntry.Text; + + foreach (Oeuvre o in my_manager.Oeuvres) + { + if (o.Nom == nom) + { + await DisplayAlert("Erreur", "L'oeuvre existe déjà.", "OK"); + return; + } + } + + if (string.IsNullOrWhiteSpace(nom) || + string.IsNullOrWhiteSpace(description) || string.IsNullOrWhiteSpace(type)) + { + await DisplayAlert("Erreur", "Veuillez remplir tous les champs.", "OK"); + return; + } + + if (nbEp < 0) + { + await DisplayAlert("Erreur", "Il faut avoir au 1 épisode pour l'application.", "OK"); + return; + } + + Oeuvre oeuv = new Oeuvre(nom, type, description, nbEp, "logo.png"); + my_manager.Oeuvres.Add(oeuv); + my_manager.sauvegarder(); + await Navigation.PushAsync(new homePage()); + return; + } +} \ No newline at end of file diff --git a/MangaMap/Views/createOeuvre.xaml b/MangaMap/Views/createOeuvre.xaml new file mode 100644 index 0000000..3088088 --- /dev/null +++ b/MangaMap/Views/createOeuvre.xaml @@ -0,0 +1,21 @@ + + + + +