public async Task AddToReadingList() { try { object currentUserId = 0; Application.Current.Properties.TryGetValue("id", out currentUserId); var request = new UserBooksUpsertRequest() { BookId = Book.Id, FinishedReadingOn = null, StartedReadingOn = DateTime.Now, UserId = (int)currentUserId }; var userBookEntity = await _userBooksService.Insert <Model.Models.UserBook>(request); if (userBookEntity != null) { await Application.Current.MainPage.DisplayAlert("Success", "Book has been added to reading list", "OK"); //Application.Current.MainPage = new ReadingListPage(); } else { await Application.Current.MainPage.DisplayAlert("Error", "Something happened", "OK"); } } catch (System.Exception ex) { throw; } }
public async Task MarkAsCompleted() { var request = new UserBooksUpsertRequest() { FinishedReadingOn = DateTime.Now, BookId = Book.Id, StartedReadingOn = UserBook.StartedReadingOn, UserId = UserBook.UserId }; var entity = await _userBooksService.Update <Model.Models.UserBook>(UserBook.Id, request); if (entity != null) { await Application.Current.MainPage.DisplayAlert("Success", "You have successfully completed a book", "Thanks"); } }