Esempio n. 1
0
        public async Task <IList <string> > ParseFileContentAndSaveData(string content, FileType fileType)
        {
            var parser = FileParserProvider.GetFileParser(fileType);
            var result = parser.ExtractDataFromContent(content);

            if (!result.HasError && result.Data.Any())
            {
                _logger.LogInformation($"Transaction data of file type {fileType} saved to database successfully! ");
                await _transactionRepository.AddRangeAsync(result.Data.ToList());
            }
            else
            {
                _logger.LogWarning($"Validation error during file upload of type: {fileType} .  Errors: {string.Join(",", result.Errors)}  , FileContent: {content} ");
            }

            return(result.Errors);
        }