Ejemplo n.º 1
0
        public async Task <IActionResult> ConfirmedReport(ReportViewModel report)
        {
            string accessToken = await HttpContext.GetTokenAsync("access_token");

            HttpClient client = new HttpClient();

            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
            if (ModelState.IsValid)
            {
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
                StringContent       httpContent = new StringContent(report.ToJson(), Encoding.UTF8, "application/json");
                HttpResponseMessage response    = await client.PostAsync(Configuration["URLAPI"] + $"api/Account/SendReportAdmin", httpContent);

                if (response.StatusCode != HttpStatusCode.OK)
                {
                    return(BadRequest());
                }
            }

            return(RedirectToAction(nameof(Search)));
        }