fix conflicts

pull/48/head
Alexandre AGOSTINHO 2 years ago
commit 31fec8e200

@ -1,16 +1,14 @@
// See https://aka.ms/new-console-template for more information
using ConsoleApp;
using ConsoleApp;
using Model;
using ConsoleApp.Menu;
using DataPersistence;
using Model;
using System.Linq;
using System.Text;
Console.WriteLine("Hello, World!\n\n");
// TESTS:
using System.Text;
Console.WriteLine("Hello, World!\n\n");
DataManager dataMgr = new DataManager(new Stubs());
//DataManager dataMgr = new DataManager(new DataContractXML());
//DataManager dataMgr = new DataManager(new DataContractJSON());
@ -39,10 +37,10 @@ User user = dataMgr.GetUsers().Last();
//rc[1].AddReview(new Review(user, 2, "Mais celle-ci oui !"));
dataMgr.Save();
MenuManager menuMgr = new MenuManager(dataMgr);
menuMgr.Loop();
Console.WriteLine(passwordManager.VerifyPassword(user.Password, "pamigos"));
Console.ReadKey();

@ -14,8 +14,6 @@ namespace DataPersistence
{
public Dictionary<string, List<object>> Load()
{
PasswordManager passwordManager = new PasswordManager();
Dictionary<string, List<object>> data = new Dictionary<string, List<object>>
{
{
@ -93,45 +91,46 @@ namespace DataPersistence
})
})
#endregion
},
},
{
#region Data: User
nameof(User),
#region Data: User
nameof(User),
new List<object>(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<string, List<object>> elements)
{
throw new NotSupportedException();
}
public void Export<T>(T obj, string pathToExport) where T : class
{
throw new NotSupportedException();
}
public KeyValuePair<string, T> Import<T>(string pathToImport) where T : class
{
throw new NotSupportedException();
}
#endregion
}
}
}
};
return data;
}
#region Not supported methods
public void Save(Dictionary<string, List<object>> elements)
{
throw new NotSupportedException();
}
public void Export<T>(T obj, string pathToExport) where T : class
{
throw new NotSupportedException();
}
public KeyValuePair<string, T> Import<T>(string pathToImport) where T : class
{
throw new NotSupportedException();
}
#endregion
}
}

@ -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)
{
}

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections;
@ -7,6 +8,7 @@ using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using System.Text;
using System.Runtime.Serialization;
using System.ComponentModel;
namespace Model
{
@ -15,7 +17,7 @@ namespace Model
/// This user can login with an Id and a password
/// </summary>
[DataContract(Name = "user")]
public class User : IEquatable<User>
public class User : IEquatable<User> , INotifyPropertyChanged
{
#region Private Attributes
@ -25,6 +27,8 @@ namespace Model
[DataMember] private string picture = "";
[DataMember] private int password ;
[DataMember] private List<Priority> priorities;
public event PropertyChangedEventHandler? PropertyChanged;
#endregion
#region Properties
@ -36,13 +40,11 @@ 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();
}
}
@ -53,13 +55,11 @@ 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();
}
}
@ -129,6 +129,21 @@ namespace Model
throw new NotImplementedException();
}
protected void OnPropertyChanged ([CallerMemberName] string? propertyName = null)
{
if (PropertyChanged != null)
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public override string ToString()
{
return $"{Name} {Surname}";
}
public IPasswordManager psswMgr { get; private set; }
#endregion
#region Constructors
@ -136,15 +151,18 @@ namespace Model
/// <summary>
/// Construtors of user.
/// </summary>
/// <param _name="name">The _name of the user</param>
/// <param _name="surname">The surname of the user</param>
/// <param _name="mail">The user needs an email to login. </param>
public User(string name, string surname, string mail, int password)
/// <param name="name">The name of the user</param>
/// <param name="surname">The surname of the user</param>
/// <param name="mail">The user needs an email to login.</param>
/// <param name="password">The password of the new user.</param>
/// <param name="passwordManager">The password manager to manage the user password.</param>
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> {
Priority.Gourmet,
Priority.Economic,
@ -155,8 +173,40 @@ namespace Model
}
/// <summary>
/// <inheritdoc cref="User.User"/>
/// </summary>
public User(string name, string surname, string mail, string password)
: this(name, surname,mail, password, new PasswordManager())
{
}
/// <summary>
/// <inheritdoc cref="User.User"/>
/// </summary>
public User()
: this("John", "Doe", "truc@gmail.com", "mdp")
{
}
/// <summary>
/// <inheritdoc cref="User.User"/>
/// </summary>
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
}
}

