ADD and MODIF rajout de possiblement tout les méthodes et modif des noms et contenu de méthode

vSonar_test
Matheo THIERRY 2 years ago
parent a69e678340
commit 8a533beec2

File diff suppressed because it is too large Load Diff

@ -32,7 +32,7 @@ namespace Biblioteque_de_Class
return ListUserSearch; return ListUserSearch;
} }
public string? GetLinkLogo(string Name) public string GetLinkLogo(string Name)
{ {
foreach (Logo logo in ListDefaultLogo) foreach (Logo logo in ListDefaultLogo)
{ {
@ -40,9 +40,10 @@ namespace Biblioteque_de_Class
}throw new Exception("no logo link find"); }throw new Exception("no logo link find");
} }
public Utilisateur GetUtilisateur(string Name) { public Utilisateur GetUtilisateur(string Name)
{
foreach(Utilisateur user in ListUtilisateur){ foreach(Utilisateur user in ListUtilisateur){
if(user.Pseudo.get == Name) if(user.Pseudo == Name)
{ {
return user; return user;
} }
@ -51,9 +52,9 @@ namespace Biblioteque_de_Class
public bool CorrespondPassword(string Psd) public bool CorrespondPassword(string Psd)
{ {
foreach (Utilisateur Mdp in ListUtilisateur) foreach (Utilisateur user in ListUtilisateur)
{ {
if (string.Equals(Psd, Mdp)) if (string.Equals(Psd, user.Password))
{ {
return true; return true;
} }
@ -80,5 +81,112 @@ namespace Biblioteque_de_Class
} }
return false; return false;
} }
public void AjouterUtilisateur(Utilisateur user)
{
foreach (Utilisateur user1 in ListUtilisateur)
{
if (user1.Pseudo == user.Pseudo)
{
throw new Exception("Pseudo déjà utilisé");
}
else if (user1.Mail == user.Mail)
{
throw new Exception("Mail déjà utilisé");
}
else
{
ListUtilisateur.Add(user);
}
}
}
public void SupUtilisateur(Utilisateur user)
{
foreach (Utilisateur user1 in ListUtilisateur)
{
if (user1.Pseudo == user.Pseudo)
{
ListUtilisateur.Remove(user);
}
else
{
throw new Exception("Utilisateur non trouvé");
}
}
}
public void AjouterTheme(Theme stheme)
{
foreach (Theme theme in ListTheme)
{
if (theme.Nom == stheme.Nom)
{
throw new Exception("Theme déjà utilisé");
}
else
{
ListTheme.Add(stheme);
}
}
}
public void SupTheme(Theme stheme)
{
foreach (Theme theme in ListTheme)
{
if (theme.Nom == stheme.Nom)
{
ListTheme.Remove(theme);
}
else
{
throw new Exception("Theme non trouvé");
}
}
}
public Theme GetTheme(string Name)
{
foreach (Theme theme in ListTheme)
{
if (theme.Nom == Name)
{
return theme;
}
}
throw new Exception("no theme find with this name");
}
public void ModifierNomTheme( Theme stheme, string NewName)
{
foreach (Theme theme1 in ListTheme)
{
if (theme1.Nom == stheme.Nom)
{
theme1.Nom = NewName;
}
else
{
throw new Exception("Theme non trouvé");
}
}
}
public void ModifierColorListTheme(Theme stheme, List<string> NewColorList)
{
foreach (Theme theme1 in ListTheme)
{
if (theme1.Nom == stheme.Nom)
{
theme1.ListCouleur = NewColorList;
}
else
{
throw new Exception("Theme non trouvé");
}
}
}
} }
} }

