private static void SaveLayoutModels(this List <LayoutModel> layouts) { string path = FileExtensions.GetRootFile().GetLayoutsModelsFiles(); layouts.CorrectLayoutIds(); List <AppModel> allApps = GetAllApps(layouts); SaveAppModels(allApps); List <string> layoutData = layouts.ConvertLayoutsOnStrings(); try { using (StreamWriter writter = new StreamWriter(path)) { foreach (string data in layoutData) { writter.WriteLine(data); } } } catch (IOException) { throw new IOException("Close data files"); } }
public static void EditAppModel(AppModel app) { string path = FileExtensions.GetRootFile().GetAppModelsFile(); List <AppModel> apps = LoadAppModels(); apps = apps.Where(x => x.Id != app.Id).ToList(); apps.Add(app); SaveAppModels(apps); }
public static List <LayoutModel> LoadLayoutModels() { string path = FileExtensions.GetRootFile().GetLayoutsModelsFiles(); if (File.Exists(path)) { try { return(File.ReadAllLines(path).ConvertStringOnLayoutModels(LoadAppModels())); } catch (IOException) { throw new IOException("Close data files."); } } else { return(new List <LayoutModel>()); } }
private static void SaveAppModels(List <AppModel> apps) { string path = FileExtensions.GetRootFile().GetAppModelsFile(); apps.CorrectAppsIds(); List <string> appData = apps.ConvertAppsOnStrings(); try { using (StreamWriter writer = new StreamWriter(path)) { foreach (string data in appData) { writer.WriteLine(data); } } } catch (IOException) { throw new IOException("Close data files."); } }