@ -13,7 +13,7 @@ namespace Model_UnitTests
public void TestConstructUser()
{
PasswordManager passwordManager = new PasswordManager();
User user = new User("Bob", "Dylan", "bd@gmail.com", passwordManager.HashPassword("bobby"));
User user = new User("Bob", "Dylan", "bd@gmail.com", "bobby");
Assert.Equal("Bob", user.Name);
Assert.Equal("Dylan", user.Surname);
Assert.Equal("bd@gmail.com", user.Mail);

@ -1,38 +1,44 @@
#if WINDOWS
using Microsoft.UI;
using Microsoft.UI.Windowing;
using Windows.Graphics;
#endif
namespace Views
{
public partial class App : Application
{
const int WindowWidth = 1200;
const int WindowHeight = 800;
public App()
{
InitializeComponent();
Microsoft.Maui.Handlers.WindowHandler.Mapper.AppendToMapping(nameof(IWindow), (handler, view) =>
{
#if WINDOWS
var mauiWindow = handler.VirtualView;
var nativeWindow = handler.PlatformView;
nativeWindow.Activate();
IntPtr windowHandle = WinRT.Interop.WindowNative.GetWindowHandle(nativeWindow);
WindowId windowId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(windowHandle);
AppWindow appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(windowId);
appWindow.Resize(new SizeInt32(WindowWidth, WindowHeight));
#endif
});
/* - Comment(ctrl-k + ctrl-c)/Uncomment(ctrl-k + ctrl-u) to change page - */
UserAppTheme = AppTheme.Light;
MainPage = new MyProfil();
//MainPage = new MyPosts();
}
}
}
#if WINDOWS
using Microsoft.UI;
using Microsoft.UI.Windowing;
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<User>().Last();
InitializeComponent();
Microsoft.Maui.Handlers.WindowHandler.Mapper.AppendToMapping(nameof(IWindow), (handler, view) =>
{
#if WINDOWS
var mauiWindow = handler.VirtualView;
var nativeWindow = handler.PlatformView;
nativeWindow.Activate();
IntPtr windowHandle = WinRT.Interop.WindowNative.GetWindowHandle(nativeWindow);
WindowId windowId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(windowHandle);
AppWindow appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(windowId);
appWindow.Resize(new SizeInt32(WindowWidth, WindowHeight));
#endif
});
/* - Comment(ctrl-k + ctrl-c)/Uncomment(ctrl-k + ctrl-u) to change page - */
UserAppTheme = AppTheme.Light;
MainPage = new AddRecipe();
//MainPage = new MyPosts();
}
}
}

@ -28,11 +28,19 @@
Style="{StaticResource button2}"
IsVisible="{Binding IsNotConnected, Source={x:Reference fl}}"
IsEnabled="{Binding IsNotConnected, Source={x:Reference fl}}"/>
<Label Text="Jean-Baptiste De La Fontaine"
HorizontalOptions="Center" Margin="15"
<StackLayout BindingContext="{Binding user}">
<Label Text="{Binding Name}"
HorizontalOptions="Center" Margin="0,15"
FontSize="20" FontAttributes="Bold" HorizontalTextAlignment="Center"
TextColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}"
IsVisible="{Binding IsNotConnected, Converter={toolkit:InvertedBoolConverter} ,Source={x:Reference fl}}"/>
<Label Text="{Binding Surname}"
HorizontalOptions="Center"
FontSize="20" FontAttributes="Bold" HorizontalTextAlignment="Center"
TextColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}"
IsVisible="{Binding IsNotConnected, Converter={toolkit:InvertedBoolConverter} ,Source={x:Reference fl}}"/>
</StackLayout>
</VerticalStackLayout>

@ -1,39 +1,49 @@
namespace Views;
public partial class ContainerFlyout : ContentView
{
public ContainerFlyout()
{
InitializeComponent();
}
// Bind MyFlyoutContent
public static readonly BindableProperty MyFlyoutContentProperty =
BindableProperty.Create("MyFlyoutContent", typeof(View), typeof(ContainerFlyout), new Grid());
public View MyFlyoutContent
{
get => (View)GetValue(MyFlyoutContentProperty);
set => SetValue(MyFlyoutContentProperty, value);
}
// Bind IsNotConnected
public static readonly BindableProperty IsNotConnectedProperty =
BindableProperty.Create("IsNotConnected", typeof(bool), typeof(Button), true);
public bool IsNotConnected
{
get => (bool)GetValue(IsNotConnectedProperty);
set => SetValue(IsNotConnectedProperty, value);
}
// bind NeedReturn
public static readonly BindableProperty NeedReturnProperty =
BindableProperty.Create("NeedReturn", typeof(bool), typeof(Border), false);
public bool NeedReturn
{
get => (bool)GetValue(NeedReturnProperty);
set => SetValue(NeedReturnProperty, value);
}
}
using DataPersistence;
using Model;
namespace Views;
public partial class ContainerFlyout : ContentView
{
public DataManager DataMgr => (App.Current as App).DataMgr;
public User user => (App.Current as App).user;
public ContainerFlyout()
{
InitializeComponent();
BindingContext = this;
}
// Bind MyFlyoutContent
public static readonly BindableProperty MyFlyoutContentProperty =
BindableProperty.Create("MyFlyoutContent", typeof(View), typeof(ContainerFlyout), new Grid());
public View MyFlyoutContent
{
get => (View)GetValue(MyFlyoutContentProperty);
set => SetValue(MyFlyoutContentProperty, value);
}
// Bind IsNotConnected
public static readonly BindableProperty IsNotConnectedProperty =
BindableProperty.Create("IsNotConnected", typeof(bool), typeof(Button), true);
public bool IsNotConnected
{
get => (bool)GetValue(IsNotConnectedProperty);
set => SetValue(IsNotConnectedProperty, value);
}
// bind NeedReturn
public static readonly BindableProperty NeedReturnProperty =
BindableProperty.Create("NeedReturn", typeof(bool), typeof(Border), false);
public bool NeedReturn
{
get => (bool)GetValue(NeedReturnProperty);
set => SetValue(NeedReturnProperty, value);
}
}

