public BookDetailsViewModel(Model.Models.Book book = null) { Title = book?.Name; Book = book; AddToReadingListCommand = new Command(async() => await AddToReadingList()); }
private async void FinishBookBtn_Click(object sender, System.EventArgs e) { if (!this.ValidateChildren()) { return; } var searchRequest = new BooksUpsertRequest() { Name = bookTitleTextBox.Text, PagesInTotal = (int)totalPagesNumeric.Value, YearPublished = (int)publishedInNumeric.Value, Subject = subjectsTextBox.Text.ToLower().Trim(), CoverImage = request.CoverImage }; var authorIdObj = bookAuthorComboBox.SelectedValue; if (int.TryParse(authorIdObj.ToString(), out int authorId)) { searchRequest.AuthorId = authorId; } var genreIdObj = bookGenreComboBox.SelectedValue; if (int.TryParse(genreIdObj.ToString(), out int genreId)) { searchRequest.GenreId = genreId; } Model.Models.Book bookEntity = null; if (!_bookId.HasValue) { bookEntity = await _bookService.Insert <Model.Models.Book>(searchRequest); } else { bookEntity = await _bookService.Update <Model.Models.Book>(_bookId.Value, searchRequest); } if (bookEntity != null) { MessageBox.Show("Operation successfull"); } }