public async Task <IActionResult> Post(IFormFile file) { List <string> restURL = new List <string>(); #region SavingFile _logger.LogInfo("Uploading file success - Started"); var filePath = string.Empty; var strActualFileName = Path.GetFileNameWithoutExtension(file.FileName); var fileExt = Path.GetExtension(file.FileName); var appendString = DateTime.Now.ToString("yyyyddmmHHssmmm"); string strUniquename = strActualFileName + "_" + appendString + "" + fileExt; var uploads = @"C:/AzaKawSampleKYC/KYCUploads"; if (!Directory.Exists(uploads)) { _logger.LogInfo("Creating Upload Directory - Start"); Directory.CreateDirectory(uploads); _logger.LogInfo("Creating Upload Directory - Done"); } if (file.Length > 0) { filePath = Path.Combine(uploads, strUniquename); using (var fileStream = new FileStream(filePath, FileMode.Create)) { await file.CopyToAsync(fileStream); } } strActualFileName = strActualFileName + "" + fileExt; _logger.LogInfo("Uploading file success - Done"); #endregion #region ReadingMRZWithAbbyOCR _logger.LogInfo("Reading MRZ Inforation with Abby Cloud OCR - Started"); if (System.IO.File.Exists(@filePath)) { using (var ocrClient = OCRHelper.GetOcrClientWithRetryPolicy()) { restURL = await OCRHelper.ProcessImageAsync(ocrClient, @filePath); //new List<string>() { "https://ocrsdk.blob.core.windows.net/files/8ebe4855-1071-4ed0-95b6-de2334536a85.result?sv=2012-02-12&se=2019-11-02T21%3A00%3A00Z&sr=b&si=downloadResults&sig=VFoM9QfONhmpc4GjokEIEDDtIIDd9fRDY8t%2Bkvdu%2Fuo%3D" }; //await OCRHelper.ProcessImageAsync(ocrClient, @filePath); } } else { _logger.LogWarn("Could not find the uploaded file"); throw new ArgumentException($"Some thing went wrong, Please contact administrator (view logs)"); } _logger.LogInfo("Reading MRZ Inforation with Abby Cloud OCR - Done"); #endregion #region ReadingMRZOutput _logger.LogInfo("Reading MRZ Resulted Output - Start"); DataSet ds = new DataSet(); WebRequest request = WebRequest.Create(restURL[0].ToString()); Encoding encoding = Encoding.GetEncoding("iso-8859-1"); WebRequest requestXML = WebRequest.Create(restURL[0].ToString()); request.Method = "GET"; using (var response = (System.Net.HttpWebResponse)request.GetResponse()) { // get correct charset and encoding from the server's header Encoding encodingXML; try { encodingXML = Encoding.GetEncoding(response.CharacterSet); } catch { encodingXML = Encoding.UTF8; } using (var rdr = new StreamReader(response.GetResponseStream(), encoding)) { ds.ReadXml(rdr); } } MrzInfo objMRZ = OCRHelper.DeserializeMRZInfo(ds.Tables[1]); objMRZ.CustomerId = int.Parse(User.Claims.FirstOrDefault().Value); objMRZ.FileName = strActualFileName; objMRZ.FileNameUnique = strUniquename; _logger.LogInfo("Reading MRZ Resulted Output - Done"); #endregion #region KYCVerification _logger.LogInfo("Verifying User KYC Details with Trulioo - Start"); //Example Username: JoeNapoli_API_Demo, Example Password: 05uZuPRCyPi!6 bool isKYCVerified = await IsKYCVerified(); _logger.LogInfo("Verifying User KYC Details with Trulioo - End"); #endregion #region SavingMRZInfo _logger.LogInfo("Saving MRZ Info - Start"); objMRZ.isKYCVerified = isKYCVerified; objMRZ.AdditionalInfo = JsonConvert.SerializeObject(objMRZ); _uploadRepository.InsertMrzInfo(objMRZ); var allMRzInfo = _uploadRepository.GetMrzInfos(); _logger.LogInfo("Saving MRZ Info - End"); #endregion return(Ok(allMRzInfo)); }