public async Task <IActionResult> CreatePollByBuildingId(CancellationToken cancellationToken, [FromRoute] Guid buildingId, [FromBody] CreatePollBinding binding, [FromServices] PollManager mananger) { await mananger.CreateByBuilding(binding.Question, binding.Answers, binding.OwnerId, buildingId, cancellationToken); return(Ok()); }
public static async Task CreatePollByBuildingId(string buildingId, CreatePollBinding binding) { HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Add("Accept", "application/json"); client.DefaultRequestHeaders.Add("User-Agent", "ServiceForWorking"); HttpResponseMessage response = await client.PostAsJsonAsync($"https://localhost:44303/polls/buildings/{buildingId}", binding); }
// end CreatingPoll //ForPolls private async void btnCreatePoll_Click(object sender, RoutedEventArgs e) { var cmi = (ComboBoxItem)cmbBuildingAddressesForCreaatePoll.SelectedItem; if (cmi == null) { MessageBox.Show("Вы не выбрали дом"); } string buildingId = (string)cmi.Tag; string question = tbPollQuestionForCreatePoll.Text; List <string> answers = new List <string>(); foreach (var answer in stpAnswerOptions.Children) { var tbAnswer = (TextBox)answer; answers.Add(tbAnswer.Text); } var createPollBinding = new CreatePollBinding() { Question = question, Answers = answers, OwnerId = Profile.Id.ToString(), }; await Server.CreatePollByBuildingId(buildingId, createPollBinding); lblCreatePollState.Content = "Опрос успешно создан"; tbPollQuestionForCreatePoll.Text = ""; foreach (var answer in stpAnswerOptions.Children) { var tbAnswer = (TextBox)answer; tbAnswer.Text = ""; } }