private void button1_Click(object sender, EventArgs e) { var client = new FoodleServiceClient(); var result = client.GetVoteOptions(); var vote = new Vote { Prio1 = result.Restaurants[0], Prio2 = result.Restaurants[1], Prio3 = result.Restaurants[2] }; var submitted = client.SubmitVote(vote); var res = client.GetResults(); Console.WriteLine(); }
private void GetRestaurantsButton_Click(object sender, RoutedEventArgs e) { using (var client = new FoodleServiceClient()) { var response = client.GetVoteOptions(); _voteOptions = response.Options; } ShowRestaurants(); }
private void SendVoteButton_Click(object sender, RoutedEventArgs e) { if (_voteOptions == null) MessageBox.Show("Please get options first"); else if (ValidVotes.Count() != 3) MessageBox.Show("Select three items"); else { var client = new FoodleServiceClient(); var request = new SaveVoteRequest { Vote = new Vote { Prio1 = ValidVotes.ElementAt(0), Prio2 = ValidVotes.ElementAt(1), Prio3 = ValidVotes.ElementAt(2) } }; var resp = client.SubmitVote(request); GetResults(string.Format("Your vote has been {0}.", resp.Status)); } }
private void GetResults(string statusInformation) { var msgBuilder = new StringBuilder(); using (var client = new FoodleServiceClient()) { var response = client.GetResults(); var results = response.Results; if (!results.Items.Any()) { msgBuilder.AppendLine("No votes yet"); } else { msgBuilder.AppendLine(string.Format("[1] -> {0} ({1} votes)", results.Items[0].Prio1.Name, results.Items[0].Prio1.Points)); msgBuilder.AppendLine(string.Format("[2] -> {0} ({1} votes)", results.Items[0].Prio2.Name, results.Items[0].Prio2.Points)); msgBuilder.AppendLine(string.Format("[3] -> {0} ({1} votes)", results.Items[0].Prio3.Name, results.Items[0].Prio3.Points)); } } if (!string.IsNullOrEmpty(statusInformation)) { msgBuilder.AppendLine(); msgBuilder.AppendLine(statusInformation); } contentControl1.Content = msgBuilder.ToString(); }