Exemplo n.º 1
0
        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");
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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>());
            }
        }
Exemplo n.º 4
0
        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.");
            }
        }