average sur une seule ligne

Popup_qui_marche_pas
Anthony RICHARD 2 years ago
parent 0907a60d76
commit 750aa1778c

@ -17,8 +17,7 @@ namespace Model
{ {
if (string.IsNullOrWhiteSpace(value)) name = "Default"; if (string.IsNullOrWhiteSpace(value)) name = "Default";
else name = value; else name = value;
NotifyPropertyChanged(); NotifyPropertyChanged();
}
} }
} }
private string name = default!; private string name = default!;
@ -31,8 +30,7 @@ namespace Model
{ {
if (string.IsNullOrWhiteSpace(value)) description = "Defaut"; if (string.IsNullOrWhiteSpace(value)) description = "Defaut";
else description = value; else description = value;
NotifyPropertyChanged(); NotifyPropertyChanged();
}
} }
} }
private string description = default!; private string description = default!;
@ -45,8 +43,7 @@ namespace Model
{ {
if (value < 1957 || value > 2023) year = 2023; if (value < 1957 || value > 2023) year = 2023;
else year = value; else year = value;
NotifyPropertyChanged(); NotifyPropertyChanged();
}
} }
} }
private int year = default!; private int year = default!;
@ -59,8 +56,7 @@ namespace Model
{ {
if (string.IsNullOrWhiteSpace(value)) cover = "no_cover.png"; if (string.IsNullOrWhiteSpace(value)) cover = "no_cover.png";
else cover = value; else cover = value;
NotifyPropertyChanged(); NotifyPropertyChanged();
}
} }
} }
private string cover = default!; private string cover = default!;
@ -73,8 +69,7 @@ namespace Model
{ {
if (value == null || value.Count > 3) tags = new ObservableCollection<string>(); if (value == null || value.Count > 3) tags = new ObservableCollection<string>();
else tags = value; else tags = value;
NotifyPropertyChanged(); NotifyPropertyChanged();
}
} }
} }
private ObservableCollection<string> tags; private ObservableCollection<string> tags;
@ -82,12 +77,7 @@ namespace Model
[DataMember] [DataMember]
public List<Review> Reviews { get; private init; } public List<Review> Reviews { get; private init; }
public double Average => AverageCalc(); public double Average => Reviews.Any() ? Math.Round(Reviews.Select(review => review.Rate).Average(), 1) : 0;
private double AverageCalc()
{
if (Reviews.Count > 0) return Math.Round(Reviews.Select(review => review.Rate).Average(), 1);
else return 0;
}
[DataMember] [DataMember]
public string Lien { public string Lien {
@ -96,8 +86,7 @@ namespace Model
{ {
if (string.IsNullOrWhiteSpace(value)) lien = "Pas de lien"; if (string.IsNullOrWhiteSpace(value)) lien = "Pas de lien";
else lien = value; else lien = value;
NotifyPropertyChanged(); NotifyPropertyChanged();
}
} }
} }
private string lien = default!; private string lien = default!;

Loading…
Cancel
Save