public static bool TryGetManagedGroup(DeviceBatch DeviceBatch, out DeviceBatchDevicesManagedGroup ManagedGroup) { ADManagedGroup managedGroup; string key = GetKey(DeviceBatch); if (ActiveDirectory.Context.ManagedGroups.TryGetValue(key, out managedGroup)) { ManagedGroup = (DeviceBatchDevicesManagedGroup)managedGroup; return true; } else { ManagedGroup = null; return false; } }
private void UpdateInsuranceDetails(DeviceBatch deviceBatch, string InsuranceDetails) { if (string.IsNullOrWhiteSpace(InsuranceDetails)) deviceBatch.InsuranceDetails = null; else deviceBatch.InsuranceDetails = InsuranceDetails; Database.SaveChanges(); }
private void UpdateInsuredUntil(DeviceBatch deviceBatch, string InsuredUntil) { if (string.IsNullOrEmpty(InsuredUntil)) deviceBatch.InsuredUntil = null; else { DateTime ecd; if (DateTime.TryParse(InsuredUntil, out ecd)) { deviceBatch.InsuredUntil = ecd.Date; } else { throw new Exception("Invalid Date Format"); } } Database.SaveChanges(); }
private void UpdateInsuranceSupplier(DeviceBatch deviceBatch, string InsuranceSupplier) { if (string.IsNullOrWhiteSpace(InsuranceSupplier)) deviceBatch.InsuranceSupplier = null; else deviceBatch.InsuranceSupplier = InsuranceSupplier; Database.SaveChanges(); }
private void UpdateWarrantyDetails(DeviceBatch deviceBatch, string WarrantyDetails) { if (string.IsNullOrWhiteSpace(WarrantyDetails)) deviceBatch.WarrantyDetails = null; else deviceBatch.WarrantyDetails = WarrantyDetails; Database.SaveChanges(); }
private void UpdateDefaultDeviceModelId(DeviceBatch deviceBatch, string DefaultDeviceModelId) { if (!string.IsNullOrEmpty(DefaultDeviceModelId)) { int bId; if (int.TryParse(DefaultDeviceModelId, out bId)) { var dm = Database.DeviceModels.Find(bId); if (dm != null) { deviceBatch.DefaultDeviceModelId = dm.Id; deviceBatch.DefaultDeviceModel = dm; Database.SaveChanges(); return; } } } else { // Null Id - No Batch deviceBatch.DefaultDeviceModelId = null; deviceBatch.DefaultDeviceModel = null; Database.SaveChanges(); return; } throw new Exception("Invalid Device Model Id"); }
private void UpdateUnitQuantity(DeviceBatch deviceBatch, string UnitQuantity) { if (string.IsNullOrWhiteSpace(UnitQuantity)) deviceBatch.UnitQuantity = null; else { int unitQuantity; if (int.TryParse(UnitQuantity, out unitQuantity)) { deviceBatch.UnitQuantity = unitQuantity; } else { throw new Exception("Invalid Number"); } } Database.SaveChanges(); }
public static string GetKey(DeviceBatch DeviceBatch) { return string.Format(KeyFormat, DeviceBatch.Id); }
private void UpdatePurchaseDetails(DeviceBatch deviceBatch, string PurchaseDetails) { if (string.IsNullOrWhiteSpace(PurchaseDetails)) deviceBatch.PurchaseDetails = null; else deviceBatch.PurchaseDetails = PurchaseDetails; Database.SaveChanges(); }
private void UpdatePurchaseDate(DeviceBatch deviceBatch, string PurchaseDate) { if (string.IsNullOrEmpty(PurchaseDate)) throw new ArgumentNullException("PurchaseDate", "A Device Batch Purchase Date is required"); else { DateTime ecd; if (DateTime.TryParse(PurchaseDate, out ecd)) { deviceBatch.PurchaseDate = ecd.Date; } else { throw new Exception("Invalid Date Format"); } } Database.SaveChanges(); }
private void UpdateName(DeviceBatch deviceBatch, string Name) { if (string.IsNullOrWhiteSpace(Name)) throw new ArgumentNullException("Name", "Device Batch Name is required"); else { // Check for Duplicates var d = Database.DeviceBatches.Where(db => db.Id != deviceBatch.Id && db.Name == Name).Count(); if (d > 0) { throw new Exception("A Device Batch with that name already exists"); } deviceBatch.Name = Name; } Database.SaveChanges(); }
public static DeviceBatchDevicesManagedGroup Initialize(DeviceBatch DeviceBatch) { if (DeviceBatch.Id > 0) { var key = GetKey(DeviceBatch); if (!string.IsNullOrEmpty(DeviceBatch.DevicesLinkedGroup)) { var config = ADManagedGroup.ConfigurationFromJson(DeviceBatch.DevicesLinkedGroup); if (config != null && !string.IsNullOrWhiteSpace(config.GroupId)) { var group = new DeviceBatchDevicesManagedGroup( key, config, DeviceBatch); // Add to AD Context ActiveDirectory.Context.ManagedGroups.AddOrUpdate(group); return group; } } // Remove from AD Context ActiveDirectory.Context.ManagedGroups.Remove(key); } return null; }
public static string GetCategoryDescription(DeviceBatch DeviceBatch) { return CategoryDescriptionFormat; }
public static string GetDescription(DeviceBatch DeviceBatch) { return string.Format(DescriptionFormat, DeviceBatch.Name); }
private void UpdateComments(DeviceBatch deviceBatch, string Comments) { if (string.IsNullOrWhiteSpace(Comments)) deviceBatch.Comments = null; else deviceBatch.Comments = Comments; Database.SaveChanges(); }
private void UpdateUnitCost(DeviceBatch deviceBatch, string UnitCost) { if (string.IsNullOrWhiteSpace(UnitCost)) deviceBatch.UnitCost = null; else { decimal unitCost; if (decimal.TryParse(UnitCost, out unitCost)) { deviceBatch.UnitCost = unitCost; } else { throw new Exception("Invalid Currency Format"); } } Database.SaveChanges(); }
private ScheduledTaskStatus UpdateAssignedUsersLinkedGroup(DeviceBatch DeviceBatch, string AssignedUsersLinkedGroup) { var configJson = ADManagedGroup.ValidConfigurationToJson(DeviceBatchAssignedUsersManagedGroup.GetKey(DeviceBatch), AssignedUsersLinkedGroup, null); if (DeviceBatch.AssignedUsersLinkedGroup != configJson) { DeviceBatch.AssignedUsersLinkedGroup = configJson; Database.SaveChanges(); var managedGroup = DeviceBatchAssignedUsersManagedGroup.Initialize(DeviceBatch); if (managedGroup != null) // Sync Group return ADManagedGroupsSyncTask.ScheduleSync(managedGroup); } return null; }
private DeviceBatchDevicesManagedGroup(string Key, ADManagedGroupConfiguration Configuration, DeviceBatch DeviceBatch) : base(Key, Configuration) { this.DeviceBatchId = DeviceBatch.Id; this.DeviceBatchName = DeviceBatch.Name; }