using System; using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Net.Http.Json; using System.Threading.Tasks; using AvaskTestBed.Shared.Models; using AvaskTestBed.Shared.Models.DocoScan; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Newtonsoft.Json; namespace AvaskTestBed.Server.Pages { public class IDCardModel : PageModel { private readonly HttpClient httpClient; public IDCardModel() => this.httpClient = new HttpClient(); // model public string DocName { get; set; } public string FileName { get; set; } public string DocType { get; set; } public List listRespStrings { get; set; } public FieldsModel oFieldsModel { get; set; } // functions public async Task OnGet(string filename, string docname, string doctype) { listRespStrings = new List(); try { string sFilename = $"C:/Ace/KBD/Temp/{filename}"; FileName = sFilename; DocName = docname; DocType = doctype; var request = new ProcessDocumentRequest(new User { CompanyId = "AVASK-SOFTWARE" }, "infiniti-system-client", "", doctype, docname, sFilename); //string sTemp = JsonConvert.SerializeObject(request); //### test only var response2 = await httpClient.PostAsJsonAsync("http://localhost:7071/api/testuploadidcard", request); var content2 = await response2.Content.ReadAsStringAsync(); FieldsModel fieldsModel = JsonConvert.DeserializeObject(content2); oFieldsModel = fieldsModel; } catch (Exception ex) { listRespStrings.Add($"Exception: {ex.Message}"); } return Page(); } } }