public DocumentDto PerformSideEffect(CreateDocumentCommand cmd) { var test = from file in SaveFile(cmd.File) from text in new OcrPdfToText().GetText(file) // TODO - Use OCR as interface and apply with Dependency Injection select CreateDocument(cmd, file, text); return(test.Try().Match(x => x, e => throw e)); }
DocumentDto CreateDocument(CreateDocumentCommand x, FileInfo fileInfo, string text) { SaveTextFile(fileInfo, text); var document = x.ToDocument(); return(_repository .CreateClassifiedDocument(document, IssueAnalizer.ObtenerAsunto(text), fileInfo.Name) .ToDocumentDto()); }
Validation <Error, CreateDocumentCommand> ValidateCreateDocumentCmd( CreateDocumentCommand cmd) => from x in ValidateNonNull(cmd) from y in ValidateDocument(x) select cmd;
Execute(CreateDocumentCommand cmd) => () => from x in ValidateCreateDocumentCmd(cmd) select PerformSideEffect(x);