ajout des admins + modifications pour avoir des listes dinamiques
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
parent
90dc6dbea9
commit
8e56d0cc0f
@ -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;
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="MangaMap.Views.createOeuvre"
|
||||
Background="{StaticResource Secondary}">
|
||||
|
||||
<VerticalStackLayout>
|
||||
<Label Text="Création d'une nouvelle série" FontSize="Title" Margin="0,0,0,20" TextColor="#ffffff"/>
|
||||
|
||||
<Entry x:Name="nameEntry" Placeholder="Nom" Margin="0,0,0,10" Style="{StaticResource Champs}"/>
|
||||
|
||||
<Entry x:Name="typeEntry" Placeholder="Type" Margin="0,0,0,10" Style="{StaticResource Champs}"/>
|
||||
|
||||
<Entry x:Name="descriptionEntry" Placeholder="Description" Margin="0,0,0,10" Style="{StaticResource Champs}"/>
|
||||
|
||||
<Entry x:Name="nbEpisodeEntry" Placeholder="Nombre d'épisodes" Margin="0,0,0,10" Style="{StaticResource Champs}"/>
|
||||
|
||||
<Button Text="Ajouter série" Style="{StaticResource Bouton}" Clicked="AddClicked"/>
|
||||
|
||||
</VerticalStackLayout>
|
||||
</ContentPage>
|
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="MangaMap.Views.loginAdminPage"
|
||||
Background="#1E1E1E">
|
||||
|
||||
|
||||
<StackLayout VerticalOptions="Center" HorizontalOptions="Center">
|
||||
|
||||
<Label Text="Se connecter à MapManga (ADMIN)" FontSize="Large" Margin="0,0,0,20" TextColor="#FFFFFF"/>
|
||||
|
||||
<Entry x:Name="pseudoEntry" Placeholder="Pseudo" Margin="0,0,0,10" Style="{StaticResource Champs}"/>
|
||||
|
||||
<Entry x:Name="passwordEntry" Placeholder="Mot de passe" Margin="0,0,0,20" Style="{StaticResource ChampsMdp}"/>
|
||||
|
||||
<Button Text="Se connecter" Clicked="OnLoginClicked" Style="{StaticResource Bouton}" />
|
||||
|
||||
<StackLayout Orientation="Horizontal" HorizontalOptions="Center">
|
||||
<Label Text="Pas admin ? " TextColor="#FFFFFF" Margin="0,12,5,0"/>
|
||||
<Button Text="Se connecter en utilisateur" TextColor="{StaticResource Primary}" BackgroundColor="{StaticResource Secondary}" Clicked="userClicked"/>
|
||||
</StackLayout>
|
||||
|
||||
</StackLayout>
|
||||
|
||||
</ContentPage>
|
@ -0,0 +1,47 @@
|
||||
namespace MangaMap.Views;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using MangaMap.Stub;
|
||||
using MangaMap.Model;
|
||||
|
||||
public partial class loginAdminPage : ContentPage
|
||||
{
|
||||
public Manager my_manager => (App.Current as App).MyManager;
|
||||
|
||||
public loginAdminPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
async void userClicked(object sender, EventArgs e)
|
||||
{
|
||||
await Shell.Current.GoToAsync("//page/secondaire/inscriptionPage");
|
||||
}
|
||||
|
||||
async void OnLoginClicked(object sender, EventArgs e)
|
||||
{
|
||||
// Récupération du pseudo et du mot de passe entrés
|
||||
string pseudo = pseudoEntry.Text;
|
||||
string password = passwordEntry.Text;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(pseudo) ||
|
||||
string.IsNullOrWhiteSpace(password))
|
||||
{
|
||||
await DisplayAlert("Erreur", "Veuillez remplir tous les champs.", "OK");
|
||||
return;
|
||||
}
|
||||
|
||||
// Vérifier que l'admin existe
|
||||
Admin admin = my_manager.Admins.FirstOrDefault(a => a.Pseudo == pseudo && a.MotDePasse == password);
|
||||
if (admin == null)
|
||||
{
|
||||
await DisplayAlert("Erreur", "Le mot de passe entré est incorrect.", "OK");
|
||||
return;
|
||||
}
|
||||
|
||||
// On garde la connection admin
|
||||
my_manager.isAdmin = true;
|
||||
// Rediriger l'utilisateur vers la page principale
|
||||
await Shell.Current.GoToAsync("//page/homePage");
|
||||
}
|
||||
}
|
Loading…
Reference in new issue