public static PSADObject ToPSADObject(this Common.MSGraph.Version1_0.DirectoryObjects.Models.MicrosoftGraphDirectoryObject obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException();
            }

            if (obj.IsUser())
            {
                return(JsonConvert.DeserializeObject <MicrosoftGraphUser>(JsonConvert.SerializeObject(obj)).ToPSADUser());
            }
            if (obj.IsServicePrincipal())
            {
                return(JsonConvert.DeserializeObject <MicrosoftGraphServicePrincipal>(JsonConvert.SerializeObject(obj)).ToPSADServicePrincipal());
            }
            if (obj.IsGroup())
            {
                return(JsonConvert.DeserializeObject <MicrosoftGraphGroup>(JsonConvert.SerializeObject(obj)).ToPSADGroup());
            }

            return(new PSADObject()
            {
                Id = obj.Id,
                DeletionTimestamp = obj.DeletedDateTime
            });
        }
 public static bool IsGroup(this Common.MSGraph.Version1_0.DirectoryObjects.Models.MicrosoftGraphDirectoryObject obj)
 {
     return(string.Equals(obj.Odatatype, "#microsoft.graph.group", StringComparison.OrdinalIgnoreCase));
 }