You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
202 lines
6.6 KiB
202 lines
6.6 KiB
using Microsoft.VisualBasic.FileIO;
|
|
using System.ComponentModel;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace Biblioteque_de_Class
|
|
{
|
|
public class Utilisateur
|
|
{
|
|
private string Pseudo { get; set; }
|
|
private string Mail { get; set; }
|
|
private string Password { get; set; }
|
|
private List<Note> NoteList;
|
|
private List<Tags> TagList;
|
|
private List<Note> FavList;
|
|
private bool connecte { get; set; }
|
|
private Dictionary<Note, List<Tags>> NoteTaged;
|
|
|
|
public Utilisateur(string Upseudo, string Umail, string Upassword)
|
|
{
|
|
Pseudo = Upseudo;
|
|
Mail = Umail;
|
|
Password = Upassword;
|
|
NoteList = new List<Note>();
|
|
TagList = new List<Tags>();
|
|
FavList = new List<Note>();
|
|
NoteTaged = new Dictionary<Note, List<Tags>>();
|
|
}
|
|
|
|
public string GetPseudo() { return Pseudo; }
|
|
public string GetMail() { return Mail; }
|
|
public string GetPassword() { return Password; }
|
|
public List<Note> GetNoteList() { return NoteList; }
|
|
public List<Tags> GetTagList() { return TagList; }
|
|
public List<Note> GetFavList() { return FavList; }
|
|
public bool GetConnecte() { return connecte; }
|
|
public Dictionary<Note, List<Tags>> GetNoteTaged() { return NoteTaged; }
|
|
|
|
public override string ToString() => $"pseudo : {Pseudo}\nmail : {Mail}\npassword : {Password}\nNote possédé : {NoteList.Count}";
|
|
|
|
/// <summary>
|
|
/// rechercher une note dans la liste de note de l'utilisateur
|
|
/// </summary>
|
|
public List<Note> RechercherNote(string name)
|
|
{
|
|
List<Note> ListNotesearch = new List<Note>();
|
|
string search = name.ToLower();
|
|
foreach(Note note in NoteList){
|
|
if(note.GetNom().ToLower().Contains(search)) { ListNotesearch.Add(note); }
|
|
}return ListNotesearch;
|
|
}
|
|
|
|
/// <summary>
|
|
/// rechercher une note dans la liste de note favoris de l'utilisateur
|
|
/// </summary>
|
|
public List<Note> RechercherNoteFav(string name)
|
|
{
|
|
List<Note> ListNotesearch = new List<Note>();
|
|
string search = name.ToLower();
|
|
foreach(Note note in FavList){
|
|
if(note.GetNom().ToLower().Contains(search)) { ListNotesearch.Add(note); }
|
|
}return ListNotesearch;
|
|
}
|
|
|
|
/// <summary>
|
|
/// rechercher un tag dans la liste de tag de l'utilisateur
|
|
/// </summary>
|
|
public List<Tags> RechercherTags(string name)
|
|
{
|
|
List<Tags> ListTagssearch = new List<Tags>();
|
|
string search = name.ToLower();
|
|
foreach(Tags tag in TagList){
|
|
if(tag.GetNom().ToLower().Contains(search)) { ListTagssearch.Add(tag); }
|
|
}
|
|
return ListTagssearch;
|
|
}
|
|
|
|
/// <summary>
|
|
/// ajouter une note dans la liste de note favorite de l'utilisateur
|
|
/// </summary>
|
|
public void AddFav(Note note)
|
|
{
|
|
foreach(Note notefav in FavList)
|
|
{
|
|
if (notefav.Equals(note))
|
|
{
|
|
throw new Exception("Note already in favorite");
|
|
}
|
|
}
|
|
FavList.Add(note);
|
|
}
|
|
|
|
/// <summary>
|
|
/// supprimer une note dans la liste de note favorite de l'utilisateur
|
|
/// </summary>
|
|
public void SupFav(Note note)
|
|
{
|
|
foreach(Note notefav in FavList)
|
|
{
|
|
if (notefav.Equals(note))
|
|
{
|
|
FavList.Remove(note);
|
|
}
|
|
}
|
|
throw new Exception("Note not found");
|
|
}
|
|
|
|
/// <summary>
|
|
///creer une note
|
|
/// </summary>
|
|
public void CreateNote(string nom, string LogoPath)
|
|
{
|
|
foreach (Note eachnote in NoteList)
|
|
{
|
|
if (eachnote.GetNom() == nom)
|
|
{
|
|
throw new Exception("Note already exist");
|
|
}
|
|
}
|
|
Note note = new Note(nom, LogoPath,this);
|
|
NoteList.Add(note);
|
|
NoteTaged.Add(note, new List<Tags>());
|
|
}
|
|
|
|
/// <summary>
|
|
/// supprimer une note
|
|
/// </summary>
|
|
public void DeleteNote(Note note)
|
|
{
|
|
if (NoteList.Contains(note))
|
|
{
|
|
NoteList.Remove(note);
|
|
NoteTaged.Remove(note);
|
|
}
|
|
else
|
|
throw new Exception("Note not found");
|
|
}
|
|
|
|
/// <summary>
|
|
/// creer un tag
|
|
/// </summary>
|
|
public void CreateTag(string name, string color)
|
|
{
|
|
foreach(Tags tag in TagList){
|
|
if(tag.GetNom() == name) { throw new Exception("Tag already exist"); }
|
|
}
|
|
TagList.Add(new Tags(name, color));
|
|
}
|
|
|
|
/// <summary>
|
|
/// supprimer un tag
|
|
/// </summary>
|
|
public void DeleteTag(string name)
|
|
{
|
|
foreach(Tags tag in TagList){
|
|
if(tag.GetNom() == name) { TagList.Remove(tag); }
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// ajouter un tag a une note
|
|
/// </summary>
|
|
public void AddOneTagToNoteList(Note note, Tags tagtoadd)
|
|
{
|
|
if (TagList.Contains(tagtoadd) == false) { throw new Exception("Tag not found"); }
|
|
if(NoteList.Contains(note) == false) { throw new Exception("Note not found"); }
|
|
else
|
|
{
|
|
NoteTaged[note].Add(tagtoadd);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// supprimer un tag a une note
|
|
/// </summary>
|
|
public void SupOneTagToNoteList(Note note, Tags tagtosup)
|
|
{
|
|
if (TagList.Contains(tagtosup) == false) { throw new Exception("Tag not found"); }
|
|
if(NoteList.Contains(note) == false) { throw new Exception("Note not found"); }
|
|
else
|
|
{
|
|
NoteTaged[note].Remove(tagtosup);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// ajouter plusieur tag a une note
|
|
/// </summary>
|
|
public void AddTagToNoteList(Note note, List<Tags> listTags)
|
|
{
|
|
NoteTaged.Add(note, listTags);
|
|
}
|
|
|
|
/// <summary>
|
|
///supprimer tout les tags d'une note
|
|
/// </summary>
|
|
public void SupTagToNoteList(Note note)
|
|
{
|
|
NoteTaged.Remove(note);
|
|
}
|
|
|
|
}
|
|
} |