diff --git a/src/Altinn.Notifications.Core/Services/OrderRequestService.cs b/src/Altinn.Notifications.Core/Services/OrderRequestService.cs index 4e034f8af..8ed835668 100644 --- a/src/Altinn.Notifications.Core/Services/OrderRequestService.cs +++ b/src/Altinn.Notifications.Core/Services/OrderRequestService.cs @@ -18,6 +18,7 @@ public class OrderRequestService : IOrderRequestService private readonly IGuidService _guid; private readonly IDateTimeService _dateTime; private readonly string _defaultEmailFromAddress; + private readonly string _defaultSenderNumber; /// /// Initializes a new instance of the class. @@ -28,6 +29,7 @@ public OrderRequestService(IOrderRepository repository, IGuidService guid, IDate _guid = guid; _dateTime = dateTime; _defaultEmailFromAddress = config.Value.DefaultEmailFromAddress; + _defaultSenderNumber = config.Value.DefaultSenderNumber; } /// @@ -36,7 +38,7 @@ public OrderRequestService(IOrderRepository repository, IGuidService guid, IDate Guid orderId = _guid.NewGuid(); DateTime created = _dateTime.UtcNow(); - var templates = SetFromAddressIfNotDefined(orderRequest.Templates); + var templates = SetFromAddressOrSenderNumberIfNotDefined(orderRequest.Templates); var order = new NotificationOrder( orderId, @@ -53,13 +55,18 @@ public OrderRequestService(IOrderRepository repository, IGuidService guid, IDate return (savedOrder, null); } - private List SetFromAddressIfNotDefined(List templates) + private List SetFromAddressOrSenderNumberIfNotDefined(List templates) { foreach (var template in templates.OfType().Where(template => string.IsNullOrEmpty(template.FromAddress))) { template.FromAddress = _defaultEmailFromAddress; } + foreach (var template in templates.OfType().Where(template => string.IsNullOrEmpty(template.SenderNumber))) + { + template.SenderNumber = _defaultSenderNumber; + } + return templates; } }