public AzureCvModels.RecognitionResult GetRecognitionResult(Domain.ImageFile imageFile, AzureCvModels.TextRecognitionMode textRecognitionMode) { ImageFile dbImageFile = _computerVisionContext.ImageFile.SingleOrDefault(x => x.HashString == imageFile.HashString); if (dbImageFile != null) { RecognitionResult dbRecognitionResult = GetRecognitionResult(dbImageFile, textRecognitionMode); AzureCvModels.RecognitionResult recognitionResult = null; if (dbRecognitionResult != null) { recognitionResult = Mapper.Map <AzureCvModels.RecognitionResult>(dbRecognitionResult); } return(recognitionResult); } return(null); }
public void AddRecognitionResult(Domain.ImageFile imageFile, AzureCvModels.RecognitionResult recognizeText, AzureCvModels.TextRecognitionMode textRecognitionMode) { RecognitionResult dbRecognizeText = Mapper.Map <RecognitionResult>(recognizeText); RecognitionResult addedRecognizeText = _computerVisionContext.RecognitionResult.Add(dbRecognizeText).Entity; _computerVisionContext.SaveChanges(); ImageFile dbImageFile = _computerVisionContext.ImageFile.SingleOrDefault(x => x.HashString == imageFile.HashString); if (dbImageFile != null && textRecognitionMode == AzureCvModels.TextRecognitionMode.Printed) { dbImageFile.PrintedRecognitionResultId = addedRecognizeText.Id; } else if (dbImageFile != null && textRecognitionMode == AzureCvModels.TextRecognitionMode.Handwritten) { dbImageFile.HandwrittenRecognitionResultId = addedRecognizeText.Id; } _computerVisionContext.SaveChanges(); }