@ -21,8 +21,7 @@ namespace Biblioteque_de_Class
set { if (value == null) { LogoPATH = "PATH TO DEFAULT LOGO"; } else { LogoPATH = value; } } set { if (value == null) { LogoPATH = "PATH TO DEFAULT LOGO"; } else { LogoPATH = value; } }
} }
private DateOnly DateCreation { get;} private DateOnly DateCreation { get;}
private DateOnly DateModif { get; set; }
public List<Tags> atributionTag;
public List<String> listeImage; public List<String> listeImage;
public List<String> listeLigneTexte; public List<String> listeLigneTexte;
public List<String> listePosiImage; public List<String> listePosiImage;
@ -35,96 +34,65 @@ namespace Biblioteque_de_Class
Nom = nom; Nom = nom;
LogoPATH = logoPATH; LogoPATH = logoPATH;
DateCreation = DateOnly.FromDateTime(DateTime.Now); DateCreation = DateOnly.FromDateTime(DateTime.Now);
DateModif = DateOnly.FromDateTime(DateTime.Now);
owner = uOwner; owner = uOwner;
} }
public override string ToString() => $"note -> nom : {Nom}\nlogoPATH : {LogoPATH}\nhow many line : {listeLigneTexte.Count()}"; public override string ToString() => $"note -> nom : {Nom}\nlogoPATH : {LogoPATH}\nhow many line : {listeLigneTexte.Count()}";
public void AjouterTag(List<Tags> listNote, string name) { public bool VerifOwner(Utilisateur user)
foreach(Tags tag in listNote){ {
if(tag.Nom == name) { atributionTag.Add(tag); }
}
throw new Exception("no tag find with this name");
}
public void EnleverTag(string name){
foreach(Tags tag in atributionTag){
if(tag.Nom == name) { atributionTag.Remove(tag); }
}
throw new Exception("no tag find with this name");
}
public bool VerifOwner(Utilisateur user) {
if (user == owner) { return true; } if (user == owner) { return true; }
else { return false; } else { return false; }
} }
public bool ModifRole(Utilisateur user,int choix) public bool ModifRole(Utilisateur user,int choix)
{ {
if (editeurs.Contains(user)) }
{
editeurs.Remove(user);
cooperateurs.Add(user);
return true;
}
if (cooperateurs.Contains(user) && choix==1)
{
cooperateurs.Remove(user);
editeurs.Add(user);
return true;
}
else
{
cooperateurs.Remove(user);
}
return false; public void AjouterImage(string image)
{
} }
public bool AjouterImage(string image) public void SuppImage(string image)
{ {
if (listeImage.Contains(image))
{
return false;
}
else
{
return true;
}
} }
public bool SuppImage(string image)
public bool VerifPriviledge(Utilisateur user)
{ {
if (listeImage.Contains(image)) if (editeurs.Contains(user))
{ {
listeImage.Remove(image); return True;
return true;
} }
else else
{ {
return false; throw new Exception("user is not editeur");
} }
} }
public void AjouterCoop(Utilisateur user) { public void AjouterCoop(Utilisateur owner, Utilisateur user)
if (VerifOwner(user)) { cooperateurs.Add(user); } {
if (VerifOwner(owner)) { cooperateurs.Add(user); }
else { throw new Exception("user is not owner"); } else { throw new Exception("user is not owner"); }
} }
public void SupCoop(Utilisateur user) { public void SupCoop(Utilisateur owner, Utilisateur user)
if (VerifOwner(user)) { cooperateurs.Remove(user); } {
if (VerifOwner(owner)) { cooperateurs.Remove(user); }
else { throw new Exception("user is not owner"); } else { throw new Exception("user is not owner"); }
} }
public void AjouterEdit(Utilisateur user) { public void AjouterEdit(Utilisateur owner, Utilisateur user)
if (VerifOwner(user)) { editeurs.Add(user); } {
if (VerifOwner(owner)) { editeurs.Add(user); }
else { throw new Exception("user is not owner"); } else { throw new Exception("user is not owner"); }
} }
public void SupEdit(Utilisateur user) { public void SupEdit(Utilisateur owner, Utilisateur user)
if (VerifOwner(user)) { editeurs.Remove(user); } {
if (VerifOwner(owner)) { editeurs.Remove(user); }
else { throw new Exception("user is not owner"); } else { throw new Exception("user is not owner"); }
} }
} }
} }

