public IActionResult ProcessFile(IFormFile file) { if (file == null || file.Length == 0) { return(Content("file not selected")); } using (var engine = new TesseractEngine(Path.Combine(_environment.WebRootPath, "tessdata"), "eng", EngineMode.Default)) { using (var image = new Bitmap(file.OpenReadStream())) { using (var page = engine.Process(image)) { IndexViewModel model = new IndexViewModel(); model.Text = page.GetText(); model.MeanConfidence = page.GetMeanConfidence(); using (var context = new OCRContext()) { var a = new Receipt(); var b = new AspNetUsers(); a.Faktura = model.Text; context.Receipt.Add(a); context.SaveChanges(); } return(View("Index", model)); } } } }
public ActionResult Create([FromBody] User u) { using (var context = new OCRContext()) { User test = new User(); test.Emri = u.Emri; context.User.Add(test); context.SaveChanges(); } return(View()); }
public OcrTemplateController(IOptions <OcrTemplateConfiguration> configSettings, OCRContext ctx) { this.configSettings = configSettings.Value; this.dbContext = ctx; }