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();
}
public ObservableCollection<Game> LoadGame()
public ObservableCollection<Game>? LoadGame()
{
if (File.Exists("games.xml"))
{

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

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

@ -51,8 +51,8 @@ namespace Model
}
private string? password;
public int Role { get; }
private int role;
//public int Role { get; }
//private int role;
public List<Game> Followed_Games
{
get;
@ -61,12 +61,16 @@ namespace Model
public User(string username, string biographie, string email, string password)
{
Username = username;
Biographie = biographie;
Email = email;
Password = password;
if (username == null) Username = "Default";
else Username = username;
if (biographie == null) biographie = "Default";
else Biographie = biographie;
if (email == null) email = "Default";
else Email = email;
if (password == null) password = "Default";
else Password = password;
Followed_Games = new List<Game>();
Role = 0;
//Role = 0;
}
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)
{
int year;
string imgName = "no_cover.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;
string imgName = "no_cover.png";//NameEntry.Text + ".png";
//if (_ImgPath!=null) NameEntry.Text + ".png";
//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));
Navigation.RemovePage(this);

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

Loading…
Cancel
Save