|
|
|
@ -2,33 +2,31 @@
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
|
|
|
|
|
|
///https://learn.microsoft.com/fr-fr/windows/apps/design/
|
|
|
|
|
///https://learn.microsoft.com/fr-fr/windows/apps/design/layout/
|
|
|
|
|
///https://raw.githubusercontent.com/dotnet-architecture/eBooks/main/current/maui/Enterprise-Application-Patterns-Using-.NET-MAUI.pdf
|
|
|
|
|
///
|
|
|
|
|
namespace Biblioteque_de_Class
|
|
|
|
|
{
|
|
|
|
|
public class Utilisateur
|
|
|
|
|
{
|
|
|
|
|
private string Pseudo { get; set; }
|
|
|
|
|
private string Mail { get; set; }
|
|
|
|
|
private string Mdp { get; set; }
|
|
|
|
|
private string Password { get; set; }
|
|
|
|
|
private List<Note> NoteList;
|
|
|
|
|
private List<Tags> TagList;
|
|
|
|
|
private List<Note> FavList;
|
|
|
|
|
private bool connecté { get; set; }
|
|
|
|
|
private Map<Note, List<Tags>> NoteTaged;
|
|
|
|
|
|
|
|
|
|
public Utilisateur(string Upseudo, string Umail, string Upassword)
|
|
|
|
|
{
|
|
|
|
|
Pseudo = Upseudo;
|
|
|
|
|
Mail = Umail;
|
|
|
|
|
Mdp = Upassword;
|
|
|
|
|
Password = Upassword;
|
|
|
|
|
NoteList = new List<Note>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ToString() => $"pseudo : {Pseudo}\nmail : {Mail}\npassword : {Mdp}\nNote possédé : {NoteList.Count}";
|
|
|
|
|
|
|
|
|
|
public List<Note> RechercherNote(string name){
|
|
|
|
|
public List<Note> RechercherNote(string name)
|
|
|
|
|
{
|
|
|
|
|
List<Note> ListNotesearch = new List<Note>();
|
|
|
|
|
string search = name.Tolower();
|
|
|
|
|
foreach(Note note in NoteList){
|
|
|
|
@ -36,7 +34,8 @@ namespace Biblioteque_de_Class
|
|
|
|
|
}return ListNotesearch;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Note> RechercherNoteFav(string name){
|
|
|
|
|
public List<Note> RechercherNoteFav(string name)
|
|
|
|
|
{
|
|
|
|
|
List<Note> ListNotesearch = new List<Note>();
|
|
|
|
|
string search = name.Tolower();
|
|
|
|
|
foreach(Note note in FavList){
|
|
|
|
@ -44,7 +43,8 @@ namespace Biblioteque_de_Class
|
|
|
|
|
}return ListNotesearch;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Tags RechercherTags(string name){
|
|
|
|
|
public Tags RechercherTags(string name)
|
|
|
|
|
{
|
|
|
|
|
List<Tags> ListTagssearch = new List<Tags>();
|
|
|
|
|
string search = name.Tolower();
|
|
|
|
|
foreach(Tags tag in TagList){
|
|
|
|
@ -52,65 +52,97 @@ namespace Biblioteque_de_Class
|
|
|
|
|
}return ListTagssearch;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool AjouterFav(List<Note> ListFav, Note note)
|
|
|
|
|
public void AddFav(Note note)
|
|
|
|
|
{
|
|
|
|
|
foreach(Note notefav in ListFav)
|
|
|
|
|
foreach(Note notefav in FavList)
|
|
|
|
|
{
|
|
|
|
|
if (!notefav.Equals(note))
|
|
|
|
|
if (notefav.Equals(note))
|
|
|
|
|
{
|
|
|
|
|
ListFav.Add(note);
|
|
|
|
|
return true;
|
|
|
|
|
throw new Exception("Note already in favorite");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
FavList.Add(note);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool SuppFav(List<Note> ListFav, Note note)
|
|
|
|
|
public void SupFav(Note note)
|
|
|
|
|
{
|
|
|
|
|
foreach (Note notefav in ListFav)
|
|
|
|
|
foreach(Note notefav in FavList)
|
|
|
|
|
{
|
|
|
|
|
if (notefav.Nom.Equals(note))
|
|
|
|
|
if (notefav.Equals(note))
|
|
|
|
|
{
|
|
|
|
|
ListFav.Remove(note);
|
|
|
|
|
return true;
|
|
|
|
|
FavList.Remove(note);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
throw new Exception("Note not found");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AjouterNote(string nom, string LogoPath)
|
|
|
|
|
public void AddNote(string nom, string LogoPath)
|
|
|
|
|
{
|
|
|
|
|
foreach (Note note in NoteList)
|
|
|
|
|
{
|
|
|
|
|
if (note.Nom == nom)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Note already exist");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Note note = new Note(nom, LogoPath,this);
|
|
|
|
|
NoteList.Add(note);
|
|
|
|
|
NoteTaged.Add(note, new List<Tags>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SuppNote(Note note)
|
|
|
|
|
public void SupNote(Note note)
|
|
|
|
|
{
|
|
|
|
|
if (NoteList.Contains(note))
|
|
|
|
|
NoteList.Remove(note);
|
|
|
|
|
NoteTaged.Remove(note);
|
|
|
|
|
else
|
|
|
|
|
throw new Exception("Note not found");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void createTag(List<Tags> listNote, string name) {
|
|
|
|
|
foreach(Tags tag in listNote)
|
|
|
|
|
public void CreateTag(string name, string color)
|
|
|
|
|
{
|
|
|
|
|
foreach(Tags tag in TagList){
|
|
|
|
|
if(tag.Nom == name) { throw new Exception("Tag already exist"); }
|
|
|
|
|
}
|
|
|
|
|
TagList.Add(new Tags(name, color));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void DeleteTag(string name)
|
|
|
|
|
{
|
|
|
|
|
foreach(Tags tag in TagList){
|
|
|
|
|
if(tag.Nom == name) { TagList.Remove(tag); }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AddOneTagToNoteList(Note note, Tags tagtoadd)
|
|
|
|
|
{
|
|
|
|
|
if(ListTags.Contains(tagtoadd) == false) { throw new Exception("Tag not found"); }
|
|
|
|
|
if(NoteList.Contains(note) == false) { throw new Exception("Note not found"); }
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(tag.Nom == name)
|
|
|
|
|
{
|
|
|
|
|
atributionTag.Add(tag);
|
|
|
|
|
}
|
|
|
|
|
NoteTaged[note].Add(tagtoadd);
|
|
|
|
|
}
|
|
|
|
|
throw new Exception("no tag find with this name");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void deleteTag(string name)
|
|
|
|
|
public void SupOneTagToNoteList(Note note, Tags tagtosup)
|
|
|
|
|
{
|
|
|
|
|
foreach(Tags tag in atributionTag)
|
|
|
|
|
if(ListTags.Contains(tagtosup) == false) { throw new Exception("Tag not found"); }
|
|
|
|
|
if(NoteList.Contains(note) == false) { throw new Exception("Note not found"); }
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(tag.Nom == name)
|
|
|
|
|
{
|
|
|
|
|
atributionTag.Remove(tag);
|
|
|
|
|
}
|
|
|
|
|
NoteTaged[note].Remove(tagtosup);
|
|
|
|
|
}
|
|
|
|
|
throw new Exception("no tag find with this name");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AddTagToNoteList(Note note, List<Tags> listTags)
|
|
|
|
|
{
|
|
|
|
|
NoteTaged.Add(note, listTags);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SupTagToNoteList(Note note)
|
|
|
|
|
{
|
|
|
|
|
NoteTaged.Remove(note);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|