private void CheckDataCorrectness() { if (schoolData.classes == null || schoolData.rooms == null || schoolData.teachers == null || schoolData.groups == null || schoolData.activities == null) { schoolData = new SchoolData(); } }
public void DeserializeData() { if (File.Exists(jsonFile)) { var jsonData = File.ReadAllText(jsonFile); if (String.IsNullOrEmpty(jsonData)) { schoolData = new SchoolData(); return; } try { schoolData = JsonSerializer.Deserialize <SchoolData>(jsonData); CheckDataCorrectness(); } catch (JsonException) { schoolData = new SchoolData(); } } else { File.Create(jsonFile); schoolData = new SchoolData();; SerializeData(); } }