-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added send find page. * Fixed some broken tests.
- Loading branch information
n.bitounis
committed
Jun 1, 2020
1 parent
c9ea481
commit cfc61bc
Showing
18 changed files
with
336 additions
and
19 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
Projects/SesNotifications.App/Factories/DbSesSendFactory.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,26 @@ | ||
using System; | ||
using SesNotifications.App.Models; | ||
using SesSend = SesNotifications.DataAccess.Entities.SesSend; | ||
|
||
namespace SesNotifications.App.Factories | ||
{ | ||
public static class DbSesSendFactory | ||
{ | ||
public static SesSend Create(this SesSendModel open, long notificationId) | ||
{ | ||
return new SesSend | ||
{ | ||
Id = notificationId, | ||
NotificationId = notificationId, | ||
NotificationType = "Send", | ||
SentAt = Convert.ToDateTime(open.Mail.Timestamp), | ||
MessageId = open.Mail.MessageId, | ||
Source = open.Mail.Source, | ||
SourceArn = open.Mail.SourceArn, | ||
SourceIp = open.Mail.SourceIp, | ||
SendingAccountId = open.Mail.SendingAccountId, | ||
Recipients = string.Join(',', open.Mail.Destination) | ||
}; | ||
} | ||
} | ||
} |
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,6 @@ | ||
namespace SesNotifications.App.Models | ||
{ | ||
public class SesSend | ||
{ | ||
} | ||
} |
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,8 @@ | ||
namespace SesNotifications.App.Models | ||
{ | ||
public class SesSendModel : Ses | ||
{ | ||
public virtual SesMail Mail { get; set; } | ||
public virtual SesSend Send { 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
@page | ||
@model SesNotifications.App.Pages.FindSendsModel | ||
@{ | ||
ViewData["Title"] = "Find sends"; | ||
} | ||
|
||
<!DOCTYPE html> | ||
|
||
<h1>@ViewData["Title"]</h1> | ||
<h4>Search for sends by date range and optional recipient.</h4> | ||
<hr /> | ||
<div class="row"> | ||
<div class="col-md-4"> | ||
<form method="post"> | ||
<div asp-validation-summary="All" class="text-danger"></div> | ||
<div class="form-group"> | ||
<label>Starting date</label> | ||
<input asp-for="Input.Start" class="form-control" /> | ||
<span asp-validation-for="Input.Start" class="text-danger"></span> | ||
|
||
<label>Ending date</label> | ||
<input asp-for="Input.End" class="form-control" /> | ||
<span asp-validation-for="Input.End" class="text-danger"></span> | ||
|
||
<label asp-for="Input.Email"></label> | ||
<input asp-for="Input.Email" class="form-control" /> | ||
<span asp-validation-for="Input.Email" class="text-danger"></span> | ||
</div> | ||
|
||
<button type="submit" class="btn btn-primary">Submit</button> | ||
</form> | ||
<br /> | ||
|
||
<table class="table"> | ||
<tr> | ||
<th>ID</th> | ||
<th>Notification ID</th> | ||
<th>Notification Type</th> | ||
<th>Sent at</th> | ||
<th>Message ID</th> | ||
<th>Source</th> | ||
<th>Recipients</th> | ||
<th>Source ARN</th> | ||
<th>Source IP</th> | ||
<th>Sending Account ID</th> | ||
<th>FeedbackId</th> | ||
<th>Reporting MTA</th> | ||
</tr> | ||
@foreach (var record in Model.Bounces) | ||
{ | ||
<tr> | ||
<td>@record.Id</td> | ||
<td>@record.NotificationId</td> | ||
<td>@record.NotificationType</td> | ||
<td>@record.SentAt.ToString("yyyy-MM-dd HH:mm:ssZ")</td> | ||
<td>@record.MessageId</td> | ||
<td>@record.Source</td> | ||
<td>@record.Recipients</td> | ||
<td>@record.SourceArn</td> | ||
<td>@record.SourceIp</td> | ||
<td>@record.SendingAccountId</td> | ||
<td><a target="_blank" href="@Url.Action("FindRawById", "Searches", new {id = record.NotificationId})">RAW (MODEL)</a></td> | ||
<td><a target="_blank" href="@string.Concat(Url.Action("FindMessageById", "Searches", new {id = record.NotificationId}), "/text")">RAW (MESSAGE)</a></td> | ||
</tr> | ||
} | ||
</table> | ||
</div> | ||
</div> |
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,44 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
using SesNotifications.App.Services.Interfaces; | ||
using SesNotifications.DataAccess.Entities; | ||
|
||
namespace SesNotifications.App.Pages | ||
{ | ||
public class FindSendsModel : PageModel | ||
{ | ||
[BindProperty] | ||
public InputModel Input { get; set; } | ||
|
||
public IList<SesSend> Bounces { get; set; } = new List<SesSend>(); | ||
|
||
public class InputModel | ||
{ | ||
[Required] | ||
[DataType(DataType.Date)] | ||
public DateTime Start { get; set; } | ||
|
||
[Required] | ||
[DataType(DataType.Date)] | ||
public DateTime End { get; set; } | ||
|
||
public string Email { get; set; } | ||
} | ||
|
||
private readonly ISearchService _searchService; | ||
|
||
public FindSendsModel(ISearchService searchService) | ||
{ | ||
_searchService = searchService; | ||
} | ||
|
||
public IActionResult OnPost() | ||
{ | ||
Bounces = _searchService.FindSends(Input.Email, Input.Start, Input.End); | ||
return Page(); | ||
} | ||
} | ||
} |
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
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
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,7 @@ | ||
namespace SesNotifications.DataAccess.Entities | ||
{ | ||
public class SesSend : SesCommon | ||
{ | ||
public virtual string Recipients { get; set; } | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
Projects/SesNotifications.DataAccess/Mappings/SesSendMap.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,14 @@ | ||
using SesNotifications.DataAccess.Entities; | ||
|
||
namespace SesNotifications.DataAccess.Mappings | ||
{ | ||
public class SesSendMap : SesCommonMap<SesSend> | ||
{ | ||
public SesSendMap() | ||
{ | ||
Table("ses_notifications.sends"); | ||
MapCommon(); | ||
Map(x => x.Recipients).Column("recipients"); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
Projects/SesNotifications.DataAccess/Repositories/Interfaces/ISesSendsRepository.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 System; | ||
using System.Collections.Generic; | ||
using SesNotifications.DataAccess.Entities; | ||
|
||
namespace SesNotifications.DataAccess.Repositories.Interfaces | ||
{ | ||
public interface ISesSendsRepository | ||
{ | ||
void Save(SesSend sesSend); | ||
SesSend FindById(long id); | ||
IList<SesSend> FindByMessageId(string messageId); | ||
IList<SesSend> FindBySentDateRange(DateTime start, DateTime end); | ||
IList<SesSend> FindByRecipient(string email); | ||
IList<SesSend> FindByRecipientAndSentDateRange(string email, DateTime start, DateTime end); | ||
} | ||
} |
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
Oops, something went wrong.