public async Task <ExportModel> Export(string catalogueId) { try { CatalogueByGuidModel catalogueDetails = await _retrieveCatalogueDetailsRepo.GetCatalogueByGuid(catalogueId); string path = _constructFileStoragePath.GetPath(catalogueId); _constructExcelFile.Create(path, catalogueDetails.CompanyDetails); byte[] file = File.ReadAllBytes(path); _deleteFile.Delete(path); ExportModel fileDetails = new ExportModel { FileBytes = file, FileName = catalogueDetails.FileName }; return(fileDetails); } catch (Exception ex) { throw ex; } }
public async Task <string> Process(IFormFile catalogueFile) { try { string fileUniqueGuid = Guid.NewGuid().ToString(); if (catalogueFile != null) { string savedPath = _constructFileStoragePath.GetPath(fileUniqueGuid); await _saveFile.Save(catalogueFile, savedPath); DataTable dtCompanyCatalogue = _fileParser.Parse(savedPath); List <CompanyDetailModel> catalogueDetails = _companyCatalogueCollection.GetCollection(dtCompanyCatalogue); await _catalogueUOW.Create(catalogueDetails, fileUniqueGuid, catalogueFile.FileName); _deleteFile.Delete(savedPath); } return(fileUniqueGuid); } catch (Exception e) { throw e; } }