Exemplo n.º 1
0
        /// <summary>
        /// Adds a single folder to the database.
        /// </summary>
        /// <param name="vm">The vm<see cref="FolderViewModel"/>.</param>
        public static void Add(FolderViewModel vm)
        {
            Debug.Assert(vm != null);
            using var dbc = new PmDb();
            var ent = new Folder();

            ent.GetViewModel(vm);
            dbc.Folders.Add(ent);
            dbc.SaveChanges();
            vm.GetModel(ent);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes static members of the <see cref="DbCore"/> class.
        /// </summary>
        static DbCore()
        {
            PmDb.BuildConnectString(
                Path.Combine(
                    Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                    "Yoder\\PluginManager"));

            var pvm = Locator.MainViewModel;

            using var dbc = new PmDb();
            foreach (var ent in dbc.ZipFiles)
            {
                var zfvm = new ZipFileViewModel();
                zfvm.GetModel(ent);
                pvm.ZipFileFolderCollection.Add(zfvm);
            }

            foreach (var ent in dbc.Folders)
            {
                var vm = new FolderViewModel();
                vm.GetModel(ent);
                pvm.FolderCollection.Add(vm);
            }
        }