@ -8,20 +8,12 @@ namespace Biblioteque_de_Class
{ {
public class Tags public class Tags
{ {
public string Nom { get; set; } private string Nom { get; set; }
public string Couleur { get; set; } private string Couleur { get; set; }
public Tags(string nom, string couleur)
{
Nom = nom;
Couleur = couleur;
}
public void ChangerNom(string nom) public Tags(string nom, string couleur)
{ {
Nom = nom; Nom = nom;
}
public void ChangerCouleur(string couleur)
{
Couleur = couleur; Couleur = couleur;
} }

@ -9,27 +9,22 @@ namespace Biblioteque_de_Class
public class Theme public class Theme
{ {
public string Nom { get; set; } public string Nom { get; set; }
List<String> ListCouleur; List<string> ListCouleur;
public Theme(string nom, List<String> listCouleur) public Theme(string nom, List<string> listCouleur)
{ {
Nom = nom; Nom = nom;
ListCouleur = List<String> listCouleur; ListCouleur = List<string>({ "#red", "#blue", "#green" });
} }
public override string ToString() => $"nom : {Nom} color 1: {Listcouleur[0]}\ncolor 2: {Listcouleur[1]}\ncolor 3: {Listcouleur[2]}\n"; public override string ToString() => $"nom : {Nom} color 1: {Listcouleur[0]}\ncolor 2: {Listcouleur[1]}\ncolor 3: {Listcouleur[2]}\n";
public List<String> GetColorList() public List<string> GetColorList()
{ {
return ListCouleur; return ListCouleur;
} }
public void ModifListColor(List<String> listColor) public void ChangeColor(string color, string newColor)
{
ListCouleur = listColor;
}
public void ChangeColor(String color, String newColor)
{ {
int longueur = 0; int longueur = 0;
for (longueur = ListCouleur.Count; longueur != 0; longueur-- ) for (longueur = ListCouleur.Count; longueur != 0; longueur-- )

@ -2,33 +2,31 @@
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema; 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 namespace Biblioteque_de_Class
{ {
public class Utilisateur public class Utilisateur
{ {
private string Pseudo { get; set; } private string Pseudo { get; set; }
private string Mail { get; set; } private string Mail { get; set; }
private string Mdp { get; set; } private string Password { get; set; }
private List<Note> NoteList; private List<Note> NoteList;
private List<Tags> TagList; private List<Tags> TagList;
private List<Note> FavList; private List<Note> FavList;
private bool connecté { get; set; } private bool connecté { get; set; }
private Map<Note, List<Tags>> NoteTaged;
public Utilisateur(string Upseudo, string Umail, string Upassword) public Utilisateur(string Upseudo, string Umail, string Upassword)
{ {
Pseudo = Upseudo; Pseudo = Upseudo;
Mail = Umail; Mail = Umail;
Mdp = Upassword; Password = Upassword;
NoteList = new List<Note>(); NoteList = new List<Note>();
} }
public override string ToString() => $"pseudo : {Pseudo}\nmail : {Mail}\npassword : {Mdp}\nNote possédé : {NoteList.Count}"; 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>(); List<Note> ListNotesearch = new List<Note>();
string search = name.Tolower(); string search = name.Tolower();
foreach(Note note in NoteList){ foreach(Note note in NoteList){
@ -36,7 +34,8 @@ namespace Biblioteque_de_Class
}return ListNotesearch; }return ListNotesearch;
} }
public List<Note> RechercherNoteFav(string name){ public List<Note> RechercherNoteFav(string name)
{
List<Note> ListNotesearch = new List<Note>(); List<Note> ListNotesearch = new List<Note>();
string search = name.Tolower(); string search = name.Tolower();
foreach(Note note in FavList){ foreach(Note note in FavList){
@ -44,7 +43,8 @@ namespace Biblioteque_de_Class
}return ListNotesearch; }return ListNotesearch;
} }
public Tags RechercherTags(string name){ public Tags RechercherTags(string name)
{
List<Tags> ListTagssearch = new List<Tags>(); List<Tags> ListTagssearch = new List<Tags>();
string search = name.Tolower(); string search = name.Tolower();
foreach(Tags tag in TagList){ foreach(Tags tag in TagList){
@ -52,65 +52,97 @@ namespace Biblioteque_de_Class
}return ListTagssearch; }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); throw new Exception("Note already in favorite");
return true;
} }
} }
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); FavList.Remove(note);
return true;
} }
} }
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); Note note = new Note(nom, LogoPath,this);
NoteList.Add(note); NoteList.Add(note);
NoteTaged.Add(note, new List<Tags>());
} }
public void SuppNote(Note note) public void SupNote(Note note)
{ {
if (NoteList.Contains(note)) if (NoteList.Contains(note))
NoteList.Remove(note); NoteList.Remove(note);
NoteTaged.Remove(note);
else
throw new Exception("Note not found");
} }
public void createTag(List<Tags> listNote, string name) { public void CreateTag(string name, string color)
foreach(Tags tag in listNote) {
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) NoteTaged[note].Add(tagtoadd);
{
atributionTag.Add(tag);
}
} }
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) NoteTaged[note].Remove(tagtosup);
{
atributionTag.Remove(tag);
}
} }
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);
}
} }
} }
Loading…
Cancel
Save