@ -14,8 +14,8 @@
<Grid RowDefinitions="250, *, *" VerticalOptions="Fill">
<VerticalStackLayout Grid.Row="1">
<Button Text="Mes informations" ImageSource="person_default.png" Style="{StaticResource button1}" Grid.Row="1"/>
<Button Text="Modifier" ImageSource="settings_icon.png" Style="{StaticResource button1}" Grid.Row="2"/>
<Button Text="Mes Recettes" ImageSource="person_default.png" Style="{StaticResource button1}" Grid.Row="1"/>
<Button Text="Ajouter Recette" ImageSource="settings_icon.png" Style="{StaticResource button1}" Grid.Row="2"/>
</VerticalStackLayout>
</Grid>
@ -24,7 +24,8 @@
<local:ContainerBase.MyContent>
<ScrollView>
<StackLayout BindingContext="User"><!--Attention debut de binding-->
<StackLayout >
<!--user's informations-->
<Label Text="Mon profil" TextColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource Gray100}}"
FontAttributes="Bold"
FontSize="24" Padding="15, 15, 20, 5"/>
@ -36,30 +37,28 @@
Padding="50,0,0,0"
FontSize="18"/>
<Entry BackgroundColor="#D1E8E2"
Margin="50,10,0,20"/>
Margin="50,10,0,20"
Text="{Binding userBis.Name}"/>
<Label Text="Prénom :"
Padding="50,0,0,0"
FontSize="18"/>
<Entry BackgroundColor="#D1E8E2"
Margin="50,10,0,20"/>
Margin="50,10,0,20"
Text="{Binding userBis.Surname} "/>
<Label Text="Mail :"
Padding="50,0,0,0"
FontSize="18"/>
<Entry BackgroundColor="#D1E8E2"
Margin="50,10,0,20"/>
<Label Text="Pseudo :"
Padding="50,0,0,0"
FontSize="18"/>
<Entry BackgroundColor="#D1E8E2"
Margin="50,10,0,50"/>
Margin="50,10,0,20"
IsEnabled="False"
Text="{Binding user.Mail}"/>
<Button BackgroundColor="#bdf5bd"
Text="Valider"
Text="Modifier"
Margin="40,0,0,0"
TextColor="Black"
MaximumWidthRequest="100"/>
MaximumWidthRequest="100"
Clicked="Validation_Click"/>
<!--liste drag and drop-->
</VerticalStackLayout>
<VerticalStackLayout Padding="100,0,0,0">
<Label Text="Priorités du compte : " TextColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource Gray100}}"
@ -67,44 +66,34 @@
<Grid BackgroundColor="#D1E8E2"
MinimumHeightRequest="300"
Padding="20">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Text="Recettes économiques" Grid.Row="0" Padding="5,0,0,0"/>
<BoxView Color="Black" HeightRequest="1" Margin="10,10,10,10" Grid.Row="1" />
<Label Text="Recettes rapides" Grid.Row="2"/>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Text="Recettes économiques" Grid.Row="0" Padding="5,0,0,0"/>
<BoxView Color="Black" HeightRequest="1" Margin="10,10,10,10" Grid.Row="1" />
<Label Text="Recettes rapides" Grid.Row="2"/>
<BoxView Color="Black" HeightRequest="1" Margin="10,10,10,10" Grid.Row="3" />
<Label Text="Recettes simples" Grid.Row="4"/>
<Label Text="Recettes simples" Grid.Row="4"/>
<BoxView Color="Black" HeightRequest="1" Margin="10,10,10,10" Grid.Row="5" />
<Label Text="Recettes légères" Grid.Row="6"/>
<Label Text="Recettes légères" Grid.Row="6"/>
<BoxView Color="Black" HeightRequest="1" Margin="10,10,10,10" Grid.Row="7" />
<Label Text="Recettes gourmandes" Grid.Row="8"/>
<Label Text="Recettes gourmandes" Grid.Row="8"/>
</Grid>
</VerticalStackLayout>
</HorizontalStackLayout>
</StackLayout>
</ScrollView>
</local:ContainerBase.MyContent>
</local:ContainerBase>
</ContentPage>

@ -1,9 +1,31 @@
namespace Views;
public partial class MyProfil : ContentPage
{
public MyProfil()
{
InitializeComponent();
}
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 => (App.Current as App).user;
public User userBis {get; set; }
public MyProfil()
{
userBis = new User(user);
InitializeComponent();
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;
}
}

@ -57,10 +57,14 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DataPersistence\DataPersistence.csproj" />
<ProjectReference Include="..\Model\Model.csproj" />
</ItemGroup>
<ItemGroup>
<MauiXaml Update="AddRecipe.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="ContainerBase.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>

Loading…
Cancel
Save