1+ using System . Net . Mail ;
12using System . Security . Claims ;
23using System . Text ;
34using Microsoft . EntityFrameworkCore ;
45using Microsoft . Extensions . Options ;
5- using TNO . Ches ;
6+ using MMI . SmtpEmail ;
67using TNO . Core . Exceptions ;
78using TNO . Core . Extensions ;
89using TNO . DAL . Services ;
@@ -21,8 +22,7 @@ public class WatchSubscriptionChange
2122 private readonly IReportService _reportService ;
2223 private readonly IProductService _productService ;
2324 private readonly INotificationService _notificationService ;
24- private readonly IChesService _chesService ;
25- private readonly Ches . Configuration . ChesOptions _chesOptions ;
25+ private readonly IEmailService _emailService ;
2626
2727 /// <summary>
2828 /// SubscriptionChange enum, identifies the type of change.
@@ -132,26 +132,23 @@ public class WatchOptions
132132 /// <param name="reportService"></param>
133133 /// <param name="productService"></param>
134134 /// <param name="notificationService"></param>
135- /// <param name="chesService"></param>
136- /// <param name="chesOptions"></param>
135+ /// <param name="emailService"></param>
137136 /// <param name="watchOptions"></param>
138137 /// <param name="logger"></param>
139138 public WatchSubscriptionChange (
140139 IUserService userService ,
141140 IReportService reportService ,
142141 IProductService productService ,
143142 INotificationService notificationService ,
144- IChesService chesService ,
145- IOptions < Ches . Configuration . ChesOptions > chesOptions ,
143+ IEmailService emailService ,
146144 IOptions < WatchOptions > watchOptions ,
147145 ILogger < WatchSubscriptionChange > logger )
148146 {
149147 _userService = userService ;
150148 _reportService = reportService ;
151149 _productService = productService ;
152150 _notificationService = notificationService ;
153- _chesService = chesService ;
154- _chesOptions = chesOptions . Value ;
151+ _emailService = emailService ;
155152 this . Options = watchOptions . Value ;
156153 _logger = logger ;
157154 }
@@ -165,7 +162,7 @@ public WatchSubscriptionChange(
165162 /// <param name="changeSource">The source of the change, generally the user who made the change.</param>
166163 /// <param name="traceInformation">The location or other details to help trace the source of the change.</param>
167164 /// <returns></returns>
168- public Ches . Models . EmailModel GenerateEmail ( SubscriptionChange [ ] changes , string changeSource , string traceInformation )
165+ public MailMessage GenerateEmail ( SubscriptionChange [ ] changes , string changeSource , string traceInformation )
169166 {
170167 var body = new StringBuilder ( $ """
171168 <div>This is an alert to identify changes to user subscriptions.</div>
@@ -234,7 +231,7 @@ public Ches.Models.EmailModel GenerateEmail(SubscriptionChange[] changes, string
234231 }
235232
236233 var to = this . Options . SendTo . Split ( ',' ) ;
237- return new Ches . Models . EmailModel ( _chesOptions . From , to , "MMI - User Subscription Change Alert" , body . ToString ( ) ) ;
234+ return _emailService . CreateMailMessage ( "MMI - User Subscription Change Alert" , body . ToString ( ) , to , null , null , null , isHtml : true ) ;
238235 }
239236
240237 #region Users
@@ -285,7 +282,7 @@ public async Task AlertUserSubscriptionChangedAsync(Entities.User user, string c
285282 if ( changes . Length > 0 )
286283 {
287284 var email = GenerateEmail ( changes , changeSource , traceInformation ) ;
288- await _chesService . SendEmailAsync ( email ) ;
285+ await _emailService . SendAsync ( email ) ;
289286 }
290287 }
291288 #endregion
@@ -335,7 +332,7 @@ public async Task AlertProductSubscriptionChangedAsync(Entities.Product product,
335332 if ( changes . Length > 0 )
336333 {
337334 var email = GenerateEmail ( changes , changeSource , traceInformation ) ;
338- await _chesService . SendEmailAsync ( email ) ;
335+ await _emailService . SendAsync ( email ) ;
339336 }
340337 }
341338 #endregion
@@ -385,7 +382,7 @@ public async Task AlertReportSubscriptionChangedAsync(Entities.Report report, st
385382 if ( changes . Length > 0 )
386383 {
387384 var email = GenerateEmail ( changes , changeSource , traceInformation ) ;
388- await _chesService . SendEmailAsync ( email ) ;
385+ await _emailService . SendAsync ( email ) ;
389386 }
390387 }
391388 #endregion
@@ -435,7 +432,7 @@ public async Task AlertNotificationSubscriptionChangedAsync(Entities.Notificatio
435432 if ( changes . Length > 0 )
436433 {
437434 var email = GenerateEmail ( changes , changeSource , traceInformation ) ;
438- await _chesService . SendEmailAsync ( email ) ;
435+ await _emailService . SendAsync ( email ) ;
439436 }
440437 }
441438 #endregion
0 commit comments