Disco.Services.Devices.ManagedGroups.DeviceBatchDevicesManagedGroup.ProcessRepositoryEvent C# (CSharp) Method

ProcessRepositoryEvent() private method

private ProcessRepositoryEvent ( RepositoryMonitorEvent Event ) : void
Event RepositoryMonitorEvent
return void
        private void ProcessRepositoryEvent(RepositoryMonitorEvent Event)
        {
            var device = (Device)Event.Entity;
            string previousDeviceDomainId = Event.GetPreviousPropertyValue<string>("DeviceDomainId");

            Event.ExecuteAfterCommit(e =>
            {
                switch (e.EventType)
                {
                    case RepositoryMonitorEventType.Added:
                        AddMember(device.DeviceDomainId + "$");
                        break;
                    case RepositoryMonitorEventType.Modified:
                        if (device.DeviceBatchId == this.DeviceBatchId)
                        {
                            if (ActiveDirectory.IsValidDomainAccountId(device.DeviceDomainId))
                                AddMember(device.DeviceDomainId + "$");

                            if (e.ModifiedProperties.Contains("DeviceDomainId"))
                            {
                                if (ActiveDirectory.IsValidDomainAccountId(previousDeviceDomainId))
                                    RemoveMember(previousDeviceDomainId + "$");
                            }
                        }
                        else
                        {
                            if (e.ModifiedProperties.Contains("DeviceDomainId"))
                            {
                                if (ActiveDirectory.IsValidDomainAccountId(previousDeviceDomainId))
                                    RemoveMember(previousDeviceDomainId + "$");
                            }
                            else
                            {
                                if (ActiveDirectory.IsValidDomainAccountId(device.DeviceDomainId))
                                    RemoveMember(device.DeviceDomainId + "$");
                            }
                        }
                        break;
                    case RepositoryMonitorEventType.Deleted:
                        if (ActiveDirectory.IsValidDomainAccountId(previousDeviceDomainId))
                            RemoveMember(previousDeviceDomainId + "$");
                        break;
                }
            });
        }