public FileHistory UpdateFile(BackedUpFile file) { FileHistory hist = new FileHistory() { FileId = file.Id, LastSeen = DateTime.Now, Modified = file.Modified }; using (var context = new AppDbContext(_dbConnectionConfig)) { context.FileHistory.Add(hist); context.SaveChanges(); } return(hist); }
public FileHistory AddFile(BackedUpFile file) { FileHistory hist = null; if (file.ParentId <= 0) { throw new InvalidDataException($"Cannot add file ({file.Name}) without a parent (ID:{file.ParentId})"); } using (var context = new AppDbContext(_dbConnectionConfig)) { context.Files.Add(file); hist = new FileHistory() { FileId = file.Id, LastSeen = DateTime.Now, Modified = file.Modified }; context.FileHistory.Add(hist); context.SaveChanges(); } return(hist); }