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 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 source, App app) { var result = SimpleMapper.Map(source, new EventDto { Settings = new Dictionary <string, ChannelSettingDto>() }); result.Properties = source.Properties ?? EmptyProperties; if (source.Formatting.Subject.TryGetValue(app.Language, out var subject)) { result.DisplayName = subject; } else { result.DisplayName = source.Formatting.Subject.Values.FirstOrDefault() ?? string.Empty; } if (source.Formatting != null) { result.Formatting = NotificationFormattingDto.FromDomainObject(source.Formatting); } if (source.Scheduling != null) { result.Scheduling = SchedulingDto.FromDomainObject(source.Scheduling); } if (source.Settings?.Count > 0) { result.Settings = new Dictionary <string, ChannelSettingDto>(); foreach (var(key, value) in source.Settings) { if (value != null) { result.Settings[key] = ChannelSettingDto.FromDomainObject(value); } } } else { result.Settings = EmptySettings; } result.Counters = source.Counters ?? EmptyCounters; return(result); }