diff --git a/MCTG/DataPersistence/Stubs.cs b/MCTG/DataPersistence/Stubs.cs
index 1539bc5..2b32fec 100644
--- a/MCTG/DataPersistence/Stubs.cs
+++ b/MCTG/DataPersistence/Stubs.cs
@@ -1,132 +1,132 @@
-using Model;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace DataPersistence
-{
- ///
- /// The subs class is a group of prefabricated object that can only be loaded. It only use is for testing.
- ///
- public class Stubs : IDataManager
- {
- public Dictionary> Load()
- {
- PasswordManager passwordManager = new PasswordManager();
-
- Dictionary> data = new Dictionary>
- {
- {
- #region Data: Recipes
- nameof(Recipe),
- new List(new[]
- {
- new Recipe(
- title: "Cookies classiques", id: null,
- preparationSteps: new[]
- {
- new PreparationStep(1, "Faire cuire."),
- new PreparationStep(2, "Manger.")
- }),
- new Recipe(
- title: "Cookies au chocolat", id: null,
- preparationSteps: new[]
- {
- new PreparationStep(1, "Moulinez la pâte."),
- new PreparationStep(2, "Faire cuire pendant une bonne heure."),
- new PreparationStep(3, "Sortir du four et mettre dans un plat.")
- }),
- new Recipe(
- title: "Gateau nature", id: null,
- preparationSteps: new[]
- {
- new PreparationStep(1, "Achetez les ingrédients."),
- new PreparationStep(2, "Préparez le matériel. Ustensiles et tout."),
- new PreparationStep(3, "Pleurez.")
- }),
- new Recipe(
- title: "Gateau au pommes", id: null,
- preparationSteps: new[]
- {
- new PreparationStep(1, "Achetez les légumes."),
- new PreparationStep(2, "Préparez le plat. Ustensiles et préchauffez le four."),
- new PreparationStep(3, "Coupez les pommes en morceaux et disposez-les sur le plat."),
- new PreparationStep(4, "Mettez enfin le plat au four, puis une fois cuit, dégustez !")
- }),
- new Recipe(
- title: "Gateau au chocolat", id: null,
- preparationSteps: new[]
- {
- new PreparationStep(1, "Ajouter les oeufs."),
- new PreparationStep(2, "Ajouter la farine."),
- new PreparationStep(3, "Ajouter 100g de chocolat fondu."),
- new PreparationStep(4, "Mélanger le tout."),
- new PreparationStep(5, "Faire cuire 45h au four traditionnel.")
- }),
- new Recipe(
- title: "Dinde au jambon", id: null,
- preparationSteps: new[]
- {
- new PreparationStep(1, "Faire une cuisson bien sec de la dinde à la poêle"),
- new PreparationStep(2, "Mettre la dinde au frigo."),
- new PreparationStep(3, "Mettre le jambon dans le micro-onde."),
- new PreparationStep(4, "Faire chauffer 3min."),
- new PreparationStep(5, "Présentez sur un plat la dinde et le jambon : Miam !")
- }),
- new Recipe(
- title: "Poulet au curry", id: null,
- preparationSteps: new[]
- {
- new PreparationStep(1, "Trouvez des épices de curry."),
- new PreparationStep(2, "Trouvez maintenant du poulet."),
- new PreparationStep(3, "Coupez la tête du poulet et posez-la dans un plat."),
- new PreparationStep(4, "Parsemez d'épices curry la tête de la poule."),
- new PreparationStep(5, "Mettre le tout au four traditionnel 30min."),
- new PreparationStep(6, "Dégustez en famille !")
- })
- })
- #endregion
- },
+using Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DataPersistence
+{
+ ///
+ /// The subs class is a group of prefabricated object that can only be loaded. It only use is for testing.
+ ///
+ public class Stubs : IDataManager
+ {
+ public Dictionary> Load()
+ {
+
+ Dictionary> data = new Dictionary>
+ {
{
- #region Data: User
- nameof(User),
+ #region Data: Recipes
+ nameof(Recipe),
+ new List(new[]
+ {
+ new Recipe(
+ title: "Cookies classiques", id: null,
+ preparationSteps: new[]
+ {
+ new PreparationStep(1, "Faire cuire."),
+ new PreparationStep(2, "Manger.")
+ }),
+ new Recipe(
+ title: "Cookies au chocolat", id: null,
+ preparationSteps: new[]
+ {
+ new PreparationStep(1, "Moulinez la pâte."),
+ new PreparationStep(2, "Faire cuire pendant une bonne heure."),
+ new PreparationStep(3, "Sortir du four et mettre dans un plat.")
+ }),
+ new Recipe(
+ title: "Gateau nature", id: null,
+ preparationSteps: new[]
+ {
+ new PreparationStep(1, "Achetez les ingrédients."),
+ new PreparationStep(2, "Préparez le matériel. Ustensiles et tout."),
+ new PreparationStep(3, "Pleurez.")
+ }),
+ new Recipe(
+ title: "Gateau au pommes", id: null,
+ preparationSteps: new[]
+ {
+ new PreparationStep(1, "Achetez les légumes."),
+ new PreparationStep(2, "Préparez le plat. Ustensiles et préchauffez le four."),
+ new PreparationStep(3, "Coupez les pommes en morceaux et disposez-les sur le plat."),
+ new PreparationStep(4, "Mettez enfin le plat au four, puis une fois cuit, dégustez !")
+ }),
+ new Recipe(
+ title: "Gateau au chocolat", id: null,
+ preparationSteps: new[]
+ {
+ new PreparationStep(1, "Ajouter les oeufs."),
+ new PreparationStep(2, "Ajouter la farine."),
+ new PreparationStep(3, "Ajouter 100g de chocolat fondu."),
+ new PreparationStep(4, "Mélanger le tout."),
+ new PreparationStep(5, "Faire cuire 45h au four traditionnel.")
+ }),
+ new Recipe(
+ title: "Dinde au jambon", id: null,
+ preparationSteps: new[]
+ {
+ new PreparationStep(1, "Faire une cuisson bien sec de la dinde à la poêle"),
+ new PreparationStep(2, "Mettre la dinde au frigo."),
+ new PreparationStep(3, "Mettre le jambon dans le micro-onde."),
+ new PreparationStep(4, "Faire chauffer 3min."),
+ new PreparationStep(5, "Présentez sur un plat la dinde et le jambon : Miam !")
+ }),
+ new Recipe(
+ title: "Poulet au curry", id: null,
+ preparationSteps: new[]
+ {
+ new PreparationStep(1, "Trouvez des épices de curry."),
+ new PreparationStep(2, "Trouvez maintenant du poulet."),
+ new PreparationStep(3, "Coupez la tête du poulet et posez-la dans un plat."),
+ new PreparationStep(4, "Parsemez d'épices curry la tête de la poule."),
+ new PreparationStep(5, "Mettre le tout au four traditionnel 30min."),
+ new PreparationStep(6, "Dégustez en famille !")
+ })
+ })
+ #endregion
+ },
+ {
+ #region Data: User
+ nameof(User),
new List(new[]
{
new User(
name: "Admin",
surname: "Admin",
mail: "admin@mctg.fr",
- password: passwordManager.HashPassword("admin")),
+ password: "admin"),
new User(
name: "Pedros",
surname: "Amigos",
mail: "pedrosamigos@hotmail.com",
- password: passwordManager.HashPassword("pamigos"))
+ password: "pamigos")
+
})
#endregion
- }
- };
-
- return data;
- }
-
- #region Not supported methods
- public void Save(Dictionary> elements)
- {
- throw new NotSupportedException();
- }
-
- public void Export(T obj, string pathToExport) where T : class
- {
- throw new NotSupportedException();
- }
-
- public KeyValuePair Import(string pathToImport) where T : class
- {
- throw new NotSupportedException();
- }
- #endregion
- }
-}
+ }
+ };
+
+ return data;
+ }
+
+ #region Not supported methods
+ public void Save(Dictionary> elements)
+ {
+ throw new NotSupportedException();
+ }
+
+ public void Export(T obj, string pathToExport) where T : class
+ {
+ throw new NotSupportedException();
+ }
+
+ public KeyValuePair Import(string pathToImport) where T : class
+ {
+ throw new NotSupportedException();
+ }
+ #endregion
+ }
+}
diff --git a/MCTG/Model/Recipes/Review.cs b/MCTG/Model/Recipes/Review.cs
index b98d498..d560d23 100644
--- a/MCTG/Model/Recipes/Review.cs
+++ b/MCTG/Model/Recipes/Review.cs
@@ -66,8 +66,7 @@ namespace Model
}
public Review(int stars, string content)
- : this(new User("admin", "admin", "admin@mctg.fr", new PasswordManager().HashPassword("admin")),
- null, stars, content)
+ : this(new User(), null, stars, content)
{
}
diff --git a/MCTG/Model/User/User.cs b/MCTG/Model/User/User.cs
index cbcb5e5..d8e4e09 100644
--- a/MCTG/Model/User/User.cs
+++ b/MCTG/Model/User/User.cs
@@ -17,7 +17,7 @@ namespace Model
/// This user can login with an Id and a password
///
[DataContract(Name = "user")]
- public class User : IEquatable , INotifyPropertyChanged
+ public class User : IEquatable , INotifyPropertyChanged
{
#region Private Attributes
@@ -40,12 +40,9 @@ namespace Model
public string Name
{
get { return name; }
- private set
+ set
{
- if (string.IsNullOrWhiteSpace(value))
- {
- throw new ArgumentException("Impossible d'avoir un champ Nom vide!");
- }
+
name = value;
OnPropertyChanged();
}
@@ -58,12 +55,9 @@ namespace Model
public string Surname
{
get { return surname; }
- private set
+ set
{
- if (string.IsNullOrWhiteSpace(value))
- {
- throw new ArgumentException("Impossible d'avoir un champ Prénom vide!");
- }
+
surname = value;
OnPropertyChanged();
}
@@ -147,7 +141,7 @@ namespace Model
return $"{Name} {Surname}";
}
-
+ public IPasswordManager psswMgr { get; private set; }
#endregion
@@ -161,12 +155,13 @@ namespace Model
/// The name of the user
/// The surname of the user
/// The user needs an email to login.
- public User(string name, string surname, string mail, int password)
+ public User(string name, string surname, string mail, string password, IPasswordManager passwordManager )
{
Name = name;
Surname = surname;
Mail = mail;
- Password = password;
+ psswMgr = passwordManager;
+ Password = psswMgr.HashPassword(password);
priorities = new List {
Priority.Gourmet,
Priority.Economic,
@@ -176,8 +171,30 @@ namespace Model
ProfilPict = picture;
}
+ public User(string name, string surname, string mail, string password)
+ : this(name, surname,mail, password, new PasswordManager())
+ {
+
+ }
+
+
+ public User()
+ : this("John", "Doe", "truc@gmail.com", "mdp")
+ {
+
+ }
+
+ public User (User user)
+ {
+ Name = user.Name;
+ Surname = user.Surname;
+ Mail = user.Mail;
+ psswMgr = user.psswMgr;
+ Password = user.Password;
+ priorities = user.Priorities;
+ ProfilPict = user.ProfilPict;
+ }
-
#endregion
diff --git a/MCTG/Views/App.xaml.cs b/MCTG/Views/App.xaml.cs
index 59c681f..0ae3fef 100644
--- a/MCTG/Views/App.xaml.cs
+++ b/MCTG/Views/App.xaml.cs
@@ -5,17 +5,20 @@ using Windows.Graphics;
#endif
using DataPersistence;
-
+using Model;
+
namespace Views
{
public partial class App : Application
{
public DataManager DataMgr { get; private set; } = new DataManager(new Stubs());
+ public User user { get; set; }
const int WindowWidth = 1200;
const int WindowHeight = 800;
public App()
- {
+ {
+ user = DataMgr.Data[nameof(User)].Cast().Last();
InitializeComponent();
Microsoft.Maui.Handlers.WindowHandler.Mapper.AppendToMapping(nameof(IWindow), (handler, view) =>
diff --git a/MCTG/Views/ContainerFlyout.xaml b/MCTG/Views/ContainerFlyout.xaml
index 0001b22..07193e3 100644
--- a/MCTG/Views/ContainerFlyout.xaml
+++ b/MCTG/Views/ContainerFlyout.xaml
@@ -28,11 +28,19 @@
Style="{StaticResource button2}"
IsVisible="{Binding IsNotConnected, Source={x:Reference fl}}"
IsEnabled="{Binding IsNotConnected, Source={x:Reference fl}}"/>
-
+
+
+
+
diff --git a/MCTG/Views/ContainerFlyout.xaml.cs b/MCTG/Views/ContainerFlyout.xaml.cs
index cde4145..6fcb273 100644
--- a/MCTG/Views/ContainerFlyout.xaml.cs
+++ b/MCTG/Views/ContainerFlyout.xaml.cs
@@ -5,17 +5,17 @@ namespace Views;
public partial class ContainerFlyout : ContentView
{
- public DataManager DataMgr => (App.Current as App).DataMgr;
- public User user { get; private set; }
+ public DataManager DataMgr => (App.Current as App).DataMgr;
+ public User user => (App.Current as App).user;
public ContainerFlyout()
- {
-
- InitializeComponent();
- BindingContext = this;
- user = DataMgr.Data[nameof(User)].Cast().Last();
-}
+ {
+ InitializeComponent();
+ BindingContext = this;
+
+
+ }
// Bind MyFlyoutContent
public static readonly BindableProperty MyFlyoutContentProperty =
diff --git a/MCTG/Views/MyProfil.xaml b/MCTG/Views/MyProfil.xaml
index 892693f..a51bc9c 100644
--- a/MCTG/Views/MyProfil.xaml
+++ b/MCTG/Views/MyProfil.xaml
@@ -36,30 +36,27 @@
Padding="50,0,0,0"
FontSize="18"/>
+ Margin="50,10,0,20"
+ Text="{Binding userBis.Name}"/>
+ Text="{Binding userBis.Surname} "/>
-
-
+ Text="{Binding user.Mail}"/>
+ MaximumWidthRequest="100"
+ Clicked="Validation_Click"/>
diff --git a/MCTG/Views/MyProfil.xaml.cs b/MCTG/Views/MyProfil.xaml.cs
index 314d681..3e89c68 100644
--- a/MCTG/Views/MyProfil.xaml.cs
+++ b/MCTG/Views/MyProfil.xaml.cs
@@ -1,21 +1,31 @@
+using CommunityToolkit.Maui.Behaviors;
using DataPersistence;
using Model;
-
+using System.Diagnostics;
+
namespace Views;
public partial class MyProfil : ContentPage
{
- public DataManager DataMgr = (App.Current as App).DataMgr;
- public User user { get; private set; }
-
+ public DataManager DataMgr => (App.Current as App).DataMgr;
+ public User user => (App.Current as App).user;
+ public User userBis {get; set; }
public MyProfil()
{
- DataMgr = new DataManager(new Stubs());
-
- user = DataMgr.Data[nameof(User)].Cast().Last();
+ userBis = new User(user);
InitializeComponent();
- BindingContext = user;
+ BindingContext = this;
+ }
+
+
+ public void Validation_Click(object sender, EventArgs e)
+ {
+ if (String.IsNullOrEmpty(userBis.Name) || String.IsNullOrEmpty(userBis.Surname)){
+ return;
+ }
+ user.Name = userBis.Name;
+ user.Surname = userBis.Surname;
}
}
\ No newline at end of file