private void MapOrganizationSettings(Organization organization, IEnumerable<OrganizationSettingModel> settings) { foreach (var setting in settings) { var orgSetting = organization.GetSetting(setting.Name); if (orgSetting != null) { if (!string.IsNullOrEmpty(setting.Value)) { orgSetting.Value = setting.Value; } else { OrganizationRepository.DeleteSetting(orgSetting); } } else { if (!string.IsNullOrEmpty(setting.Value)) { organization.OrganizationSettings.Add(new OrganizationSetting { Name = setting.Name, Value = setting.Value, DataType = (int) DataType.String }); } } } }
private static OrganizationDetailsModel MapOrganizationDetails(Organization organization) { var model = Mapper.Map<Organization, OrganizationDetailsModel>(organization); model.OrganizationSettings = new List<OrganizationSettingModel>(); var keys = ModelHelpers.GetKeys(typeof(OrgSettingKeys)); foreach (var key in keys) { var setting = organization.GetSetting(key); OrganizationSettingModel settingModel; if (setting != null) { settingModel = Mapper.Map<OrganizationSetting, OrganizationSettingModel>(setting); } else { settingModel = new OrganizationSettingModel { DataType = (int) DataType.String, Name = key }; } model.OrganizationSettings.Add(settingModel); } return model; }