diff --git a/src/Banquale/Banquale/Model/Person.cs b/src/Banquale/Banquale/Model/Person.cs index a33329b..f0230b5 100644 --- a/src/Banquale/Banquale/Model/Person.cs +++ b/src/Banquale/Banquale/Model/Person.cs @@ -17,25 +17,19 @@ namespace Banquale.Model public string FirstName { get; private set; } [DataMember] public uint Id { get; private set; } + + public static uint id { get; set; } = 1; [DataMember] public string Password { get; private set; } public Person(string name, string firstName, string password) - { - Name = name; - FirstName = firstName; - Id = 1; - Password = password; - } - - public Person(string name, string firstName, uint id, string password) { Name = name; FirstName = firstName; Id = id; Password = password; + id++; } - } } diff --git a/src/Banquale/Banquale/Views/ConnectionPage.xaml.cs b/src/Banquale/Banquale/Views/ConnectionPage.xaml.cs index 2d8a6dd..f7e9e6d 100644 --- a/src/Banquale/Banquale/Views/ConnectionPage.xaml.cs +++ b/src/Banquale/Banquale/Views/ConnectionPage.xaml.cs @@ -13,16 +13,16 @@ public partial class ConnectionPage : ContentPage public async void Connection_Clicked(Object sender, EventArgs e) { - string currentId = ident.Text; + uint currentId = Convert.ToUInt32(ident.Text); string password = pass.Text; - if (string.IsNullOrWhiteSpace(currentId) || string.IsNullOrWhiteSpace(password)) + if (string.IsNullOrWhiteSpace(ident.Text) || string.IsNullOrWhiteSpace(password)) { await DisplayAlert("Erreur", "Tout les champs doivent être complétés", "OK"); return; } - if(currentId == "1") + if(currentId == 0) { Mgr.IsConsultant = true; await Navigation.PushModalAsync(new ConsultantHomePage()); @@ -33,21 +33,14 @@ public partial class ConnectionPage : ContentPage Mgr.IsConsultant = false; } - - /*foreach(var Cu in Mgr.CustomersList) + Customer customer = Mgr.CustomersList.FirstOrDefault(u => u.Id == currentId && u.Password == password); + if (customer == null) { - if (Cu.Id == currentId) - { - Mgr.SelectedCustomer = Mgr.CustomersList[currentId+1]; - } - }*/ - - //if(int.Parse(currentId) in Mgr.CustomersList) // FONCTIONNE PAS - //{ - // Mgr.SelectedCustomer = Mgr.CustomersList[int.Parse(currentId)]; - //} - - Mgr.SelectedCustomer = Mgr.CustomersList[0];// 0 à changer + await DisplayAlert("Erreur", "Le mot de passe ou l'id entré est incorrect.", "OK"); + return; + } + + Mgr.SelectedCustomer = customer; await Navigation.PushModalAsync(new SwitchAccountPage());