Example #1
0
 public CsvFile GetCsvFile(int id)
 {
     using (CsvDataContext cntx = new CsvDataContext())
     {
         return(cntx.CsvFileContents.FirstOrDefault(fileContent => fileContent.Id == id));
     }
 }
Example #2
0
 public List <CsvFile> GetFiles()
 {
     using (CsvDataContext cntx = new CsvDataContext())
     {
         return(cntx.CsvFileContents.ToList());
     }
 }
Example #3
0
 public void Save(string fileName, byte[] contentBytes)
 {
     using (CsvDataContext cntx = new CsvDataContext())
     {
         if (cntx.CsvFileContents.Any(x => x.FileName == fileName))
         {
             throw new Exception($"Csv file with filename {fileName} already exists");
         }
         CsvFile cdFileContent = new CsvFile
         {
             Content  = contentBytes,
             FileName = fileName
         };
         cntx.CsvFileContents.Add(cdFileContent);
         cntx.SaveChanges();
     }
 }