public static TemplateDto FromDomainObject(Template source) { var result = SimpleMapper.Map(source, new TemplateDto()); if (source.Formatting != null) { result.Formatting = NotificationFormattingDto.FromDomainObject(source.Formatting); } else { result.Formatting = new NotificationFormattingDto(); } if (source.Settings != null) { foreach (var(key, value) in source.Settings) { if (value != null) { result.Settings[key] = NotificationSettingDto.FromDomainObject(value); } } } return(result); }
public static EventDto FromDomainObject(Event @event, App app) { var result = SimpleMapper.Map(@event, new EventDto()); if (@event.Formatting.Subject.TryGetValue(app.Language, out var subject)) { result.DisplayName = subject; } else { result.DisplayName = @event.Formatting.Subject.Values.FirstOrDefault() ?? string.Empty; } result.Properties = @event.Properties ?? EmptyProperties; result.Settings ??= new Dictionary <string, NotificationSettingDto>(); if (@event.Settings != null) { foreach (var(key, value) in @event.Settings) { if (value != null) { result.Settings[key] = NotificationSettingDto.FromDomainObject(value); } } } result.Counters = @event.Counters ?? EmptyCounters; return(result); }
public static SubscriptionDto FromDomainObject(Subscription subscription) { var result = new SubscriptionDto { TopicPrefix = subscription.TopicPrefix }; if (subscription.TopicSettings != null) { result.TopicSettings = new NotificationSettingsDto(); foreach (var(key, value) in subscription.TopicSettings) { if (value != null) { result.TopicSettings[key] = NotificationSettingDto.FromDomainObject(value); } } } else { result.TopicSettings = new NotificationSettingsDto(); } return(result); }
public static TemplateDto FromDomainObject(Template template) { var result = SimpleMapper.Map(template, new TemplateDto()); if (template.Formatting != null) { result.Formatting = NotificationFormattingDto.FromDomainObject(template.Formatting); } else { result.Formatting = new NotificationFormattingDto(); } result.Settings ??= new Dictionary <string, NotificationSettingDto>(); if (template.Settings != null) { foreach (var(key, value) in template.Settings) { if (value != null) { result.Settings[key] = NotificationSettingDto.FromDomainObject(value); } } } return(result); }
public static UserDto FromDomainObject(User user) { var result = SimpleMapper.Map(user, new UserDto()); if (user.Settings != null) { result.Settings = new NotificationSettingsDto(); foreach (var(key, value) in user.Settings) { if (value != null) { result.Settings[key] = NotificationSettingDto.FromDomainObject(value); } } } else { result.Settings = new NotificationSettingsDto(); } if (result.Counters == null) { result.Counters = new CounterMap(); } return(result); }
public static ProfileDto FromDomainObject(User user, App app) { var result = SimpleMapper.Map(user, new ProfileDto()); result.SupportedTimezones = DateTimeZoneProviders.Tzdb.Ids.ToArray(); result.SupportedLanguages = app.Languages; if (user.Settings != null) { result.Settings = new NotificationSettingsDto(); foreach (var(key, value) in user.Settings) { if (value != null) { result.Settings[key] = NotificationSettingDto.FromDomainObject(value); } } } else { result.Settings = new NotificationSettingsDto(); } return(result); }
public static EventDto FromDomainObject(Event source, App app) { var result = SimpleMapper.Map(source, new EventDto()); if (source.Formatting.Subject.TryGetValue(app.Language, out var subject)) { result.DisplayName = subject; } else { result.DisplayName = source.Formatting.Subject.Values.FirstOrDefault() ?? string.Empty; } result.Settings = new NotificationSettingsDto(); if (source.Settings != null) { foreach (var(key, value) in source.Settings) { if (value != null) { result.Settings[key] = NotificationSettingDto.FromDomainObject(value); } } } if (result.Formatting == null) { result.Formatting = new NotificationFormattingDto(); } if (result.Properties == null) { result.Properties = new EventProperties(); } if (result.Counters == null) { result.Counters = new CounterMap(); } return(result); }
public static UserDto FromDomainObject(User user) { var result = SimpleMapper.Map(user, new UserDto()); result.Settings ??= new Dictionary <string, NotificationSettingDto>(); if (user.Settings != null) { foreach (var(key, value) in user.Settings) { if (value != null) { result.Settings[key] = NotificationSettingDto.FromDomainObject(value); } } } result.Counters = user.Counters ?? EmptyCounters; return(result); }
public static SubscriptionDto FromDomainObject(Subscription subscription) { var result = new SubscriptionDto { TopicPrefix = subscription.TopicPrefix }; result.TopicSettings ??= new Dictionary <string, NotificationSettingDto>(); if (subscription.TopicSettings != null) { foreach (var(key, value) in subscription.TopicSettings) { if (value != null) { result.TopicSettings[key] = NotificationSettingDto.FromDomainObject(value); } } } return(result); }