FIX : Data Loads with CommunityToolkit

TP3
Lou BRODA 1 year ago
parent 13e5cb95d8
commit af32502792

@ -8,29 +8,44 @@ using System.Threading.Tasks;
namespace ViewModels
{
[ObservableObject]
public partial class AuthorVM
public class AuthorVM : ObservableObject
{
#region Fields
[ObservableProperty]
private int nbBooksWritten;
[ObservableProperty]
private string name;
private int nbBooksWritten { get; set; }
#endregion
#region Properties
public Author Model { get; }
public string Name
{
get => Model.Name;
set
{
Model.Name = value;
}
}
public int NbBooksWritten
{
get => nbBooksWritten;
set
{
nbBooksWritten = value;
}
}
#endregion
#region Constructor
public AuthorVM(Author model)
{
Model = model;
}
#endregion

@ -8,51 +8,79 @@ using System.Threading.Tasks;
namespace ViewModels
{
[ObservableObject]
public partial class BookVM
public class BookVM : ObservableObject
{
#region Fields
[ObservableProperty]
private string id;
#endregion
[ObservableProperty]
private string isbn13;
#region Properties
[ObservableProperty]
private string title;
public Book Model { get; }
[ObservableProperty]
private List<string> publishers;
public string Id
{
get => Model.Id;
}
[ObservableProperty]
private DateTime publishDate;
public string ISBN13
{
get => Model.ISBN13;
}
[ObservableProperty]
private List<AuthorVM> authors;
public string Title
{
get => Model.Title;
}
[ObservableProperty]
private string author;
public List<string> Publishers
{
get => Model.Publishers;
}
[ObservableProperty]
private Status status;
public DateTime PublishDate
{
get => Model.PublishDate;
}
public List<AuthorVM> Authors
{
get => Model.Authors.Select(a => new AuthorVM(a)).ToList();
}
[ObservableProperty]
private int nbPages;
public string Author => Model.Authors.Count > 0 ? Model.Authors.First().Name : "Auteur inconnu";
[ObservableProperty]
private Languages language;
public Status Status
{
get => Model.Status;
set => SetProperty(Model.Status, value, status => Model.Status = status);
}
[ObservableProperty]
private string imageSmall;
public int NbPages
{
get => Model.NbPages;
}
[ObservableProperty]
private float? userRating;
public Languages Language
{
get => Model.Language;
}
#endregion
public string ImageSmall
{
get => Model.ImageSmall;
}
#region Properties
public float? UserRating
{
get => Model?.UserRating;
set
{
if (Model == null) return;
SetProperty(Model.UserRating, value, rating => Model.UserRating = rating);
}
}
#endregion
@ -60,7 +88,7 @@ namespace ViewModels
public BookVM(Book b)
{
Model = b;
}
#endregion

@ -8,29 +8,43 @@ using System.Threading.Tasks;
namespace ViewModels
{
[ObservableObject]
public partial class BorrowingVM
public class BorrowingVM : ObservableObject
{
#region Fields
[ObservableProperty]
private string id;
#endregion
[ObservableProperty]
private BookVM book;
#region Properties
[ObservableProperty]
private ContactVM owner;
public Borrowing Model { get; }
[ObservableProperty]
private DateTime borrowedAt;
public string Id
{
get => Model.Id;
set => SetProperty(Model.Id, value, v => Model.Id = value);
}
[ObservableProperty]
private DateTime returnedAt;
public BookVM Book
{
get => new BookVM(Model.Book);
}
#endregion
public ContactVM Owner
{
get => new ContactVM(Model.Owner);
}
#region Properties
public DateTime BorrowedAt
{
get => Model.BorrowedAt;
set => SetProperty(Model.BorrowedAt, value, v => Model.BorrowedAt = value);
}
public DateTime? ReturnedAt
{
get => Model.ReturnedAt;
set => SetProperty(Model.ReturnedAt, value, v => Model.ReturnedAt = value);
}
#endregion
@ -38,7 +52,7 @@ namespace ViewModels
public BorrowingVM(Borrowing b)
{
Model = b;
}
#endregion

@ -8,23 +8,33 @@ using System.Threading.Tasks;
namespace ViewModels
{
[ObservableObject]
public partial class ContactVM
public class ContactVM : ObservableObject
{
#region Fields
[ObservableProperty]
private string id;
#endregion
[ObservableProperty]
private string firstName;
#region Properties
[ObservableProperty]
private string lastName;
public Model.Contact Model { get; }
#endregion
public string Id
{
get => Model.Id;
set => SetProperty(Model.Id, value, v => Model.Id = value);
}
#region Properties
public string FirstName
{
get => Model.FirstName;
set => SetProperty(Model.FirstName, value, v => Model.FirstName = value);
}
public string LastName
{
get => Model.LastName;
set => SetProperty(Model.LastName, value, v => Model.LastName = value);
}
#endregion
@ -32,7 +42,7 @@ namespace ViewModels
public ContactVM(Model.Contact c)
{
Model = c;
}
#endregion

@ -8,29 +8,43 @@ using System.Threading.Tasks;
namespace ViewModels
{
[ObservableObject]
public partial class LoanVM
public class LoanVM : ObservableObject
{
#region Fields
[ObservableProperty]
private string id;
#endregion
[ObservableProperty]
private BookVM book;
#region Properties
[ObservableProperty]
private ContactVM loaner;
public Loan Model { get; }
[ObservableProperty]
private DateTime loanedAt;
public string Id
{
get => Model.Id;
set => SetProperty(Model.Id, value, v => Model.Id = value);
}
[ObservableProperty]
private DateTime? returnedAt;
public BookVM Book
{
get => new BookVM(Model.Book);
}
#endregion
public ContactVM Loaner
{
get => new ContactVM(Model.Loaner);
}
#region Properties
public DateTime LoanedAt
{
get => Model.LoanedAt;
set => SetProperty(Model.LoanedAt, value, v => Model.LoanedAt = value);
}
public DateTime? ReturnedAt
{
get => Model.ReturnedAt;
set => SetProperty(Model.ReturnedAt, value, v => Model.ReturnedAt = value);
}
#endregion
@ -38,7 +52,7 @@ namespace ViewModels
public LoanVM(Loan l)
{
Model = l;
}
#endregion

@ -8,24 +8,29 @@ using System.Threading.Tasks;
namespace ViewModels
{
[ObservableObject]
public partial class RatingsVM
public partial class RatingsVM : ObservableObject
{
#region Fields
[ObservableProperty]
private int nbBooksWritten;
[ObservableProperty]
private float? average;
[ObservableProperty]
private int count;
private int nbBooksWritten { get; set; }
#endregion
#region Properties
public float? Average { get; set; }
public int Count { get; set; }
public int NbBooksWritten
{
get => nbBooksWritten;
set
{
nbBooksWritten = value;
}
}
#endregion
#region Constructor

Loading…
Cancel
Save