Skip to content

Commit

Permalink
Added paging to all searches.
Browse files Browse the repository at this point in the history
  • Loading branch information
n.bitounis committed Jun 7, 2020
1 parent 06152df commit 03c5f65
Show file tree
Hide file tree
Showing 28 changed files with 507 additions and 205 deletions.
18 changes: 18 additions & 0 deletions Projects/SesNotifications.App/Pages/FindBounceEvents.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,23 @@
</tr>
}
</table>

<div>
@if (Model.BounceEvents.Count > 0)
{
<ul class="pagination">
@for (var i = 1; i <= (int) ViewData["NumberOfPages"]; i++)
{
<li class="page-item @(i == (int) ViewData["PageNumber"] ? "active" : "")">
<a asp-page="FindRaw"
asp-route-currentpage="@i"
asp-route-start="@ViewData["Start"]"
asp-route-end ="@ViewData["End"]"
class="page-link">@i</a>
</li>
}
</ul>
}
</div>
</div>
</div>
63 changes: 43 additions & 20 deletions Projects/SesNotifications.App/Pages/FindBounceEvents.cshtml.cs
Original file line number Diff line number Diff line change
@@ -1,45 +1,68 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using SesNotifications.App.Helpers;
using SesNotifications.App.Services.Interfaces;
using SesNotifications.DataAccess.Entities;

namespace SesNotifications.App.Pages
{
public class FindBounceEventsModel : PageModel
public class FindBounceEventsModel : PageBase
{
[BindProperty]
public InputModel Input { get; set; }
public BaseEmailInputModel Input { get; set; }

public IList<SesBounceEvent> BounceEvents { get; set; } = new List<SesBounceEvent>();

public class InputModel
private readonly ISearchService _searchService;

public FindBounceEventsModel(ISearchService searchService)
{
_searchService = searchService;
}

protected override void Search()
{
[Required]
[DataType(DataType.Date)]
public DateTime Start { get; set; }
var countOfResults = _searchService.FindBounceEventsCount(Input.Email, Input.Start.StartOfDay(), Input.End.EndOfDay());

BounceEvents = _searchService.FindBounceEvents(Input.Email, Input.Start.StartOfDay(), Input.End.EndOfDay(), null, 0, PageSize);

[Required]
[DataType(DataType.Date)]
public DateTime End { get; set; }
if (BounceEvents.Count > 0)
{
FirstId = (int)BounceEvents[0].Id;
}

public string Email { get; set; }
PageNumber = 1;
NumberOfPages = countOfResults / PageSize + 1;
Start = Input.Start;
End = Input.End;
Email = Input.Email;
}

private readonly ISearchService _searchService;
protected override void GetPage()
{
BounceEvents = _searchService.FindBounceEvents(
Email,
Start.StartOfDay(),
End.EndOfDay(),
FirstId,
PageNumber - 1,
PageSize);
}

public FindBounceEventsModel(ISearchService searchService)
protected override void CreateModel()
{
_searchService = searchService;
Input = new BaseEmailInputModel();
}

public IActionResult OnPost()
protected override void SaveState()
{
BounceEvents = _searchService.FindBounceEvents(Input.Email, Input.Start.StartOfDay(), Input.End.EndOfDay());
return Page();
SaveState(Input);
Input.Email = Email;
}
}

public class BaseEmailInputModel : BaseInputModel
{
public string Email { get; set; }
}
}
18 changes: 18 additions & 0 deletions Projects/SesNotifications.App/Pages/FindBounces.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,23 @@
</tr>
}
</table>

<div>
@if (Model.Bounces.Count > 0)
{
<ul class="pagination">
@for (var i = 1; i <= (int) ViewData["NumberOfPages"]; i++)
{
<li class="page-item @(i == (int) ViewData["PageNumber"] ? "active" : "")">
<a asp-page="FindRaw"
asp-route-currentpage="@i"
asp-route-start="@ViewData["Start"]"
asp-route-end ="@ViewData["End"]"
class="page-link">@i</a>
</li>
}
</ul>
}
</div>
</div>
</div>
60 changes: 39 additions & 21 deletions Projects/SesNotifications.App/Pages/FindBounces.cshtml.cs
Original file line number Diff line number Diff line change
@@ -1,45 +1,63 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using SesNotifications.App.Helpers;
using SesNotifications.App.Services.Interfaces;
using SesNotifications.DataAccess.Entities;

