Dodaj pliki projektów.

This commit is contained in:
Krzysztof KrzysiekSiemv Smaga
2024-11-25 22:42:31 +01:00
parent 133b8199db
commit 7581d5df42
58 changed files with 1644 additions and 0 deletions
@@ -0,0 +1,39 @@
using DatabaseConnection.Model;
using DatabaseConnection.Services;
using System.Collections.ObjectModel;
using System.ComponentModel;
namespace DatabaseConnection.ViewModel
{
public partial class AuthorsViewModel : INotifyPropertyChanged
{
private readonly AuthorService _authorService;
public ObservableCollection<Author> Authors { get; set; } = [];
public AuthorsViewModel(AuthorService authorService)
{
_authorService = authorService;
LoadAuthorsCommand = new Command(async () => await LoadAuthors());
}
public Command LoadAuthorsCommand { get; }
private async Task LoadAuthors()
{
Authors.Clear();
var authors = await _authorService.GetAuthors();
foreach (var author in authors)
{
Authors.Add(author);
}
OnPropertyChanged(nameof(Authors));
}
public event PropertyChangedEventHandler? PropertyChanged;
public void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}