private void UpdateMetadataFromModel(SimpleMetadataViewModel model, SimpleMetadata metadata) { metadata.ParentIdentifier = model.ParentIdentifier; metadata.Title = model.Title; metadata.Abstract = model.Abstract; metadata.SupplementalDescription = model.SupplementalDescription; metadata.SpecificUsage = !string.IsNullOrWhiteSpace(model.SpecificUsage) ? model.SpecificUsage : " "; metadata.ProcessHistory = !string.IsNullOrWhiteSpace(model.ProcessHistory) ? model.ProcessHistory : " "; metadata.ProductPageUrl = model.ProductPageUrl; var contactMetadata = model.ContactMetadata.ToSimpleContact(); if (!string.IsNullOrWhiteSpace(model.EnglishContactMetadataOrganization)) { contactMetadata.OrganizationEnglish = model.EnglishContactMetadataOrganization; } metadata.ContactMetadata = contactMetadata; var contactPublisher = model.ContactPublisher.ToSimpleContact(); if (!string.IsNullOrWhiteSpace(model.EnglishContactPublisherOrganization)) { contactPublisher.OrganizationEnglish = model.EnglishContactPublisherOrganization; } metadata.ContactPublisher = contactPublisher; var contactOwner = model.ContactOwner.ToSimpleContact(); if (!string.IsNullOrWhiteSpace(model.EnglishContactOwnerOrganization)) { contactOwner.OrganizationEnglish = model.EnglishContactOwnerOrganization; } metadata.ContactOwner = contactOwner; if (!string.IsNullOrWhiteSpace(model.BoundingBoxEast)) { metadata.BoundingBox = new SimpleBoundingBox { EastBoundLongitude = model.BoundingBoxEast, WestBoundLongitude = model.BoundingBoxWest, NorthBoundLatitude = model.BoundingBoxNorth, SouthBoundLatitude = model.BoundingBoxSouth }; } string accessConstraintsSelected = ""; if (!string.IsNullOrEmpty(model.OtherConstraintsAccess)) { if (model.OtherConstraintsAccess.ToLower() == "no restrictions") { accessConstraintsSelected = "otherRestrictions"; } } if (!string.IsNullOrWhiteSpace(model.MaintenanceFrequency)) { metadata.MaintenanceFrequency = model.MaintenanceFrequency; } metadata.DateUpdated = model.DateUpdated; //Keep if other keywords than in model List <SimpleKeyword> keywordsNotInModel = metadata.Keywords.Where(k => k.Thesaurus != SimpleKeyword.THESAURUS_NATIONAL_INITIATIVE && k.Thesaurus != SimpleKeyword.THESAURUS_NATIONAL_THEME && k.Type != SimpleKeyword.TYPE_PLACE).ToList(); //Get keywords in model List <SimpleKeyword> keywordsToUpdate = model.GetAllKeywords(); bool hasEnglishFields = false; // don't create PT_FreeText fields if it isn't necessary if (!string.IsNullOrWhiteSpace(model.EnglishTitle)) { metadata.EnglishTitle = model.EnglishTitle; hasEnglishFields = true; } if (!string.IsNullOrWhiteSpace(model.EnglishAbstract)) { metadata.EnglishAbstract = model.EnglishAbstract; hasEnglishFields = true; } if (hasEnglishFields) { metadata.SetLocale(SimpleMetadata.LOCALE_ENG); } metadata.Keywords = keywordsNotInModel.Concat(keywordsToUpdate).ToList(); metadata.DistributionDetails = new SimpleDistributionDetails { URL = model.DistributionUrl, Protocol = model.DistributionProtocol }; metadata.Constraints = new SimpleConstraints { UseConstraints = "license", OtherConstraints = !string.IsNullOrWhiteSpace(accessConstraintsSelected) ? accessConstraintsSelected : null, OtherConstraintsLink = !string.IsNullOrWhiteSpace(model.OtherConstraintsLink) ? model.OtherConstraintsLink : null, OtherConstraintsLinkText = !string.IsNullOrWhiteSpace(model.OtherConstraintsLinkText) ? model.OtherConstraintsLinkText : null, OtherConstraintsAccess = !string.IsNullOrWhiteSpace(model.OtherConstraintsAccess) ? model.OtherConstraintsAccess : null }; SetDefaultValuesOnMetadata(metadata); }
private void UpdateMetadataFromModel(SimpleMetadataViewModel model, SimpleMetadata metadata) { metadata.ParentIdentifier = model.ParentIdentifier; metadata.Title = model.Title; metadata.Abstract = model.Abstract; metadata.SupplementalDescription = model.SupplementalDescription; metadata.SpecificUsage = !string.IsNullOrWhiteSpace(model.SpecificUsage) ? model.SpecificUsage : " "; metadata.ProcessHistory = !string.IsNullOrWhiteSpace(model.ProcessHistory) ? model.ProcessHistory : " "; metadata.ProductPageUrl = model.ProductPageUrl; var contactMetadata = model.ContactMetadata.ToSimpleContact(); if (!string.IsNullOrWhiteSpace(model.EnglishContactMetadataOrganization)) { contactMetadata.OrganizationEnglish = model.EnglishContactMetadataOrganization; } metadata.ContactMetadata = contactMetadata; var contactPublisher = model.ContactPublisher.ToSimpleContact(); if (!string.IsNullOrWhiteSpace(model.EnglishContactPublisherOrganization)) { contactPublisher.OrganizationEnglish = model.EnglishContactPublisherOrganization; } metadata.ContactPublisher = contactPublisher; var contactOwner = model.ContactOwner.ToSimpleContact(); if (!string.IsNullOrWhiteSpace(model.EnglishContactOwnerOrganization)) { contactOwner.OrganizationEnglish = model.EnglishContactOwnerOrganization; } metadata.ContactOwner = contactOwner; if (!string.IsNullOrWhiteSpace(model.BoundingBoxEast)) { metadata.BoundingBox = new SimpleBoundingBox { EastBoundLongitude = model.BoundingBoxEast, WestBoundLongitude = model.BoundingBoxWest, NorthBoundLatitude = model.BoundingBoxNorth, SouthBoundLatitude = model.BoundingBoxSouth }; } string accessConstraintsSelected = ""; if (!string.IsNullOrEmpty(model.OtherConstraintsAccess)) { if (model.OtherConstraintsAccess.ToLower() == "no restrictions") { accessConstraintsSelected = "otherRestrictions"; } } if (!string.IsNullOrWhiteSpace(model.MaintenanceFrequency)) metadata.MaintenanceFrequency = model.MaintenanceFrequency; metadata.DateUpdated = model.DateUpdated; //Keep if other keywords than in model List<SimpleKeyword> keywordsNotInModel = metadata.Keywords.Where(k => k.Thesaurus != SimpleKeyword.THESAURUS_NATIONAL_INITIATIVE && k.Thesaurus != SimpleKeyword.THESAURUS_NATIONAL_THEME && k.Type != SimpleKeyword.TYPE_PLACE).ToList(); //Get keywords in model List<SimpleKeyword> keywordsToUpdate = model.GetAllKeywords(); bool hasEnglishFields = false; // don't create PT_FreeText fields if it isn't necessary if (!string.IsNullOrWhiteSpace(model.EnglishTitle)) { metadata.EnglishTitle = model.EnglishTitle; hasEnglishFields = true; } if (!string.IsNullOrWhiteSpace(model.EnglishAbstract)) { metadata.EnglishAbstract = model.EnglishAbstract; hasEnglishFields = true; } if (hasEnglishFields) metadata.SetLocale(SimpleMetadata.LOCALE_ENG); metadata.Keywords = keywordsNotInModel.Concat(keywordsToUpdate).ToList(); metadata.DistributionDetails = new SimpleDistributionDetails { URL = model.DistributionUrl, Protocol = model.DistributionProtocol }; metadata.Constraints = new SimpleConstraints { UseConstraints = "license", OtherConstraints = !string.IsNullOrWhiteSpace(accessConstraintsSelected) ? accessConstraintsSelected : null, OtherConstraintsLink = !string.IsNullOrWhiteSpace(model.OtherConstraintsLink) ? model.OtherConstraintsLink : null, OtherConstraintsLinkText = !string.IsNullOrWhiteSpace(model.OtherConstraintsLinkText) ? model.OtherConstraintsLinkText : null, OtherConstraintsAccess = !string.IsNullOrWhiteSpace(model.OtherConstraintsAccess) ? model.OtherConstraintsAccess : null }; SetDefaultValuesOnMetadata(metadata); }