/// <summary> /// Updates a folder of the database. /// </summary> /// <param name="vm">The vm<see cref="FolderViewModel"/>.</param> public static void Update(FolderViewModel vm) { Debug.Assert(vm != null); Debug.Assert(vm.FolderId != 0); using var dbc = new PmDb(); var ent = dbc.Find <Folder>(vm.FolderId); ent.GetViewModel(vm); dbc.SaveChanges(); }
/// <summary> /// Updates a single zip file of the database. /// </summary> /// <param name="vm">The vm<see cref="ZipFileViewModel"/>.</param> public static void Update(ZipFileViewModel vm) { Debug.Assert(vm != null); Debug.Assert(vm.PackageId != 0); using var dbc = new PmDb(); var ent = dbc.Find <ZipFile>(vm.PackageId); ent.GetViewModel(vm); dbc.SaveChanges(); }
/// <summary> /// Deletes a single zip file from the database. /// </summary> /// <param name="vm">The vm<see cref="ZipFileViewModel"/>.</param> public static void Delete(ZipFileViewModel vm) { Debug.Assert(vm != null); Debug.Assert(vm.PackageId != 0); using var dbc = new PmDb(); foreach (var item in vm.Folders) { item.PackageId = null; var folderEnt = dbc.Find <Folder>(item.FolderId); folderEnt.PackageId = null; dbc.Update(folderEnt); } var ent = dbc.Find <ZipFile>(vm.PackageId); dbc.ZipFiles.Remove(ent); dbc.SaveChanges(); }
/// <summary> /// Deletes a folder from the database. /// </summary> /// <param name="vm">The vm<see cref="FolderViewModel"/>.</param> public static void Delete(FolderViewModel vm) { Debug.Assert(vm != null); Debug.Assert(vm.FolderId != 0); using var dbc = new PmDb(); var ent = dbc.Find <Folder>(vm.FolderId); dbc.Folders.Remove(ent); dbc.SaveChanges(); }
/// <summary> /// Updates zip files of the database. /// </summary> /// <param name="vms">The vms<see cref="IEnumerable{ZipFileViewModel}"/>.</param> public static void Update(IEnumerable <ZipFileViewModel> vms) { Debug.Assert(vms != null); using var dbc = new PmDb(); foreach (var vm in vms) { Debug.Assert(vm.PackageId != 0); var ent = dbc.Find <ZipFile>(vm.PackageId); ent.GetViewModel(vm); } dbc.SaveChanges(); }
/// <summary> /// Deletes folders from the database. /// </summary> /// <param name="vms">The vms<see cref="IEnumerable{FolderViewModel}"/>.</param> public static void Delete(IEnumerable <FolderViewModel> vms) { Debug.Assert(vms != null); using var dbc = new PmDb(); foreach (var vm in vms) { Debug.Assert(vm.FolderId != 0); var ent = dbc.Find <Folder>(vm.FolderId); dbc.Folders.Remove(ent); } dbc.SaveChanges(); }
/// <summary> /// Deletes zip files from the database. /// </summary> /// <param name="vms">The vms<see cref="IEnumerable{ZipFileViewModel}"/>.</param> public static void Delete(IEnumerable <ZipFileViewModel> vms) { Debug.Assert(vms != null); var dbc = new PmDb(); foreach (var vm in vms) { Debug.Assert(vm.PackageId != 0); var ent = dbc.Find <ZipFile>(vm.PackageId); dbc.ZipFiles.Remove(ent); } dbc.SaveChanges(); dbc.Dispose(); }