From aff1a84ff1ede0f12e1af364b0afc4961198aac6 Mon Sep 17 00:00:00 2001 From: "matheo.thierry" Date: Thu, 18 May 2023 10:31:40 +0200 Subject: [PATCH] =?UTF-8?q?transfers=20francais=20=C3=A0=20englais?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- notus/Biblioteque_de_Class/Database.cs | 182 +++++++---------- notus/Biblioteque_de_Class/Logo.cs | 18 +- notus/Biblioteque_de_Class/Note.cs | 124 ++++++------ notus/Biblioteque_de_Class/NoteImage.cs | 17 +- notus/Biblioteque_de_Class/Tags.cs | 19 +- notus/Biblioteque_de_Class/Theme.cs | 28 +-- notus/Biblioteque_de_Class/User.cs | 230 ++++++++++++++++++++++ notus/Biblioteque_de_Class/Utilisateur.cs | 202 ------------------- notus/Notus_Console/Program.cs | 6 +- 9 files changed, 411 insertions(+), 415 deletions(-) create mode 100644 notus/Biblioteque_de_Class/User.cs delete mode 100644 notus/Biblioteque_de_Class/Utilisateur.cs diff --git a/notus/Biblioteque_de_Class/Database.cs b/notus/Biblioteque_de_Class/Database.cs index 44d7da1..488b487 100644 --- a/notus/Biblioteque_de_Class/Database.cs +++ b/notus/Biblioteque_de_Class/Database.cs @@ -10,89 +10,81 @@ namespace Biblioteque_de_Class { public class Database { - private List ListDefaultLogo; - private List ListTheme; - private List ListUtilisateur; + private List DefaultLogoList; + private List ThemeList; + private List UserList; - public Database() - { - ListDefaultLogo = new List(); - ListTheme = new List(); - ListUtilisateur = new List(); + public Database() + { + DefaultLogoList = new List(); + ThemeList = new List(); + UserList = new List(); } - public List GetListDefaultLogo() { return ListDefaultLogo; } - public List GetListTheme() { return ListTheme; } - public List GetListUtilisateur() { return ListUtilisateur; } + public List GetDefaultLogoList() { return DefaultLogoList; } + public List GetThemeList() { return ThemeList; } + public List GetUserList() { return UserList; } /// /// recherche un utilisateur dans la liste d'utilisateur /// - public List RechercherUtilisateur(string name) + public List SearchUser(string name) { - List ListUserSearch = new List(); + List searchedUsers = new List(); string search = name.ToLower(); - foreach (Utilisateur user in ListUtilisateur) + foreach (User user in UserList) { - if (user.GetPseudo().ToLower().Contains(search)) { ListUserSearch.Add(user); } + if (user.GetUsername().ToLower().Contains(search)) { searchedUsers.Add(user); } } - return ListUserSearch; + return searchedUsers; } /// /// récupérer le lien d'un logo /// - public string GetLinkLogo(string Name) + public string GetLogoLink(string name) { - foreach (Logo logo in ListDefaultLogo) + foreach (Logo logo in DefaultLogoList) { - if (logo.GetNom() == Name) { return logo.GetNom(); } - }throw new Exception("no logo link find"); + if (logo.GetName() == name) { return logo.GetLink(); } + } + throw new Exception("No logo link found."); } /// /// récupérer un utilisateur /// - public Utilisateur GetUtilisateur(string Name) - { - foreach(Utilisateur user in ListUtilisateur){ - if(user.GetPseudo() == Name) + public User GetUser(string name) + { + foreach (User user in UserList) + { + if (user.GetUsername() == name) { return user; } - }throw new Exception("no user find with this pseudo"); + } + throw new Exception("No user found with this username."); } /// /// comparer le mot de passe entré avec celui de l'utilisateur /// - public bool CorrespondPassword(Utilisateur user, string Psd) + public bool ComparePassword(User user, string password) { - if (user.GetPassword() == Psd) - { - return true; - } - else - { - return false; - } + return user.GetPassword() == password; } /// /// rechercher un mail dans la liste d'utilisateur /// - public bool TrouverMail(string mail) + public bool FindEmail(string email) { - foreach (Utilisateur Mail in ListUtilisateur) + foreach (User user in UserList) { - if (string.Equals(mail,Mail)) + if (string.Equals(user.GetEmail(), email)) { return true; } - else - { - return false; - } } return false; } @@ -100,137 +92,115 @@ namespace Biblioteque_de_Class /// /// ajouter un utilisateur dans la liste d'utilisateur /// - public void AjouterUtilisateur(Utilisateur user) + public void AddUser(User user) { - foreach (Utilisateur user1 in ListUtilisateur) + foreach (User existingUser in UserList) { - if (user1.GetPseudo() == user.GetPseudo()) - { - throw new Exception("Pseudo déjà utilisé"); - } - else if (user1.GetMail() == user.GetMail()) + if (existingUser.GetUsername() == user.GetUsername()) { - throw new Exception("Mail déjà utilisé"); + throw new Exception("Username already used."); } - else + else if (existingUser.GetEmail() == user.GetEmail()) { - ListUtilisateur.Add(user); + throw new Exception("Email already used."); } } + UserList.Add(user); } /// /// supprimer un utilisateur dans la liste d'utilisateur /// - public void SupUtilisateur(Utilisateur user) + public void RemoveUser(User user) { - foreach (Utilisateur user1 in ListUtilisateur) + if (UserList.Contains(user)) { - if (user1.GetPseudo() == user.GetPseudo()) - { - ListUtilisateur.Remove(user); - } - else - { - throw new Exception("Utilisateur non trouvé"); - } + UserList.Remove(user); + } + else + { + throw new Exception("User not found."); } } /// /// ajouter un theme dans la liste de theme /// - public void AjouterTheme(Theme stheme) + public void AddTheme(Theme theme) { - List ListTheme = GetListTheme(); - foreach (Theme theme in ListTheme) + foreach (Theme existingTheme in ThemeList) { - if (theme.GetNom() == stheme.GetNom()) - { - throw new Exception("Theme déjà utilisé"); - } - else + if (existingTheme.GetName() == theme.GetName()) { - ListTheme.Add(stheme); + throw new Exception("Theme already used."); } } + ThemeList.Add(theme); } /// /// supprimer un theme dans la liste de theme /// - public void SupTheme(Theme stheme) + public void RemoveTheme(Theme theme) { - List ListTheme = GetListTheme(); - foreach (Theme theme in ListTheme) + if (ThemeList.Contains(theme)) { - if (theme.GetNom() == stheme.GetNom()) - { - ListTheme.Remove(theme); - } - else - { - throw new Exception("Theme non trouvé"); - } + ThemeList.Remove(theme); + } + else + { + throw new Exception("Theme not found."); } } /// /// récupérer un theme /// - public Theme GetTheme(string Name) + public Theme GetTheme(string name) { - List ListTheme = GetListTheme(); - foreach (Theme theme in ListTheme) + foreach (Theme theme in ThemeList) { - if (theme.GetNom() == Name) + if (theme.GetName() == name) { return theme; } } - throw new Exception("no theme find with this name"); + throw new Exception("No theme found with this name."); } /// /// modifier le nom d'un theme /// - public void ModifierNomTheme( Theme stheme, string NewName) + public void ModifyThemeName(Theme theme, string newName) { - foreach (Theme theme1 in ListTheme) + foreach (Theme existingTheme in ThemeList) { - if (theme1.GetNom() == stheme.GetNom()) - { - theme1.SetNom(NewName); - } - else + if (existingTheme.GetName() == theme.GetName()) { - throw new Exception("Theme non trouvé"); + existingTheme.SetName(newName); + return; } } + throw new Exception("Theme not found."); } /// /// modifier la liste de couleur d'un theme /// - public void ModifierColorListTheme(Theme stheme, List NewColorList) + public void ModifyThemeColorList(Theme theme, List newColorList) { - foreach (Theme theme1 in ListTheme) + foreach (Theme existingTheme in ThemeList) { - if (theme1.GetNom() == stheme.GetNom()) + if (existingTheme.GetName() == theme.GetName()) { for (int i = 0; i < 3; i++) { - theme1.ChangeColor(theme1.GetColor(i), NewColorList[i]); + existingTheme.ChangeColor(existingTheme.GetColor(i), newColorList[i]); } - } - else - { - throw new Exception("Theme non trouvé"); + return; } } + throw new Exception("Theme not found."); } - - - } -} +} \ No newline at end of file diff --git a/notus/Biblioteque_de_Class/Logo.cs b/notus/Biblioteque_de_Class/Logo.cs index baee17b..4fdb203 100644 --- a/notus/Biblioteque_de_Class/Logo.cs +++ b/notus/Biblioteque_de_Class/Logo.cs @@ -8,18 +8,18 @@ namespace Biblioteque_de_Class { public class Logo { - private string Nom { get; set; } - private string LinkLogo { get; set; } - - public Logo(string nom, string linklogo) + private string Name { get; set; } + private string LogoLink { get; set; } + + public Logo(string name, string logoLink) { - Nom = nom; - LinkLogo = linklogo; + Name = name; + LogoLink = logoLink; } - public string GetNom() { return Nom; } - public string GetLinkLogo() { return LinkLogo; } + public string GetName() { return Name; } + public string GetLogoLink() { return LogoLink; } - public override string ToString() => $"logo -> nom : {Nom}\nlink : {LinkLogo}"; + public override string ToString() => $"Logo -> Name: {Name}\nLink: {LogoLink}"; } } diff --git a/notus/Biblioteque_de_Class/Note.cs b/notus/Biblioteque_de_Class/Note.cs index 16e384d..c33f949 100644 --- a/notus/Biblioteque_de_Class/Note.cs +++ b/notus/Biblioteque_de_Class/Note.cs @@ -8,130 +8,130 @@ namespace Biblioteque_de_Class { public class Note { - private string Nom + private string Name { - get { return Nom; } - set { if (value == null) { Nom = "Note sans nom"; } else { Nom = value; } } + get { return Name; } + set { if (value == null) { Name = "Unnamed Note"; } else { Name = value; } } } ///private string Text { get; set; } Attribut pour le texte de la note - private string LogoPATH + private string LogoPath { - get { return LogoPATH; } - set { if (value == null) { LogoPATH = "PATH TO DEFAULT LOGO"; } else { LogoPATH = value; } } + get { return LogoPath; } + set { if (value == null) { LogoPath = "PATH TO DEFAULT LOGO"; } else { LogoPath = value; } } } - private DateOnly DateCreation { get;} - private DateOnly DateModif { get; set; } - private List listeImage; - private List listeLigneTexte; - private List cooperateurs; - private List editeurs; - private Utilisateur owner; - - public Note(string nom, string logoPATH, Utilisateur uOwner) + + private DateOnly CreationDate { get; } + private DateOnly ModificationDate { get; set; } + private List ImageList; + private List TextLineList; + private List Collaborators; + private List Editors; + private User Owner; + + public Note(string name, string logoPath, User owner) { - Nom = nom; - LogoPATH = logoPATH; - DateCreation = DateOnly.FromDateTime(DateTime.Now); - DateModif = DateOnly.FromDateTime(DateTime.Now); - listeImage = new List(); - listeLigneTexte = new List(); - cooperateurs = new List(); - editeurs = new List(); - - owner = uOwner; + Name = name; + LogoPath = logoPath; + CreationDate = DateOnly.FromDateTime(DateTime.Now); + ModificationDate = DateOnly.FromDateTime(DateTime.Now); + ImageList = new List(); + TextLineList = new List(); + Collaborators = new List(); + Editors = new List(); + + Owner = owner; } - public string GetNom() { return Nom; } - public string GetLogoPATH() { return LogoPATH; } - public DateOnly GetDateCreation() { return DateCreation; } - public DateOnly GetDateModif() { return DateModif; } - public List GetListeImage() { return listeImage; } - public List GetListeLigneTexte() { return listeLigneTexte; } - public List GetCooperateurs() { return cooperateurs; } - public List GetEditeurs() { return editeurs; } - public Utilisateur GetOwner() { return owner; } + public string GetName() { return Name; } + public string GetLogoPath() { return LogoPath; } + public DateOnly GetCreationDate() { return CreationDate; } + public DateOnly GetModificationDate() { return ModificationDate; } + public List GetImageList() { return ImageList; } + public List GetTextLineList() { return TextLineList; } + public List GetCollaborators() { return Collaborators; } + public List GetEditors() { return Editors; } + public User GetOwner() { return Owner; } - public override string ToString() => $"note -> nom : {Nom}\nlogoPATH : {LogoPATH}\nhow many line : {listeLigneTexte.Count()}"; + public override string ToString() => $"Note -> Name: {Name}\nLogoPath: {LogoPath}\nNumber of lines: {TextLineList.Count()}"; - public void ModifNom(string nom) { Nom = nom; } - public void ModifLogoPATH(string logoPATH) { LogoPATH = logoPATH; } - public void ModifDateModif() { DateModif = DateOnly.FromDateTime(DateTime.Now); } + public void ModifyName(string name) { Name = name; } + public void ModifyLogoPath(string logoPath) { LogoPath = logoPath; } + public void ModifyModificationDate() { ModificationDate = DateOnly.FromDateTime(DateTime.Now); } /// /// vérifier si l'utilisateur est le propriétaire de la note /// - public bool VerifOwner(Utilisateur user) + public bool VerifyOwner(User user) { - if (user == owner) { return true; } - else { return false; } + return user == Owner; } - public void AjouterImage(string linkImage, string position) + public void AddImage(string imageLink, string position) { - foreach (NoteImage image in this.GetListeImage()) + foreach (NoteImage image in ImageList) { - if (image.GetLinkImage() == linkImage) + if (image.GetImageLink() == imageLink) { - + /// Do something } } } - public void SuppImage(string image) + public void RemoveImage(string image) { - /// il faut une nouvelle structure pour pouvoir stocker les images + /// Need a new data structure to store images } /// /// vérifier si l'utilisateur est un éditeur de la note /// - public bool VerifPriviledge(Utilisateur user) + public bool VerifyPrivilege(User user) { - if (editeurs.Contains(user)) + if (Editors.Contains(user)) { return true; } else { - throw new Exception("user is not editeur"); + throw new Exception("User is not an editor"); } } /// /// ajouter un utilisateur en tant que coopérateur /// - public void AjouterCoop(Utilisateur owner, Utilisateur user) + public void AddCollaborator(User owner, User user) { - if (VerifOwner(owner)) { cooperateurs.Add(user); } - else { throw new Exception("user is not owner"); } + if (VerifyOwner(owner)) { Collaborators.Add(user); } + else { throw new Exception("User is not the owner"); } } /// /// supprimer un utilisateur en tant que coopérateur /// - public void SupCoop(Utilisateur owner, Utilisateur user) + public void RemoveCollaborator(User owner, User user) { - if (VerifOwner(owner)) { cooperateurs.Remove(user); } - else { throw new Exception("user is not owner"); } + if (VerifyOwner(owner)) { Collaborators.Remove(user); } + else { throw new Exception("User is not the owner"); } } /// /// passer un coopérateur en tant qu'éditeur /// - public void AjouterEdit(Utilisateur owner, Utilisateur user) + public void AddEditor(User owner, User user) { - if (VerifOwner(owner)) { editeurs.Add(user); } - else { throw new Exception("user is not owner"); } + if (VerifyOwner(owner)) { Editors.Add(user); } + else { throw new Exception("User is not the owner"); } } /// /// supprimer un coopérateur de la liste des éditeurs /// - public void SupEdit(Utilisateur owner, Utilisateur user) + public void RemoveEditor(User owner, User user) { - if (VerifOwner(owner)) { editeurs.Remove(user); } - else { throw new Exception("user is not owner"); } + if (VerifyOwner(owner)) { Editors.Remove(user); } + else { throw new Exception("User is not the owner"); } } } } diff --git a/notus/Biblioteque_de_Class/NoteImage.cs b/notus/Biblioteque_de_Class/NoteImage.cs index 1be20f7..db6f85d 100644 --- a/notus/Biblioteque_de_Class/NoteImage.cs +++ b/notus/Biblioteque_de_Class/NoteImage.cs @@ -8,22 +8,21 @@ namespace Biblioteque_de_Class { public class NoteImage { - private string Nom { get; set; } - private string LinkImage { get; set; } + private string Name { get; set; } + private string ImageLink { get; set; } private string Position { get; set; } - public NoteImage(string nom, string linkimage, string position) + public NoteImage(string name, string imageLink, string position) { - Nom = nom; - LinkImage = linkimage; + Name = name; + ImageLink = imageLink; Position = position; } - public string GetNom() { return Nom; } - public string GetLinkImage() { return LinkImage; } + public string GetName() { return Name; } + public string GetImageLink() { return ImageLink; } public string GetPosition() { return Position; } - public override string ToString() => $"image -> nom : {Nom}\nlink : {LinkImage}"; - + public override string ToString() => $"image -> name: {Name}\nlink: {ImageLink}"; } } diff --git a/notus/Biblioteque_de_Class/Tags.cs b/notus/Biblioteque_de_Class/Tags.cs index 991eab8..bf0181d 100644 --- a/notus/Biblioteque_de_Class/Tags.cs +++ b/notus/Biblioteque_de_Class/Tags.cs @@ -8,19 +8,18 @@ namespace Biblioteque_de_Class { public class Tags { - private string Nom { get; set; } - private string Couleur { get; set; } - - public Tags(string nom, string couleur) + private string Name { get; set; } + private string Color { get; set; } + + public Tags(string name, string color) { - Nom = nom; - Couleur = couleur; + Name = name; + Color = color; } - public string GetNom() { return Nom; } - public string GetCouleur() { return Couleur; } + public string GetName() { return Name; } + public string GetColor() { return Color; } - public override string ToString() => $"tag -> nom : {Nom}\ncouleur : {Couleur}"; - + public override string ToString() => $"tag -> name: {Name}\ncolor: {Color}"; } } diff --git a/notus/Biblioteque_de_Class/Theme.cs b/notus/Biblioteque_de_Class/Theme.cs index d19fc66..c4d2340 100644 --- a/notus/Biblioteque_de_Class/Theme.cs +++ b/notus/Biblioteque_de_Class/Theme.cs @@ -8,32 +8,32 @@ namespace Biblioteque_de_Class { public class Theme { - private string Nom { get; set; } - private List ListCouleur; + private string Name { get; set; } + private List ColorList; - public Theme(string nom, List listCouleur) + public Theme(string name, List colorList) { - Nom = nom; - ListCouleur = listCouleur; + Name = name; + ColorList = colorList; } - public string GetNom() { return Nom; } - public void SetNom(string nom) { Nom = nom; } - public List GetColorList() { return ListCouleur; } - public string GetColor(int code) { return ListCouleur[code]; } + public string GetName() { return Name; } + public void SetName(string name) { Name = name; } + public List GetColorList() { return ColorList; } + public string GetColor(int index) { return ColorList[index]; } - public override string ToString() => $"nom : {Nom} color 1: {ListCouleur[0]}\ncolor 2: {ListCouleur[1]}\ncolor 3: {ListCouleur[2]}\n"; + public override string ToString() => $"name: {Name}\ncolor 1: {ColorList[0]}\ncolor 2: {ColorList[1]}\ncolor 3: {ColorList[2]}\n"; /// - /// changer la couleur spécifique d'un theme + /// Change a specific color of the theme. /// public void ChangeColor(string color, string newColor) { - for (int i = 0; i < ListCouleur.Count; i++) + for (int i = 0; i < ColorList.Count; i++) { - if (ListCouleur[i] == color) + if (ColorList[i] == color) { - ListCouleur[i] = newColor; + ColorList[i] = newColor; } } } diff --git a/notus/Biblioteque_de_Class/User.cs b/notus/Biblioteque_de_Class/User.cs new file mode 100644 index 0000000..0a7cf80 --- /dev/null +++ b/notus/Biblioteque_de_Class/User.cs @@ -0,0 +1,230 @@ +using Microsoft.VisualBasic.FileIO; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Biblioteque_de_Class +{ + public class User + { + private string Username { get; set; } + private string Email { get; set; } + private string Password { get; set; } + private List NoteList; + private List TagList; + private List FavList; + private bool IsConnected { get; set; } + private Dictionary> NoteTagged; + + public User(string username, string email, string password) + { + Username = username; + Email = email; + Password = password; + NoteList = new List(); + TagList = new List(); + FavList = new List(); + NoteTagged = new Dictionary>(); + } + + public string GetUsername() { return Username; } + public string GetEmail() { return Email; } + public string GetPassword() { return Password; } + public List GetNoteList() { return NoteList; } + public List GetTagList() { return TagList; } + public List GetFavList() { return FavList; } + public bool GetIsConnected() { return IsConnected; } + public Dictionary> GetNoteTagged() { return NoteTagged; } + + public override string ToString() => $"username: {Username}\nemail: {Email}\npassword: {Password}\nOwned notes: {NoteList.Count}"; + + /// + /// rechercher une note dans la liste de note de l'utilisateur + /// + public List SearchNoteByName(string name) + { + List searchedNotes = new List(); + string search = name.ToLower(); + foreach (Note note in NoteList) + { + if (note.GetName().ToLower().Contains(search)) + { + searchedNotes.Add(note); + } + } + return searchedNotes; + } + + /// + /// rechercher une note dans la liste de note favoris de l'utilisateur + /// + public List SearchFavoriteNoteByName(string name) + { + List searchedNotes = new List(); + string search = name.ToLower(); + foreach (Note note in FavList) + { + if (note.GetName().ToLower().Contains(search)) + { + searchedNotes.Add(note); + } + } + return searchedNotes; + } + + /// + /// rechercher un tag dans la liste de tag de l'utilisateur + /// + public List SearchTagByName(string name) + { + List searchedTags = new List(); + string search = name.ToLower(); + foreach (Tags tag in TagList) + { + if (tag.GetName().ToLower().Contains(search)) + { + searchedTags.Add(tag); + } + } + return searchedTags; + } + + /// + /// ajouter une note dans la liste de note favorite de l'utilisateur + /// + public void AddFavorite(Note note) + { + if (FavList.Contains(note)) + { + throw new Exception("Note already in favorites"); + } + FavList.Add(note); + } + + /// + /// supprimer une note dans la liste de note favorite de l'utilisateur + /// + public void RemoveFavorite(Note note) + { + if (FavList.Contains(note)) + { + FavList.Remove(note); + } + else + { + throw new Exception("Note not found"); + } + } + + /// + ///creer une note + /// + public void CreateNote(string name, string imagePath) + { + foreach (Note existingNote in NoteList) + { + if (existingNote.GetName() == name) + { + throw new Exception("Note already exists"); + } + } + Note note = new Note(name, imagePath, this); + NoteList.Add(note); + NoteTagged.Add(note, new List()); + } + + /// + /// supprimer une note + /// + public void DeleteNote(Note note) + { + if (NoteList.Contains(note)) + { + NoteList.Remove(note); + NoteTagged.Remove(note); + } + else + { + throw new Exception("Note not found"); + } + } + + /// + /// creer un tag + /// + public void CreateTag(string name, string color) + { + foreach (Tags tag in TagList) + { + if (tag.GetName() == name) + { + throw new Exception("Tag already exists"); + } + } + TagList.Add(new Tags(name, color)); + } + + /// + /// supprimer un tag + /// + public void DeleteTag(string name) + { + foreach (Tags tag in TagList) + { + if (tag.GetName() == name) + { + TagList.Remove(tag); + return; + } + } + } + + /// + /// ajouter un tag a une note + /// + public void AddTagToNoteList(Note note, Tags tagToAdd) + { + if (!TagList.Contains(tagToAdd)) + { + throw new Exception("Tag not found"); + } + if (!NoteList.Contains(note)) + { + throw new Exception("Note not found"); + } + NoteTagged[note].Add(tagToAdd); + } + + /// + /// supprimer un tag a une note + /// + public void RemoveTagFromNoteList(Note note, Tags tagToRemove) + { + if (!TagList.Contains(tagToRemove)) + { + throw new Exception("Tag not found"); + } + if (!NoteList.Contains(note)) + { + throw new Exception("Note not found"); + } + NoteTagged[note].Remove(tagToRemove); + } + + /// + /// ajouter plusieur tag a une note + /// + public void AddTagsToNoteList(Note note, List tags) + { + NoteTagged.Add(note, tags); + } + + /// + ///supprimer tout les tags d'une note + /// + public void RemoveTagsFromNoteList(Note note) + { + NoteTagged.Remove(note); + } + + } +} \ No newline at end of file diff --git a/notus/Biblioteque_de_Class/Utilisateur.cs b/notus/Biblioteque_de_Class/Utilisateur.cs deleted file mode 100644 index 2d76578..0000000 --- a/notus/Biblioteque_de_Class/Utilisateur.cs +++ /dev/null @@ -1,202 +0,0 @@ -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 NoteList; - private List TagList; - private List FavList; - private bool connecte { get; set; } - private Dictionary> NoteTaged; - - public Utilisateur(string Upseudo, string Umail, string Upassword) - { - Pseudo = Upseudo; - Mail = Umail; - Password = Upassword; - NoteList = new List(); - TagList = new List(); - FavList = new List(); - NoteTaged = new Dictionary>(); - } - - public string GetPseudo() { return Pseudo; } - public string GetMail() { return Mail; } - public string GetPassword() { return Password; } - public List GetNoteList() { return NoteList; } - public List GetTagList() { return TagList; } - public List GetFavList() { return FavList; } - public bool GetConnecte() { return connecte; } - public Dictionary> GetNoteTaged() { return NoteTaged; } - - public override string ToString() => $"pseudo : {Pseudo}\nmail : {Mail}\npassword : {Password}\nNote possédé : {NoteList.Count}"; - - /// - /// rechercher une note dans la liste de note de l'utilisateur - /// - public List RechercherNote(string name) - { - List ListNotesearch = new List(); - string search = name.ToLower(); - foreach(Note note in NoteList){ - if(note.GetNom().ToLower().Contains(search)) { ListNotesearch.Add(note); } - }return ListNotesearch; - } - - /// - /// rechercher une note dans la liste de note favoris de l'utilisateur - /// - public List RechercherNoteFav(string name) - { - List ListNotesearch = new List(); - string search = name.ToLower(); - foreach(Note note in FavList){ - if(note.GetNom().ToLower().Contains(search)) { ListNotesearch.Add(note); } - }return ListNotesearch; - } - - /// - /// rechercher un tag dans la liste de tag de l'utilisateur - /// - public List RechercherTags(string name) - { - List ListTagssearch = new List(); - string search = name.ToLower(); - foreach(Tags tag in TagList){ - if(tag.GetNom().ToLower().Contains(search)) { ListTagssearch.Add(tag); } - } - return ListTagssearch; - } - - /// - /// ajouter une note dans la liste de note favorite de l'utilisateur - /// - public void AddFav(Note note) - { - foreach(Note notefav in FavList) - { - if (notefav.Equals(note)) - { - throw new Exception("Note already in favorite"); - } - } - FavList.Add(note); - } - - /// - /// supprimer une note dans la liste de note favorite de l'utilisateur - /// - public void SupFav(Note note) - { - foreach(Note notefav in FavList) - { - if (notefav.Equals(note)) - { - FavList.Remove(note); - } - } - throw new Exception("Note not found"); - } - - /// - ///creer une note - /// - 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()); - } - - /// - /// supprimer une note - /// - public void DeleteNote(Note note) - { - if (NoteList.Contains(note)) - { - NoteList.Remove(note); - NoteTaged.Remove(note); - } - else - throw new Exception("Note not found"); - } - - /// - /// creer un tag - /// - 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)); - } - - /// - /// supprimer un tag - /// - public void DeleteTag(string name) - { - foreach(Tags tag in TagList){ - if(tag.GetNom() == name) { TagList.Remove(tag); } - } - } - - /// - /// ajouter un tag a une note - /// - 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); - } - } - - /// - /// supprimer un tag a une note - /// - 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); - } - } - - /// - /// ajouter plusieur tag a une note - /// - public void AddTagToNoteList(Note note, List listTags) - { - NoteTaged.Add(note, listTags); - } - - /// - ///supprimer tout les tags d'une note - /// - public void SupTagToNoteList(Note note) - { - NoteTaged.Remove(note); - } - - } -} \ No newline at end of file diff --git a/notus/Notus_Console/Program.cs b/notus/Notus_Console/Program.cs index 5451fbf..b90abfe 100644 --- a/notus/Notus_Console/Program.cs +++ b/notus/Notus_Console/Program.cs @@ -25,10 +25,10 @@ string linkimage = "u"; List NewColorList; List listCouleurs; -Utilisateur user = new Utilisateur(Upseudo, Umail, Upassword); +User user = new User(Upseudo, Umail, Upassword); NoteImage image = new NoteImage(nom2, linkimage, position); Database db= new Database(); -Utilisateur u = new Utilisateur(Upseudo, Umail, Upassword); +User u = new User(Upseudo, Umail, Upassword); Note n = new Note(nom, logoPath, u); Tags t = new Tags(name, couleur); @@ -100,7 +100,7 @@ while (boucle == 0){ Umail = Console.ReadLine(); Console.WriteLine("Saisissez un mot de passe"); Upassword = Console.ReadLine(); - Utilisateur u1 = new Utilisateur(Upseudo, Umail, Upassword); + User u1 = new User(Upseudo, Umail, Upassword); db.AjouterUtilisateur(u1); break;