Fix : blabla code smells
continuous-integration/drone/push Build is failing Details

Popup_qui_marche_pas
Jade VAN BRABANDT 2 years ago
parent 079bf87015
commit eeb1b8054b

@ -29,7 +29,7 @@ namespace StimPersistance
throw new NotImplementedException(); throw new NotImplementedException();
} }
public ObservableCollection<Game> LoadGame() public ObservableCollection<Game>? LoadGame()
{ {
if (File.Exists("games.xml")) if (File.Exists("games.xml"))
{ {

@ -75,7 +75,7 @@ namespace Model
public float Average { get; private set; } public float Average { get; private set; }
[DataMember] [DataMember]
public string? Lien { public string Lien {
get => lien; get => lien;
private set private set
{ {
@ -83,7 +83,7 @@ namespace Model
lien = value; lien = value;
} }
} }
private string? lien; private string lien;
public Game(string name, string description, int year, List<string> c_tags, string cover, string c_lien) public Game(string name, string description, int year, List<string> c_tags, string cover, string c_lien)
{ {
@ -106,6 +106,7 @@ namespace Model
public override int GetHashCode() public override int GetHashCode()
{ {
if (string.IsNullOrWhiteSpace(Name)) return 0;
return Name.GetHashCode(); return Name.GetHashCode();
} }
@ -119,6 +120,7 @@ namespace Model
public bool Equals(Game? other) public bool Equals(Game? other)
{ {
if (string.IsNullOrWhiteSpace(Name)) return false;
return other != null && Name.Equals(other.Name); return other != null && Name.Equals(other.Name);
} }

@ -4,25 +4,26 @@ namespace Model
{ {
public class Manager public class Manager
{ {
public IPersistance _persistance; public IPersistance persistance;
public ObservableCollection<Game> GameList { get;} public ObservableCollection<Game> GameList { get;}
public Manager(IPersistance persistance) public Manager(IPersistance persistance)
{ {
_persistance = persistance; persistance = persistance;
GameList = persistance.LoadGame(); GameList = persistance.LoadGame();
if (GameList == null) { GameList = new ObservableCollection<Game>();}
} }
public void AddGametoGamesList(Game game) public void AddGametoGamesList(Game game)
{ {
GameList.Add(game); GameList.Add(game);
_persistance.SaveGame(GameList); persistance.SaveGame(GameList);
} }
public void RemoveGameFromGamesList(Game game) public void RemoveGameFromGamesList(Game game)
{ {
GameList.Remove(game); GameList.Remove(game);
_persistance.SaveGame(GameList); persistance.SaveGame(GameList);
} }
/*public void LoadGames() /*public void LoadGames()
@ -31,7 +32,7 @@ namespace Model
}*/ }*/
public void SaveGames() public void SaveGames()
{ {
_persistance.SaveGame(GameList); persistance.SaveGame(GameList);
} }
} }
} }

@ -51,8 +51,8 @@ namespace Model
} }
private string? password; private string? password;
public int Role { get; } //public int Role { get; }
private int role; //private int role;
public List<Game> Followed_Games public List<Game> Followed_Games
{ {
get; get;
@ -61,12 +61,16 @@ namespace Model
public User(string username, string biographie, string email, string password) public User(string username, string biographie, string email, string password)
{ {
Username = username; if (username == null) Username = "Default";
Biographie = biographie; else Username = username;
Email = email; if (biographie == null) biographie = "Default";
Password = password; else Biographie = biographie;
if (email == null) email = "Default";
else Email = email;
if (password == null) password = "Default";
else Password = password;
Followed_Games = new List<Game>(); Followed_Games = new List<Game>();
Role = 0; //Role = 0;
} }
public void AddReview(Game game, float rate, string text) public void AddReview(Game game, float rate, string text)
{ {

@ -17,8 +17,9 @@ public partial class AddGamePage : ContentPage
private void AddGame(object sender, EventArgs e) private void AddGame(object sender, EventArgs e)
{ {
int year; int year;
if (string.IsNullOrEmpty(NameEntry.Text) || string.IsNullOrEmpty(DescriptionEntry.Text) || string.IsNullOrEmpty(YearEntry.Text) || !int.TryParse(YearEntry.Text, out year) || string.IsNullOrWhiteSpace(LinkEntry.Text) /*|| _ImgPath is null*/) return; string imgName = "no_cover.png";
string imgName = "no_cover.png";//NameEntry.Text + ".png"; if (string.IsNullOrEmpty(NameEntry.Text) || string.IsNullOrEmpty(DescriptionEntry.Text) || string.IsNullOrEmpty(YearEntry.Text) || !int.TryParse(YearEntry.Text, out year) || string.IsNullOrWhiteSpace(LinkEntry.Text) /*|| _ImgPath is null*/) return;
//if (_ImgPath!=null) NameEntry.Text + ".png";
//System.IO.File.Copy(_ImgPath, /**/, true); //System.IO.File.Copy(_ImgPath, /**/, true);
((App)App.Current).Manager.AddGametoGamesList(new Game(NameEntry.Text, DescriptionEntry.Text, year, new List<string> { TagEntry1.Text, TagEntry2.Text, TagEntry3.Text }, imgName, LinkEntry.Text)); ((App)App.Current).Manager.AddGametoGamesList(new Game(NameEntry.Text, DescriptionEntry.Text, year, new List<string> { TagEntry1.Text, TagEntry2.Text, TagEntry3.Text }, imgName, LinkEntry.Text));
Navigation.RemovePage(this); Navigation.RemovePage(this);

@ -20,7 +20,7 @@ public partial class App : Application
window.Stopped += (s, e) => window.Stopped += (s, e) =>
{ {
Manager._persistance = new Persistance(FileSystem.Current.AppDataDirectory); Manager.persistance = new Persistance(FileSystem.Current.AppDataDirectory);
var test = Manager; var test = Manager;
Manager.SaveGames(); Manager.SaveGames();
}; };

Loading…
Cancel
Save