-
-
Save ZadokJoshua/ac8caa801d0bbcf956e5b06b533a3acd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BooksTracker.Models; | |
using BooksTracker.Services; | |
using CommunityToolkit.Mvvm.ComponentModel; | |
using CommunityToolkit.Mvvm.Input; | |
namespace BooksTracker.ViewModels; | |
[QueryProperty(nameof(Book), "BookObject")] | |
public partial class UpdateBookViewModel : ObservableObject | |
{ | |
private readonly IDataService _dataService; | |
[ObservableProperty] | |
private Book _book; | |
public UpdateBookViewModel(IDataService dataService) | |
{ | |
_dataService = dataService; | |
} | |
[RelayCommand] | |
private async Task UpdateBook() | |
{ | |
if (!string.IsNullOrEmpty(Book.Title)) | |
{ | |
await _dataService.UpdateBook(Book); | |
await Shell.Current.GoToAsync(".."); | |
} | |
else | |
{ | |
await Shell.Current.DisplayAlert("Error", "No title!", "OK"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment