public async Task <IActionResult> EfetuarPagamento(PagamentoEvento pagamento) { //a ser implementado try { HttpClient client = new HttpClient(); client.BaseAddress = new Uri("http://localhost:49728/"); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); string json = JsonConvert.SerializeObject(pagamento); HttpContent content = new StringContent(json, Encoding.Unicode, "application/json"); var response = await client.PostAsync("api/Pagamentos/IncluirPagamento", content); if (response.IsSuccessStatusCode) { return(RedirectToAction("ListarParticipantes")); } else { string msg = response.StatusCode + " - " + response.ReasonPhrase; throw new Exception(msg); } } catch (Exception ex) { ViewData["MensagemErro"] = ex.Message; return(View("_Erro")); } }
public IActionResult EfetuarPagamento(int id, int idEvento) { var participante = ParticipantesDao.BuscarPorId(id); var evento = EventosDao.BuscarPorId(idEvento); PagamentoEvento pagamento = new PagamentoEvento { Cpf = participante.Cpf, IdEvento = idEvento, Valor = evento.Preco, Status = 1, NumeroCartao = "11111111" }; return(View(pagamento)); }