namespace SesNotifications.App.Pages
{
public class FindBouncesModel : PageModel
public class FindBouncesModel : PageBase
{
[BindProperty]
public InputModel Input { get; set; }
public BaseEmailInputModel Input { get; set; }

public IList<SesBounce> Bounces { get; set; } = new List<SesBounce>();

public class InputModel
private readonly ISearchService _searchService;

public FindBouncesModel(ISearchService searchService)
{
_searchService = searchService;
}

protected override void Search()
{
[Required]
[DataType(DataType.Date)]
public DateTime Start { get; set; }
var countOfResults = _searchService.FindBouncesCount(Input.Email, Input.Start.StartOfDay(), Input.End.EndOfDay());

[Required]
[DataType(DataType.Date)]
public DateTime End { get; set; }
Bounces = _searchService.FindBounces(Input.Email, Input.Start.StartOfDay(), Input.End.EndOfDay(), null, 0, PageSize);

public string Email { get; set; }
if (Bounces.Count > 0)
{
FirstId = (int)Bounces[0].Id;
}

PageNumber = 1;
NumberOfPages = countOfResults / PageSize + 1;
Start = Input.Start;
End = Input.End;
Email = Input.Email;
}

private readonly ISearchService _searchService;
protected override void GetPage()
{
Bounces = _searchService.FindBounces(
Email,
Start.StartOfDay(),
End.EndOfDay(),
FirstId,
PageNumber - 1,
PageSize);
}

public FindBouncesModel(ISearchService searchService)
protected override void CreateModel()
{
_searchService = searchService;
Input = new BaseEmailInputModel();
}

public IActionResult OnPost()
protected override void SaveState()
{
Bounces = _searchService.FindBounces(Input.Email, Input.Start.StartOfDay(), Input.End.EndOfDay());
return Page();
SaveState(Input);
Input.Email = Email;
}
}
}
}
54 changes: 36 additions & 18 deletions Projects/SesNotifications.App/Pages/FindComplaintEvents.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,43 @@
</tr>
@foreach (var record in Model.ComplaintEvents)
{
<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.ComplainedRecipients</td>
<td>@record.ComplaintSubType</td>
<td>@record.ComplaintFeedbackType</td>
<td>@record.SourceArn</td>
<td>@record.SourceIp</td>
<td>@record.SendingAccountId</td>
<td>@record.CreatedAt.ToString("yyyy-MM-dd HH:mm:ssZ")</td>
<td>@record.FeedbackId</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>
<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.ComplainedRecipients</td>
<td>@record.ComplaintSubType</td>
<td>@record.ComplaintFeedbackType</td>
<td>@record.SourceArn</td>
<td>@record.SourceIp</td>
<td>@record.SendingAccountId</td>
<td>@record.CreatedAt.ToString("yyyy-MM-dd HH:mm:ssZ")</td>
<td>@record.FeedbackId</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>
@if (Model.ComplaintEvents.Count > 0)
{
<ul class="pagination">
@for (var i = 1; i <= (int) ViewData["NumberOfPages"]; i++)
{
<li class="page-item @(i == (int) ViewData["PageNumber"] ? "active" : "")">
<a asp-page="FindRaw"
asp-route-currentpage="@i"
asp-route-start="@ViewData["Start"]"
asp-route-end ="@ViewData["End"]"
class="page-link">@i</a>
</li>
}
</ul>
}
</div>
</div>
</div>
54 changes: 36 additions & 18 deletions Projects/SesNotifications.App/Pages/FindComplaints.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,43 @@
</tr>
@foreach (var record in Model.Complaints)
{
<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.ComplainedRecipients</td>
<td>@record.ComplaintSubType</td>
<td>@record.ComplaintFeedbackType</td>
<td>@record.SourceArn</td>
<td>@record.SourceIp</td>
<td>@record.SendingAccountId</td>
<td>@record.CreatedAt.ToString("yyyy-MM-dd HH:mm:ssZ")</td>
<td>@record.FeedbackId</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>
<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.ComplainedRecipients</td>
<td>@record.ComplaintSubType</td>
<td>@record.ComplaintFeedbackType</td>
<td>@record.SourceArn</td>
<td>@record.SourceIp</td>
<td>@record.SendingAccountId</td>
<td>@record.CreatedAt.ToString("yyyy-MM-dd HH:mm:ssZ")</td>
<td>@record.FeedbackId</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>
@if (Model.Complaints.Count > 0)
{
<ul class="pagination">
@for (var i = 1; i <= (int) ViewData["NumberOfPages"]; i++)
{
<li class="page-item @(i == (int) ViewData["PageNumber"] ? "active" : "")">
<a asp-page="FindRaw"
asp-route-currentpage="@i"
asp-route-start="@ViewData["Start"]"
asp-route-end ="@ViewData["End"]"
class="page-link">@i</a>
</li>
}
</ul>
}
</div>
</div>
</div>
Loading

0 comments on commit 03c5f65

Please sign in to comment.