partial void AddToFavourite_TouchUpInsite(UIButton sender)
 {
     Core.Model.FavouriteMoviePostRequest request = new FavouriteMoviePostRequest();
     request.MovieId = Movie.Id.Value.ToString();
     sender.Selected = request.IsFavourite = !sender.Selected;
     PostFavouriteRequestAsync(request).FireAndForgetSafeAsync();
 }
        private async Task PostFavouriteRequestAsync(FavouriteMoviePostRequest request)
        {
            try
            {
                var response = await AppData.MoviesDataAccess.PostFavouriteMovie(request);

                if (response != null)
                {
                    var message = request.IsFavourite ? "Saved as favourite" : "Removed from favourite";
                    BeginInvokeOnMainThread(() =>
                    {
                        var alert       = UIAlertController.Create("Favourite movie", message, UIAlertControllerStyle.Alert);
                        var alertAction = UIAlertAction.Create("OK", UIAlertActionStyle.Default, null);
                        alert.AddAction(alertAction);
                        this.PresentViewController(alert, true, null);
                    });
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Ejemplo n.º 3
0
        public Task <FavouriteMoviePostResponse> PostFavouriteMovie(FavouriteMoviePostRequest request)
        {
            var url = Config.BaseUrl + Config.FavouriteMovies;

            return(_apiService.Post <FavouriteMoviePostRequest, FavouriteMoviePostResponse>(url, request));
        }