using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Biblioteque_de_Class { public class Note { private string Name { 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 { get { return LogoPath; } set { if (value == null) { LogoPath = "PATH TO DEFAULT LOGO"; } else { LogoPath = value; } } } 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) { 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 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 -> Name: {Name}\nLogoPath: {LogoPath}\nNumber of lines: {TextLineList.Count()}"; public void SetName(string name) { Name = name; } public void SetLogoPath(string logoPath) { LogoPath = logoPath; } public void SetModificationDate() { ModificationDate = DateOnly.FromDateTime(DateTime.Now); } /// /// vérifier si l'utilisateur est le propriétaire de la note /// public bool VerifyOwner(User user) { return user == Owner; } public void AddImage(string imageLink, string position) { foreach (NoteImage image in ImageList) { if (image.GetImageLink() == imageLink) { /// Do something } } } public void RemoveImage(string image) { /// Need a new data structure to store images } /// /// vérifier si l'utilisateur est un éditeur de la note /// public bool VerifyPrivilege(User user) { if (Editors.Contains(user)) { return true; } else { throw new Exception("User is not an editor"); } } /// /// ajouter un utilisateur en tant que coopérateur /// public void AddCollaborator(User owner, User user) { 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 RemoveCollaborator(User owner, User user) { 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 AddEditor(User owner, User user) { 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 RemoveEditor(User owner, User user) { if (VerifyOwner(owner)) { Editors.Remove(user); } else { throw new Exception("User is not the owner"); } } } }