fix notifypropertychanged sur user et game + implémentation sur review

Popup_qui_marche_pas
Anthony RICHARD 2 years ago
parent 1d503d9733
commit 0a14886776

@ -15,10 +15,8 @@ namespace Model
get => name;
private set
{
if (string.IsNullOrWhiteSpace(value)) name="Default";
else
{
name = value;
if (string.IsNullOrWhiteSpace(value)) name = "Default";
else name = value;
NotifyPropertyChanged();
}
}
@ -31,10 +29,8 @@ namespace Model
get => description;
private set
{
if (string.IsNullOrWhiteSpace(value)) description="Defaut";
else
{
description = value;
if (string.IsNullOrWhiteSpace(value)) description = "Defaut";
else description = value;
NotifyPropertyChanged();
}
}
@ -47,10 +43,8 @@ namespace Model
get => year;
private set
{
if (value < 1957 || value > 2023) year=2023;
else
{
year = value;
if (value < 1957 || value > 2023) year = 2023;
else year = value;
NotifyPropertyChanged();
}
}
@ -63,10 +57,8 @@ namespace Model
get => cover;
private set
{
if (string.IsNullOrWhiteSpace(value)) cover="no_cover.png";
else
{
cover = value;
if (string.IsNullOrWhiteSpace(value)) cover = "no_cover.png";
else cover = value;
NotifyPropertyChanged();
}
}
@ -80,9 +72,7 @@ namespace Model
private set
{
if (value == null || value.Count > 3) tags = new ObservableCollection<string>();
else
{
tags = value;
else tags = value;
NotifyPropertyChanged();
}
}
@ -105,9 +95,7 @@ namespace Model
private set
{
if (string.IsNullOrWhiteSpace(value)) lien = "Pas de lien";
else
{
lien = value;
else lien = value;
NotifyPropertyChanged();
}
}
@ -133,12 +121,7 @@ namespace Model
public event PropertyChangedEventHandler? PropertyChanged;
private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
public override int GetHashCode()
{

@ -1,9 +1,11 @@
using System.Runtime.Serialization;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
namespace Model
{
[DataContract]
public class Review
public class Review :INotifyPropertyChanged
{
[DataMember]
public double Rate
@ -11,8 +13,9 @@ namespace Model
get => rate;
private set
{
if (value < 0 || value > 5) return;
rate = value;
if (value < 0 || value > 5) rate = 0;
else rate = value;
NotifyPropertyChanged();
}
}
private double rate;
@ -23,12 +26,17 @@ namespace Model
get => text;
private set
{
if (string.IsNullOrWhiteSpace(value)) return;
text = value;
if (string.IsNullOrWhiteSpace(value)) text = "Default";
else text = value;
NotifyPropertyChanged();
}
}
private string? text;
public event PropertyChangedEventHandler? PropertyChanged;
private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
[DataMember]
public string AuthorName { get; set; }

@ -18,6 +18,7 @@ namespace Model
{
if (!string.IsNullOrWhiteSpace(value)) userImage = value;
else userImage = "no_cover.png";
NotifyPropertyChanged();
}
}
private string userImage = default!;
@ -28,11 +29,8 @@ namespace Model
set
{
if (string.IsNullOrWhiteSpace(value)) username = "Default";
else
{
username = value;
NotifyPropertyChanged();
}
else username = value;
NotifyPropertyChanged();
}
}
private string username=default!;
@ -43,11 +41,8 @@ namespace Model
private set
{
if (string.IsNullOrWhiteSpace(value)) biographie = "Pas de biographie";
else
{
biographie = value;
NotifyPropertyChanged();
}
else biographie = value;
NotifyPropertyChanged();
}
}
private string biographie = default!;
@ -58,12 +53,9 @@ namespace Model
private set
{
Regex rg_email = new Regex("^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$");
if (!(string.IsNullOrWhiteSpace(value)) && rg_email.IsMatch(value))
{
email = value;
NotifyPropertyChanged();
}
if (!(string.IsNullOrWhiteSpace(value)) && rg_email.IsMatch(value)) email = value;
else email = "Default";
NotifyPropertyChanged();
}
}
private string email = default!;
@ -87,12 +79,7 @@ namespace Model
public event PropertyChangedEventHandler? PropertyChanged;
private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
[DataMember]
public ObservableCollection<Game> Followed_Games

Loading…
Cancel
Save