예제 #1
0
        /// <summary>
        /// Merges the specified organizations.
        /// </summary>
        /// <param name="organizations">The organizations.</param>
        /// <param name="organization">The organization.</param>
        /// <returns>True if Changed.</returns>
        public static bool Merge(this ExtensionCollection <Organization> organizations, Organization organization)
        {
            if ((!string.IsNullOrWhiteSpace(organization.Name) || !string.IsNullOrWhiteSpace(organization.Department)))
            {
                var result = false;

                if (organizations.Any(e => e.Name == organization.Name))
                {
                    var org = organizations.First(e => e.Name == organization.Name);
                    result |= org.ApplyProperty(o => o.Department, organization.Department);
                    result |= org.ApplyProperty(o => o.Title, organization.Title);
                }
                else
                {
                    organizations.Add(organization);
                    result = true;
                }

                if (organizations.Any() && !organizations.Any(e => e.Primary))
                {
                    organizations.First().Primary = true;
                }

                return(result);
            }

            return(false);
        }
예제 #2
0
        /// <summary>
        /// Merges the specified ims.
        /// </summary>
        /// <param name="ims">The ims.</param>
        /// <param name="im">The im.</param>
        /// <returns>True if Changed.</returns>
        public static bool Merge(this ExtensionCollection <IMAddress> ims, IMAddress im)
        {
            if (!string.IsNullOrWhiteSpace(im.Address) && !ims.Any(e => e.Address == im.Address))
            {
                ims.Add(im);

                if (ims.Any() && !ims.Any(e => e.Primary))
                {
                    ims.First().Primary = true;
                }

                return(true);
            }

            return(false);
        }
예제 #3
0
        /// <summary>
        /// Merges the specified websites.
        /// </summary>
        /// <param name="websites">The websites.</param>
        /// <param name="website">The website.</param>
        /// <returns>True if Changed.</returns>
        public static bool Merge(this ExtensionCollection <Website> websites, Website website)
        {
            if (!string.IsNullOrWhiteSpace(website.Href) && !websites.Any(e => e.Href == website.Href))
            {
                websites.Add(website);

                if (websites.Any() && !websites.Any(e => e.Primary))
                {
                    websites.First().Primary = true;
                }

                return(true);
            }

            return(false);
        }
예제 #4
0
        /// <summary>
        /// Merges the specified emails.
        /// </summary>
        /// <param name="emails">The emails.</param>
        /// <param name="mail">The mail.</param>
        /// <returns>True if Changed.</returns>
        public static bool Merge(this ExtensionCollection <EMail> emails, EMail mail)
        {
            if (!string.IsNullOrWhiteSpace(mail.Address) && !emails.Any(e => e.Address == mail.Address))
            {
                emails.Add(mail);

                if (emails.Any() && !emails.Any(e => e.Primary))
                {
                    emails.First().Primary = true;
                }

                return(true);
            }

            return(false);
        }