public static async Task <JSONEnrollFavorites> EnrollFavorites() { HttpMessage response = await Login.Instance.DoPost($"api/talks/enroll_favorites"); if (!response.Success) { return(new JSONEnrollFavorites() { success = response.Success }); } string json = await response.Response.Content.ReadAsStringAsync(); JSONEnrollFavorites canEnroll = JsonConvert.DeserializeObject <JSONEnrollFavorites>(json); return(canEnroll); }
private async void EnrollToFavorites() { JSONEnrollFavorites result = await Enroll.EnrollFavorites(); if (!result.success) { if (result.errors > 0) { await Application.Current.MainPage.DisplayAlert("Failed", $"Could not enroll to all of your favorites. Enrolled to {result.amountOfFavorites - result.errors} talks and failed for {result.errors} talks. Did you already enroll to some talks?", "OK"); } else { await Application.Current.MainPage.DisplayAlert("Failed", "Could not enroll to your favorites... Try again later.", "OK"); } } else { await Application.Current.MainPage.DisplayAlert("Success!", "Enrolled for your favorite talks.", "OK"); } }