private async void LoadStars() { try { IRatingRestService ratingRestService = new RatingRestService(); AvgStars = await ratingRestService.GetAverageRating(Location); VotingList.ItemsSource = Location.Ratings; MakeStarYellow(1, Star1); MakeStarYellow(2, Star2); MakeStarYellow(3, Star3); MakeStarYellow(4, Star4); MakeStarYellow(5, Star5); ColorizeRatings(0, 1, VotingStar1); ColorizeRatings(0, 2, VotingStar2); ColorizeRatings(0, 3, VotingStar3); ColorizeRatings(0, 4, VotingStar4); ColorizeRatings(0, 5, VotingStar5); } catch (FaultException <Exception> exc) { await DisplayAlert("Fejl", exc.Message, "OK"); } }
private async void SaveRatingEditsButton_OnClicked(object sender, EventArgs e) { try { bool status = double.TryParse(RatingEntry.Text, out double result); if (status) { Rating.Rate = result; Rating.Comment = CommentEditor.Text; IRatingRestService restService = new RatingRestService(); restService.Update(Rating); } } catch (FaultException <Exception> exc) { await DisplayAlert("Fejl", exc.Message, "OK"); } }
private async void SendVote(object sender, EventArgs eventArgs) { try { IRatingRestService ratingRestService = new RatingRestService(); Rating rating = new Rating { Comment = RatingComment.Text, User = User, Rate = CurrVote, LocationId = Location.LocationId }; await ratingRestService.Create(rating); LoadStars(); CurrVote = 0; } catch (FaultException <Exception> exc) { await DisplayAlert("Fejl", exc.Message, "OK"); } }