Ejemplo n.º 1
0
        public static void CapturePropertiesForAdd(ObjectContext context, OrgUnitV2 source, OrgUnit target)
        {
            target.SetName(source.Name);
            target.SetAddress1(source.Address1);
            target.SetAddress2(source.Address2);
            target.SetCity(source.City);
            target.SetPostalCode(source.PostalCode);
            target.SetPhone(source.Phone);
            target.SetFax(source.Fax);
            target.SetCustomUrl(source.CustomUrl);
            target.SetCustomLiveUrl(source.CustomLiveUrl);
            target.SetCustomStageUrl(source.CustomStageUrl);
            target.SetCustomQaUrl(source.CustomQaUrl);
            target.SetCustomDevUrl(source.CustomDevUrl);
            target.SetServiceLineUrl(source.ServiceLineUrl);
            target.IsEnabled = source.IsEnabledAsBool.HasValue ? source.IsEnabledAsBool.Value : false;

            LookupStateId(context, source.State, target);
            LookupCountryId(context, source.Country, target);

            target.Latitude = source.LatitudeAsDecimal;
            target.Longitude = source.LongitudeAsDecimal;

            int pictureId;

            if (int.TryParse(source.PictureId, out pictureId))
            {
                target.ImageUrl = source.ImageUrl;
                target.PictureId = pictureId;
            }

            target.Keywords = source.Keywords;
            target.CustomKeywords = source.CustomKeywords;

            target.Custom1 = source.Custom1;
            target.Custom2 = source.Custom2;
            target.Custom3 = source.Custom3;
            target.PotentialEventLocation = source.IsPotentialEventLocationAsBool.HasValue ? source.IsPotentialEventLocationAsBool.Value : true;
            target.SeoPageTitle = source.SeoPageTitle;
            target.SeoPageDescription = source.SeoPageDescription;
            target.SeoCustomMetaTags = source.SeoCustomMetaTags;
            target.SeoH1tag = source.SeoH1Tag;
            target.SeoPrimaryKeyword = source.SeoPrimaryKeyword;
            target.SeoSecondaryKeyword = source.SeoSecondaryKeyword;
            target.SeoCanonicalUrl = source.SeoCanonicalUrl;
        }
Ejemplo n.º 2
0
        public static void CapturePropertiesForUpdate(ObjectContext context, OrgUnitV2 source, OrgUnit target)
        {
            //if source values are null, we do not update the field.
            if (source.Name != null)
                target.SetName(source.Name);

            if (source.Address1 != null)
                target.SetAddress1(source.Address1);

            if (source.Address2 != null)
                target.SetAddress2(source.Address2);

            if (source.City != null)
                target.SetCity(source.City);

            if (source.PostalCode != null)
                target.SetPostalCode(source.PostalCode);

            if (source.Phone != null)
                target.SetPhone(source.Phone);

            if (source.Email != null)
                target.Email = source.Email;

            if (source.Description != null)
                target.Description = source.Description;

            if (source.Fax != null)
                target.SetFax(source.Fax);

            if (source.CustomUrl != null)
                target.SetCustomUrl(source.CustomUrl);

            if (source.CustomLiveUrl != null)
                target.SetCustomLiveUrl(source.CustomLiveUrl);

            if (source.CustomStageUrl != null)
                target.SetCustomStageUrl(source.CustomStageUrl);

            if (source.CustomQaUrl != null)
                target.SetCustomQaUrl(source.CustomQaUrl);

            if (source.CustomDevUrl != null)
                target.SetCustomDevUrl(source.CustomDevUrl);

            if (source.ServiceLineUrl != null)
                target.SetServiceLineUrl(source.ServiceLineUrl);

            if (source.IsEnabled != null)
                target.IsEnabled = source.IsEnabledAsBool.HasValue ? source.IsEnabledAsBool.Value : false;

            if (source.State != null)
            {
                LookupStateId(context, source.State, target);
            }

            if (source.Country != null)
            {
                LookupCountryId(context, source.Country, target);
            }

            int pictureId;

            if (int.TryParse(source.PictureId, out pictureId))
            {
                target.ImageUrl = source.ImageUrl ?? target.ImageUrl;
                target.PictureId = pictureId;
            }

            if (source.Keywords != null)
                target.Keywords = source.Keywords;

            if (source.CustomKeywords != null)
                target.CustomKeywords = source.CustomKeywords;

            if (source.Latitude != null)
                target.Latitude = source.LatitudeAsDecimal;

            if (source.Longitude != null)
                target.Longitude = source.LongitudeAsDecimal;

            if (source.Custom1 != null)
                target.Custom1 = source.Custom1;

            if (source.Custom2 != null)
                target.Custom2 = source.Custom2;

            if (source.Custom3 != null)
                target.Custom3 = source.Custom3;

            if (source.IsPotentialEventLocation != null)
                target.PotentialEventLocation = source.IsPotentialEventLocationAsBool.HasValue ? source.IsPotentialEventLocationAsBool.Value : true;

            if (source.SeoPageTitle != null)
                target.SeoPageTitle = source.SeoPageTitle;

            if (source.SeoPageDescription != null)
                target.SeoPageDescription = source.SeoPageDescription;

            if (source.SeoCustomMetaTags != null)
                target.SeoCustomMetaTags = source.SeoCustomMetaTags;

            if (source.SeoH1Tag != null)
                target.SeoH1tag = source.SeoH1Tag;

            if (source.SeoPrimaryKeyword != null)
                target.SeoPrimaryKeyword = source.SeoPrimaryKeyword;

            if (source.SeoSecondaryKeyword != null)
                target.SeoSecondaryKeyword = source.SeoSecondaryKeyword;

            if (source.SeoCanonicalUrl != null)
                target.SeoCanonicalUrl = source.SeoCanonicalUrl;
        }