-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New - Envoi d'un email lorsqu'un producteur atteint 150€/mois de comm…
…ande
- Loading branch information
1 parent
4bc100f
commit ed55db4
Showing
3 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
Sheaft.Application.Events/Producer/ProducerDeclarationRequiredEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Sheaft.Core; | ||
using System; | ||
using Newtonsoft.Json; | ||
|
||
namespace Sheaft.Application.Events | ||
{ | ||
public class ProducerDeclarationRequiredEvent : Event | ||
{ | ||
[JsonConstructor] | ||
public ProducerDeclarationRequiredEvent(RequestUser requestUser) : base(requestUser) | ||
{ | ||
} | ||
|
||
public Guid ProducerId { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,8 @@ namespace Sheaft.Application.Handlers | |
public class ProducerEventsHandler : EventsHandler, | ||
INotificationHandler<ProducerDeclarationNotValidatedEvent>, | ||
INotificationHandler<ProducerDocumentsNotValidatedEvent>, | ||
INotificationHandler<ProducerRegisteredEvent> | ||
INotificationHandler<ProducerRegisteredEvent>, | ||
INotificationHandler<ProducerDeclarationRequiredEvent> | ||
{ | ||
public ProducerEventsHandler( | ||
IAppDbContext context, | ||
|
@@ -59,5 +60,17 @@ await _emailService.SendEmailAsync( | |
false, | ||
token); | ||
} | ||
|
||
public async Task Handle(ProducerDeclarationRequiredEvent notification, CancellationToken token) | ||
{ | ||
var producer = await _context.GetSingleAsync<Producer>(c => c.Id == notification.ProducerId, token); | ||
await _emailService.SendEmailAsync( | ||
"[email protected]", | ||
"Support", | ||
$"Un producteur vient de dépasser les 150€/mois de commandes", | ||
$"Un producteur ({producer.Name}) vient de franchir la limite des 150€/mois sur la plateforme, contactez le par email ({producer.Email}) ou par téléphone ({producer.Phone}) pour valider avec lui les documents banquaires.", | ||
false, | ||
token); | ||
} | ||
} | ||
} |