Ejemplo n.º 1
0
        public Task <OperationResult> AddRows(IFormFile file) =>
        Task.Factory.StartNew(() =>
        {
            OperationResult result = _excelValidator.ValidateExcelDocument(file);

            if (result.Success)
            {
                WorkSheet worksheet = WorkBookHelper.ConvertFileToWorkbook(file).DefaultWorkSheet;

                LinkedList <Row> rowList = worksheet.ToRowEntityList();

                int effectedRowCount = _spreadsheetRepository.AddRange(rowList);
                if (effectedRowCount < 1)
                {
                    result.Success = false;
                    result.AddMessage(ResponseMessages.AddFailed);
                }
            }

            return(result);
        });