diff --git a/Disco.BI/BI/Extensions/DeviceBatchExtensions.cs b/Disco.BI/BI/Extensions/DeviceBatchExtensions.cs index 2fe39a4f..7634b28c 100644 --- a/Disco.BI/BI/Extensions/DeviceBatchExtensions.cs +++ b/Disco.BI/BI/Extensions/DeviceBatchExtensions.cs @@ -1,11 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using Disco.Data.Repository; using Disco.Models.Repository; -using Disco.Data.Repository; -using Disco.Services.Users; using Disco.Services.Authorization; +using Disco.Services.Devices.ManagedGroups; +using Disco.Services.Interop.ActiveDirectory; +using Disco.Services.Users; +using System; +using System.Linq; namespace Disco.BI.Extensions { @@ -29,6 +29,10 @@ namespace Disco.BI.Extensions if (!db.CanDelete(Database)) throw new InvalidOperationException("The state of this Device Batch doesn't allow it to be deleted"); + // Remove Linked Group + ActiveDirectory.Context.ManagedGroups.Remove(DeviceBatchDevicesManagedGroup.GetKey(db)); + ActiveDirectory.Context.ManagedGroups.Remove(DeviceBatchAssignedUsersManagedGroup.GetKey(db)); + // Delete Batch Database.DeviceBatches.Remove(db); } diff --git a/Disco.BI/BI/Extensions/DeviceProfileExtensions.cs b/Disco.BI/BI/Extensions/DeviceProfileExtensions.cs index c339317c..d9ae1454 100644 --- a/Disco.BI/BI/Extensions/DeviceProfileExtensions.cs +++ b/Disco.BI/BI/Extensions/DeviceProfileExtensions.cs @@ -1,13 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Disco.Models.Repository; -using Disco.Data.Repository; -using Disco.Data.Configuration.Modules; +using Disco.Data.Repository; using Disco.Models.BI.Config; -using Disco.Services.Users; +using Disco.Models.Repository; using Disco.Services.Authorization; +using Disco.Services.Devices.ManagedGroups; +using Disco.Services.Interop.ActiveDirectory; +using Disco.Services.Users; +using System; +using System.Linq; namespace Disco.BI.Extensions { @@ -58,6 +57,10 @@ namespace Disco.BI.Extensions if (Database.DiscoConfiguration.DeviceProfiles.DefaultAddDeviceOfflineDeviceProfileId == dp.Id) Database.DiscoConfiguration.DeviceProfiles.DefaultAddDeviceOfflineDeviceProfileId = 1; + // Remove Linked Group + ActiveDirectory.Context.ManagedGroups.Remove(DeviceProfileDevicesManagedGroup.GetKey(dp)); + ActiveDirectory.Context.ManagedGroups.Remove(DeviceProfileAssignedUsersManagedGroup.GetKey(dp)); + // Delete Profile Database.DeviceProfiles.Remove(dp); } diff --git a/Disco.BI/BI/Extensions/DocumentTemplateExtensions.cs b/Disco.BI/BI/Extensions/DocumentTemplateExtensions.cs index 62baa538..ffc07aaa 100644 --- a/Disco.BI/BI/Extensions/DocumentTemplateExtensions.cs +++ b/Disco.BI/BI/Extensions/DocumentTemplateExtensions.cs @@ -1,17 +1,17 @@ -using System; -using System.Collections.Concurrent; -using System.Linq; -using System.Web; +using Disco.BI.DocumentTemplateBI; +using Disco.BI.DocumentTemplateBI.ManagedGroups; +using Disco.BI.Expressions; using Disco.Data.Repository; using Disco.Models.BI.DocumentTemplates; using Disco.Models.Repository; -using System.Collections; -using System.Collections.Generic; +using Disco.Services.Interop.ActiveDirectory; using iTextSharp.text.pdf; -using Disco.BI.Expressions; +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; using System.Drawing; using System.IO; -using Disco.BI.DocumentTemplateBI; +using System.Linq; namespace Disco.BI.Extensions { @@ -273,6 +273,10 @@ namespace Disco.BI.Extensions a.DocumentTemplate = null; } + // Remove Linked Group + ActiveDirectory.Context.ManagedGroups.Remove(DocumentTemplateDevicesManagedGroup.GetKey(dt)); + ActiveDirectory.Context.ManagedGroups.Remove(DocumentTemplateUsersManagedGroup.GetKey(dt)); + // Delete SubTypes dt.JobSubTypes.Clear();