Ejemplo n.º 1
0
        public static UserOrganization ToModel(this OrganizationDTO source)
        {
            if (source == null)
            {
                return(null);
            }

            var userOrganization = new UserOrganization(source);

            if (source.Identifier != null || source.AdditionalIdentifiers?.Count > 0)
            {
                List <UserOrganizationIdentifier> allIdentifiers = new List <UserOrganizationIdentifier>();
                if (source.Identifier != null)
                {
                    allIdentifiers.Add(new UserOrganizationIdentifier(source.Identifier)
                    {
                        Main = true
                    });
                }
                if (source.AdditionalIdentifiers != null)
                {
                    allIdentifiers.AddRange(source.AdditionalIdentifiers?.Select(i => new UserOrganizationIdentifier(i)));
                }
                userOrganization.AllIdentifiers = allIdentifiers;
            }

            return(userOrganization.InitComplexProperties());
        }