public TripContext(string fileDBLocation) { _fileDBLocation = fileDBLocation; var fileSystem = new Microsoft.Owin.FileSystems.PhysicalFileSystem(""); IFileInfo fi; if (fileSystem.TryGetFileInfo(_fileDBLocation, out fi)) { var json = File.ReadAllText(fi.PhysicalPath); var result = JsonConvert.DeserializeObject <List <Trip> >(json); Trips = result.ToList(); } }
public TripContext(string fileDBLocation) { _fileDBLocation = fileDBLocation; var fileSystem = new Microsoft.Owin.FileSystems.PhysicalFileSystem(""); IFileInfo fi; if (fileSystem.TryGetFileInfo(_fileDBLocation, out fi)) { var json = File.ReadAllText(fi.PhysicalPath); var result = JsonConvert.DeserializeObject<List<Trip>>(json); Trips = result.ToList(); } }
public bool SaveChanges() { // write trips to json file, overwriting the old one var json = JsonConvert.SerializeObject(Trips); var fileSystem = new Microsoft.Owin.FileSystems.PhysicalFileSystem(""); IFileInfo fi; if (fileSystem.TryGetFileInfo(_fileDBLocation, out fi)) { File.WriteAllText(fi.PhysicalPath, json); return true; } return false; }
public bool SaveChanges() { // write trips to json file, overwriting the old one var json = JsonConvert.SerializeObject(Trips); var fileSystem = new Microsoft.Owin.FileSystems.PhysicalFileSystem(""); IFileInfo fi; if (fileSystem.TryGetFileInfo(_fileDBLocation, out fi)) { File.WriteAllText(fi.PhysicalPath, json); return(true); } return(false); }
private IFileInfo GetJsonFile() { var fileSystem = new PhysicalFileSystem(""); IFileInfo fileInfo; fileSystem.TryGetFileInfo(_jsonFileLocation, out fileInfo); return fileInfo; }