Fix code smell
continuous-integration/drone/push Build is failing Details

refonte_program
Matheo THIERRY 2 years ago
parent cff31cec4f
commit 8fcb08ed63

@ -15,7 +15,5 @@ namespace Biblioteque_de_Class
public void SaveUserData(User user);
public List<User> LoadUserData();
//public List<Note> LoadNote();
}
}

@ -1,262 +1,262 @@
using Microsoft.VisualBasic.FileIO;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace Biblioteque_de_Class
{
[DataContract]
public class User
{
[DataMember]
private string Username { get; set; }
[DataMember]
private string Email { get; set; }
[DataMember]
private string Password { get; set; }
[DataMember]
private List<Note> NoteList;
[DataMember]
private List<Tags> TagList;
[DataMember]
private List<Note> FavList;
[DataMember]
private bool IsConnected { get; set; }
[DataMember]
private Dictionary<Note, List<Tags>> NoteTagged;
public User(string username, string email, string password)
{
Username = username;
Email = email;
Password = password;
NoteList = new List<Note>();
TagList = new List<Tags>();
FavList = new List<Note>();
NoteTagged = new Dictionary<Note, List<Tags>>();
}
public string GetUsername() { return Username; }
public string GetEmail() { return Email; }
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 GetIsConnected() { return IsConnected; }
public Dictionary<Note, List<Tags>> GetNoteTagged() { return NoteTagged; }
public void SetUsername(string username) { Username = username; }
public void SetEmail(string email) { Email = email; }
public void SetPassword(string password) { Password = password; }
public void SetIsConnected(bool isConnected) { IsConnected = isConnected; }
public override string ToString() => $"username: {Username}\nemail: {Email}\npassword: {Password}\nOwned notes: {NoteList.Count}";
/// <summary>
/// rechercher une note dans la liste de note de l'utilisateur
/// </summary>
public List<Note> SearchNoteByName(string name)
{
List<Note> searchedNotes = new List<Note>();
string search = name.ToLower();
foreach (Note note in NoteList)
{
if (note.GetName().ToLower().Contains(search))
{
searchedNotes.Add(note);
}
}
return searchedNotes;
}
/// <summary>
/// rechercher une note dans la liste de note favoris de l'utilisateur
/// </summary>
public List<Note> SearchFavoriteNoteByName(string name)
{
List<Note> searchedNotes = new List<Note>();
string search = name.ToLower();
foreach (Note note in FavList)
{
if (note.GetName().ToLower().Contains(search))
{
searchedNotes.Add(note);
}
}
return searchedNotes;
}
/// <summary>
/// rechercher un tag dans la liste de tag de l'utilisateur
/// </summary>
public List<Tags> SearchTagByName(string name)
{
List<Tags> searchedTags = new List<Tags>();
string search = name.ToLower();
foreach (Tags tag in TagList)
{
if (tag.GetName().ToLower().Contains(search))
{
searchedTags.Add(tag);
}
}
return searchedTags;
}
public List<Note> SearchNoteByDate(List<Note> ToResearchIntoList, string name, DateOnly FirstDate, DateOnly SecondeDate)
{
List<Note> searchedNotes = new List<Note>();
string search = name.ToLower();
foreach (Note note in ToResearchIntoList)
{
if (note.GetName().ToLower().Contains(search) && note.GetCreationDate() >= FirstDate && note.GetCreationDate() <= SecondeDate)
{
searchedNotes.Add(note);
}
}
return searchedNotes;
}
/// <summary>
/// ajouter une note dans la liste de note favorite de l'utilisateur
/// </summary>
public void AddFavorite(Note note)
{
if (FavList.Contains(note))
{
throw new AlreadyExistException("Note already in favorites");
}
FavList.Add(note);
}
/// <summary>
/// supprimer une note dans la liste de note favorite de l'utilisateur
/// </summary>
public void RemoveFavorite(Note note)
{
if (FavList.Contains(note))
{
FavList.Remove(note);
}
else
{
throw new NotFoundException("Note not found");
}
}
/// <summary>
///creer une note
/// </summary>
public void CreateNote(string name, string imagePath)
{
foreach (Note existingNote in NoteList)
{
if (existingNote.GetName() == name)
{
throw new AlreadyExistException("Note already exists");
}
}
Note note = new Note(name, imagePath, this);
NoteList.Add(note);
NoteTagged.Add(note, new List<Tags>());
}
/// <summary>
/// supprimer une note
/// </summary>
public void DeleteNote(string name)
{
foreach (Note note in NoteList)
{
if (note.GetName() == name)
{
NoteList.Remove(note);
NoteTagged.Remove(note);
}
else
{
throw new NotFoundException("Note not found");
using Microsoft.VisualBasic.FileIO;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace Biblioteque_de_Class
{
[DataContract]
public class User
{
[DataMember]
private string Username { get; set; }
[DataMember]
private string Email { get; set; }
[DataMember]
private string Password { get; set; }
[DataMember]
private List<Note> NoteList;
[DataMember]
private List<Tags> TagList;
[DataMember]
private List<Note> FavList;
[DataMember]
private bool IsConnected { get; set; }
[DataMember]
private Dictionary<Note, List<Tags>> NoteTagged;
public User(string username, string email, string password)
{
Username = username;
Email = email;
Password = password;
NoteList = new List<Note>();
TagList = new List<Tags>();
FavList = new List<Note>();
NoteTagged = new Dictionary<Note, List<Tags>>();
}
public string GetUsername() { return Username; }
public string GetEmail() { return Email; }
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 GetIsConnected() { return IsConnected; }
public Dictionary<Note, List<Tags>> GetNoteTagged() { return NoteTagged; }
public void SetUsername(string username) { Username = username; }
public void SetEmail(string email) { Email = email; }
public void SetPassword(string password) { Password = password; }
public void SetIsConnected(bool isConnected) { IsConnected = isConnected; }
public override string ToString() => $"username: {Username}\nemail: {Email}\npassword: {Password}\nOwned notes: {NoteList.Count}";
/// <summary>
/// rechercher une note dans la liste de note de l'utilisateur
/// </summary>
public List<Note> SearchNoteByName(List<Note> ToResearchIntoList, string name)
{
List<Note> searchedNotes = new List<Note>();
string search = name.ToLower();
foreach (Note note in ToResearchIntoList)
{
if (note.GetName().ToLower().Contains(search))
{
searchedNotes.Add(note);
}
}
}
/// <summary>
/// creer un tag
/// </summary>
public void CreateTag(string name, string color)
{
foreach (Tags tag in TagList)
{
if (tag.GetName() == name)
{
throw new AlreadyExistException("Tag already exists");
}
}
TagList.Add(new Tags(name, color));
}
/// <summary>
/// supprimer un tag
/// </summary>
public void DeleteTag(string name)
{
foreach (Tags tag in TagList)
{
if (tag.GetName() == name)
{
TagList.Remove(tag);
return;
}
}
}
/// <summary>
/// ajouter un tag a une note
/// </summary>
public void AddTagToNoteList(Note note, Tags tagToAdd)
{
if (!TagList.Contains(tagToAdd))
{
throw new NotFoundException("Tag not found");
}
if (!NoteList.Contains(note))
{
throw new NotFoundException("Note not found");
}
NoteTagged[note].Add(tagToAdd);
}
/// <summary>
/// supprimer un tag a une note
/// </summary>
public void RemoveTagFromNoteList(Note note, Tags tagToRemove)
{
if (!TagList.Contains(tagToRemove))
{
throw new NotFoundException("Tag not found");
}
if (!NoteList.Contains(note))
{
throw new NotFoundException("Note not found");
}
NoteTagged[note].Remove(tagToRemove);
}
/// <summary>
/// ajouter plusieur tag a une note
/// </summary>
public void AddTagsToNoteList(Note note, List<Tags> tags)
{
NoteTagged.Add(note, tags);
}
/// <summary>
///supprimer tout les tags d'une note
/// </summary>
public void RemoveTagsFromNoteList(Note note)
{
NoteTagged.Remove(note);
}
}
}
return searchedNotes;
}
/// <summary>
/// rechercher une note dans la liste de note favoris de l'utilisateur
/// </summary>
public List<Note> SearchFavoriteNoteByName(List<Note> ToResearchIntoList, string name)
{
List<Note> searchedNotes = new List<Note>();
string search = name.ToLower();
foreach (Note note in ToResearchIntoList)
{
if (note.GetName().ToLower().Contains(search))
{
searchedNotes.Add(note);
}
}
return searchedNotes;
}
/// <summary>
/// rechercher un tag dans la liste de tag de l'utilisateur
/// </summary>
public List<Tags> SearchTagByName(List<Tags> ToResearchIntoList, string name)
{
List<Tags> searchedTags = new List<Tags>();
string search = name.ToLower();
foreach (Tags tag in ToResearchIntoList)
{
if (tag.GetName().ToLower().Contains(search))
{
searchedTags.Add(tag);
}
}
return searchedTags;
}
public List<Note> SearchNoteByDate(List<Note> ToResearchIntoList, string name, DateOnly FirstDate, DateOnly SecondeDate)
{
List<Note> searchedNotes = new List<Note>();
string search = name.ToLower();
foreach (Note note in ToResearchIntoList)
{
if (note.GetName().ToLower().Contains(search) && note.GetCreationDate() >= FirstDate && note.GetCreationDate() <= SecondeDate || note.GetModificationDate() >= FirstDate && note.GetModificationDate() <= SecondeDate)
{
searchedNotes.Add(note);
}
}
return searchedNotes;
}
/// <summary>
/// ajouter une note dans la liste de note favorite de l'utilisateur
/// </summary>
public void AddFavorite(Note note)
{
if (FavList.Contains(note))
{
throw new AlreadyExistException("Note already in favorites");
}
FavList.Add(note);
}
/// <summary>
/// supprimer une note dans la liste de note favorite de l'utilisateur
/// </summary>
public void RemoveFavorite(Note note)
{
if (FavList.Contains(note))
{
FavList.Remove(note);
}
else
{
throw new NotFoundException("Note not found");
}
}
/// <summary>
///creer une note
/// </summary>
public void CreateNote(string name, string imagePath)
{
foreach (Note existingNote in NoteList)
{
if (existingNote.GetName() == name)
{
throw new AlreadyExistException("Note already exists");
}
}
Note note = new Note(name, imagePath, this);
NoteList.Add(note);
NoteTagged.Add(note, new List<Tags>());
}
/// <summary>
/// supprimer une note
/// </summary>
public void DeleteNote(string note)
{
foreach (Note existingNote in NoteList)
{
if (existingNote.GetName() == note)
{
NoteList.Remove(existingNote);
NoteTagged.Remove(existingNote);
return;
}else
{
throw new NotFoundException("Note not found");
}
}
}
/// <summary>
/// creer un tag
/// </summary>
public void CreateTag(string name, string color)
{
foreach (Tags tag in TagList)
{
if (tag.GetName() == name)
{
throw new AlreadyExistException("Tag already exists");
}
}
TagList.Add(new Tags(name, color));
}
/// <summary>
/// supprimer un tag
/// </summary>
public void DeleteTag(string name)
{
foreach (Tags tag in TagList)
{
if (tag.GetName() == name)
{
TagList.Remove(tag);
return;
}
}
}
/// <summary>
/// ajouter un tag a une note
/// </summary>
public void AddTagToNoteList(Note note, Tags tagToAdd)
{
if (!TagList.Contains(tagToAdd))
{
throw new NotFoundException("Tag not found");
}
if (!NoteList.Contains(note))
{
throw new NotFoundException("Note not found");
}
NoteTagged[note].Add(tagToAdd);
}
/// <summary>
/// supprimer un tag a une note
/// </summary>
public void RemoveTagFromNoteList(Note note, Tags tagToRemove)
{
if (!TagList.Contains(tagToRemove))
{
throw new NotFoundException("Tag not found");
}
if (!NoteList.Contains(note))
{
throw new NotFoundException("Note not found");
}
NoteTagged[note].Remove(tagToRemove);
}
/// <summary>
/// ajouter plusieur tag a une note
/// </summary>
public void AddTagsToNoteList(Note note, List<Tags> tags)
{
NoteTagged.Add(note, tags);
}
/// <summary>
///supprimer tout les tags d'une note
/// </summary>
public void RemoveTagsFromNoteList(Note note)
{
NoteTagged.Remove(note);
}
}
}

@ -66,7 +66,7 @@ switch (Console.ReadLine())
}
//connection
while (connection == true)
while (connection)
{
connection = false;
Console.WriteLine("\nEntrez un nom : ");
@ -84,7 +84,7 @@ while (connection == true)
Console.WriteLine(ex.Message);
connection = true;
}
if (connection == false)
if (!connection)
{
if (Database.ComparePassword(u, password))
{
@ -98,11 +98,11 @@ while (connection == true)
u = uvide;
}
}
while (continuerboucle == true) { connection = continuer(); }
while (continuerboucle) { connection = continuer(); }
}
//inscription
while (inscription == true)
while (inscription)
{
Console.WriteLine("\nEntrez un nom :");
string? nom = Console.ReadLine();
@ -122,12 +122,12 @@ while (inscription == true)
break;
}
Console.WriteLine("\nNom d'utilisateur déjà utilisé. \n");
while (continuerboucle == true) { inscription = continuer(); }
while (continuerboucle) { inscription = continuer(); }
}
//une fois connecté ou inscription fait
while (u.GetIsConnected() == true)
while (u.GetIsConnected())
{
Console.WriteLine("\n|--------------------------------------|");
Console.WriteLine("| |");
@ -156,13 +156,13 @@ while (u.GetIsConnected() == true)
case "2":
Console.WriteLine("\nChoisissez le nom de la note (entrer - nom par defaut)");
string? wantedNameNote = Console.ReadLine();
if(wantedNameNote == null) { wantedNameNote = ""; }
wantedNameNote??= "";
u.CreateNote(wantedNameNote, "");
break;
case "3":
Console.WriteLine("\nChoisissez le nom de la note");
string? wantedDeleteNote = Console.ReadLine();
if (wantedDeleteNote == null) { wantedDeleteNote= ""; }
wantedDeleteNote??= "";
try
{
u.DeleteNote(wantedDeleteNote);
@ -184,7 +184,7 @@ while (u.GetIsConnected() == true)
break;
}
while (tags == true)
while (tags)
{
Console.WriteLine("\n|--------------------------------------|");
Console.WriteLine("| |");
@ -201,7 +201,7 @@ while (u.GetIsConnected() == true)
tags =false;
}
while(para == true)
while(para)
{
Console.WriteLine("\n|--------------------------------------|");
Console.WriteLine("| |");
@ -218,7 +218,7 @@ while (u.GetIsConnected() == true)
para = false;
}
while (theme == true)
while (theme)
{
Console.WriteLine("\n|--------------------------------------|");
Console.WriteLine("| |");

@ -19,9 +19,7 @@ namespace Notus_UnitTest_Database
[Test]
public void GetLogoLink_LogoExists_ReturnsLogoLink()
{
string logoName = "Logo2";
string logoLink = database.GetLogoLink(logoName);
Assert.That(logoLink, Is.EqualTo("link2"));
Assert.That(database.GetLogoLink("Logo2"), Is.EqualTo("link2"));
}
[Test]

Loading…
Cancel
Save