diff --git a/Projects/SesNotifications.App/Pages/FindBounceEvents.cshtml b/Projects/SesNotifications.App/Pages/FindBounceEvents.cshtml index 779eae9..26b06b9 100644 --- a/Projects/SesNotifications.App/Pages/FindBounceEvents.cshtml +++ b/Projects/SesNotifications.App/Pages/FindBounceEvents.cshtml @@ -74,5 +74,23 @@ } + +
+ @if (Model.BounceEvents.Count > 0) + { + + } +
diff --git a/Projects/SesNotifications.App/Pages/FindBounceEvents.cshtml.cs b/Projects/SesNotifications.App/Pages/FindBounceEvents.cshtml.cs index b8d8e49..9e229e2 100644 --- a/Projects/SesNotifications.App/Pages/FindBounceEvents.cshtml.cs +++ b/Projects/SesNotifications.App/Pages/FindBounceEvents.cshtml.cs @@ -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 BounceEvents { get; set; } = new List(); - 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; } + } } \ No newline at end of file diff --git a/Projects/SesNotifications.App/Pages/FindBounces.cshtml b/Projects/SesNotifications.App/Pages/FindBounces.cshtml index 6850790..e5ab0a3 100644 --- a/Projects/SesNotifications.App/Pages/FindBounces.cshtml +++ b/Projects/SesNotifications.App/Pages/FindBounces.cshtml @@ -76,5 +76,23 @@ } + +
+ @if (Model.Bounces.Count > 0) + { +
    + @for (var i = 1; i <= (int) ViewData["NumberOfPages"]; i++) + { +
  • + @i +
  • + } +
+ } +
diff --git a/Projects/SesNotifications.App/Pages/FindBounces.cshtml.cs b/Projects/SesNotifications.App/Pages/FindBounces.cshtml.cs index fd2cbb1..663a598 100644 --- a/Projects/SesNotifications.App/Pages/FindBounces.cshtml.cs +++ b/Projects/SesNotifications.App/Pages/FindBounces.cshtml.cs @@ -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 Bounces { get; set; } = new List(); - 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; } } -} \ No newline at end of file +} diff --git a/Projects/SesNotifications.App/Pages/FindComplaintEvents.cshtml b/Projects/SesNotifications.App/Pages/FindComplaintEvents.cshtml index 57b1628..4a40b17 100644 --- a/Projects/SesNotifications.App/Pages/FindComplaintEvents.cshtml +++ b/Projects/SesNotifications.App/Pages/FindComplaintEvents.cshtml @@ -52,25 +52,43 @@ @foreach (var record in Model.ComplaintEvents) { - - @record.Id - @record.NotificationId - @record.NotificationType - @record.SentAt.ToString("yyyy-MM-dd HH:mm:ssZ") - @record.MessageId - @record.Source - @record.ComplainedRecipients - @record.ComplaintSubType - @record.ComplaintFeedbackType - @record.SourceArn - @record.SourceIp - @record.SendingAccountId - @record.CreatedAt.ToString("yyyy-MM-dd HH:mm:ssZ") - @record.FeedbackId - RAW (MODEL) - RAW (MESSAGE) - + + @record.Id + @record.NotificationId + @record.NotificationType + @record.SentAt.ToString("yyyy-MM-dd HH:mm:ssZ") + @record.MessageId + @record.Source + @record.ComplainedRecipients + @record.ComplaintSubType + @record.ComplaintFeedbackType + @record.SourceArn + @record.SourceIp + @record.SendingAccountId + @record.CreatedAt.ToString("yyyy-MM-dd HH:mm:ssZ") + @record.FeedbackId + RAW (MODEL) + RAW (MESSAGE) + } + +
+ @if (Model.ComplaintEvents.Count > 0) + { +
    + @for (var i = 1; i <= (int) ViewData["NumberOfPages"]; i++) + { +
  • + @i +
  • + } +
+ } +
diff --git a/Projects/SesNotifications.App/Pages/FindComplaints.cshtml b/Projects/SesNotifications.App/Pages/FindComplaints.cshtml index d5e00e0..18597ad 100644 --- a/Projects/SesNotifications.App/Pages/FindComplaints.cshtml +++ b/Projects/SesNotifications.App/Pages/FindComplaints.cshtml @@ -52,25 +52,43 @@ @foreach (var record in Model.Complaints) { - - @record.Id - @record.NotificationId - @record.NotificationType - @record.SentAt.ToString("yyyy-MM-dd HH:mm:ssZ") - @record.MessageId - @record.Source - @record.ComplainedRecipients - @record.ComplaintSubType - @record.ComplaintFeedbackType - @record.SourceArn - @record.SourceIp - @record.SendingAccountId - @record.CreatedAt.ToString("yyyy-MM-dd HH:mm:ssZ") - @record.FeedbackId - RAW (MODEL) - RAW (MESSAGE) - + + @record.Id + @record.NotificationId + @record.NotificationType + @record.SentAt.ToString("yyyy-MM-dd HH:mm:ssZ") + @record.MessageId + @record.Source + @record.ComplainedRecipients + @record.ComplaintSubType + @record.ComplaintFeedbackType + @record.SourceArn + @record.SourceIp + @record.SendingAccountId + @record.CreatedAt.ToString("yyyy-MM-dd HH:mm:ssZ") + @record.FeedbackId + RAW (MODEL) + RAW (MESSAGE) + } + +
+ @if (Model.Complaints.Count > 0) + { +
    + @for (var i = 1; i <= (int) ViewData["NumberOfPages"]; i++) + { +
  • + @i +
  • + } +
+ } +
diff --git a/Projects/SesNotifications.App/Pages/FindComplaints.cshtml.cs b/Projects/SesNotifications.App/Pages/FindComplaints.cshtml.cs index 237f0ed..61d597f 100644 --- a/Projects/SesNotifications.App/Pages/FindComplaints.cshtml.cs +++ b/Projects/SesNotifications.App/Pages/FindComplaints.cshtml.cs @@ -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 FindComplaintsModel : PageModel + public class FindComplaintsModel : PageBase { [BindProperty] - public InputModel Input { get; set; } + public BaseEmailInputModel Input { get; set; } - public IList Complaints { get; set; } = new List(); + public IList Complaints { get; set; } = new List(); - public class InputModel + private readonly ISearchService _searchService; + + public FindComplaintsModel(ISearchService searchService) + { + _searchService = searchService; + } + + protected override void Search() { - [Required] - [DataType(DataType.Date)] - public DateTime Start { get; set; } + var countOfResults = _searchService.FindComplaintEventCount(Input.Email, Input.Start.StartOfDay(), Input.End.EndOfDay()); - [Required] - [DataType(DataType.Date)] - public DateTime End { get; set; } + Complaints = _searchService.FindComplaintEvents(Input.Email, Input.Start.StartOfDay(), Input.End.EndOfDay(), null, 0, PageSize); - public string Email { get; set; } + if (Complaints.Count > 0) + { + FirstId = (int)Complaints[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() + { + Complaints = _searchService.FindComplaintEvents( + Email, + Start.StartOfDay(), + End.EndOfDay(), + FirstId, + PageNumber - 1, + PageSize); + } - public FindComplaintsModel(ISearchService searchService) + protected override void CreateModel() { - _searchService = searchService; + Input = new BaseEmailInputModel(); } - public IActionResult OnPost() + protected override void SaveState() { - Complaints = _searchService.FindComplaints(Input.Email, Input.Start.StartOfDay(), Input.End.EndOfDay()); - return Page(); + SaveState(Input); + Input.Email = Email; } } } \ No newline at end of file diff --git a/Projects/SesNotifications.App/Pages/FindDeliveries.cshtml b/Projects/SesNotifications.App/Pages/FindDeliveries.cshtml index f366a14..e01e016 100644 --- a/Projects/SesNotifications.App/Pages/FindDeliveries.cshtml +++ b/Projects/SesNotifications.App/Pages/FindDeliveries.cshtml @@ -72,5 +72,23 @@ } + +
+ @if (Model.Deliveries.Count > 0) + { +
    + @for (var i = 1; i <= (int) ViewData["NumberOfPages"]; i++) + { +
  • + @i +
  • + } +
+ } +
\ No newline at end of file diff --git a/Projects/SesNotifications.App/Pages/FindDeliveries.cshtml.cs b/Projects/SesNotifications.App/Pages/FindDeliveries.cshtml.cs index 6331433..3687d77 100644 --- a/Projects/SesNotifications.App/Pages/FindDeliveries.cshtml.cs +++ b/Projects/SesNotifications.App/Pages/FindDeliveries.cshtml.cs @@ -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 FindDeliveriesModel : PageModel + public class FindDeliveriesModel : PageBase { [BindProperty] - public InputModel Input { get; set; } + public BaseEmailInputModel Input { get; set; } public IList Deliveries { get; set; } = new List(); - public class InputModel + private readonly ISearchService _searchService; + + public FindDeliveriesModel(ISearchService searchService) + { + _searchService = searchService; + } + + protected override void Search() { - [Required] - [DataType(DataType.Date)] - public DateTime Start { get; set; } + var countOfResults = _searchService.FindDeliveriesCount(Input.Email, Input.Start.StartOfDay(), Input.End.EndOfDay()); - [Required] - [DataType(DataType.Date)] - public DateTime End { get; set; } + Deliveries = _searchService.FindDeliveries(Input.Email, Input.Start.StartOfDay(), Input.End.EndOfDay(), null, 0, PageSize); - public string Email { get; set; } + if (Deliveries.Count > 0) + { + FirstId = (int)Deliveries[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() + { + Deliveries = _searchService.FindDeliveries( + Email, + Start.StartOfDay(), + End.EndOfDay(), + FirstId, + PageNumber - 1, + PageSize); + } - public FindDeliveriesModel(ISearchService searchService) + protected override void CreateModel() { - _searchService = searchService; + Input = new BaseEmailInputModel(); } - public IActionResult OnPost() + protected override void SaveState() { - Deliveries = _searchService.FindDeliveries(Input.Email, Input.Start.StartOfDay(), Input.End.EndOfDay()); - return Page(); + SaveState(Input); + Input.Email = Email; } } } \ No newline at end of file diff --git a/Projects/SesNotifications.App/Pages/FindDeliveryEvents.cshtml b/Projects/SesNotifications.App/Pages/FindDeliveryEvents.cshtml index e7883ce..c1e3ff9 100644 --- a/Projects/SesNotifications.App/Pages/FindDeliveryEvents.cshtml +++ b/Projects/SesNotifications.App/Pages/FindDeliveryEvents.cshtml @@ -70,5 +70,23 @@ } + +
+ @if (Model.DeliveryEvents.Count > 0) + { +
    + @for (var i = 1; i <= (int) ViewData["NumberOfPages"]; i++) + { +
  • + @i +
  • + } +
+ } +
\ No newline at end of file diff --git a/Projects/SesNotifications.App/Pages/FindDeliveryEvents.cshtml.cs b/Projects/SesNotifications.App/Pages/FindDeliveryEvents.cshtml.cs index 35c5664..0c9d19f 100644 --- a/Projects/SesNotifications.App/Pages/FindDeliveryEvents.cshtml.cs +++ b/Projects/SesNotifications.App/Pages/FindDeliveryEvents.cshtml.cs @@ -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 FindDeliveryEventsModel : PageModel + public class FindDeliveryEventsModel : PageBase { [BindProperty] - public InputModel Input { get; set; } + public BaseEmailInputModel Input { get; set; } public IList DeliveryEvents { get; set; } = new List(); - public class InputModel + private readonly ISearchService _searchService; + + public FindDeliveryEventsModel(ISearchService searchService) + { + _searchService = searchService; + } + + protected override void Search() { - [Required] - [DataType(DataType.Date)] - public DateTime Start { get; set; } + var countOfResults = _searchService.FindDeliveryEventsCount(Input.Email, Input.Start.StartOfDay(), Input.End.EndOfDay()); - [Required] - [DataType(DataType.Date)] - public DateTime End { get; set; } + DeliveryEvents = _searchService.FindDeliveryEvents(Input.Email, Input.Start.StartOfDay(), Input.End.EndOfDay(), null, 0, PageSize); - public string Email { get; set; } + if (DeliveryEvents.Count > 0) + { + FirstId = (int)DeliveryEvents[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() + { + DeliveryEvents = _searchService.FindDeliveryEvents( + Email, + Start.StartOfDay(), + End.EndOfDay(), + FirstId, + PageNumber - 1, + PageSize); + } - public FindDeliveryEventsModel(ISearchService searchService) + protected override void CreateModel() { - _searchService = searchService; + Input = new BaseEmailInputModel(); } - public IActionResult OnPost() + protected override void SaveState() { - DeliveryEvents = _searchService.FindDeliveryEvents(Input.Email, Input.Start.StartOfDay(), Input.End.EndOfDay()); - return Page(); + SaveState(Input); + Input.Email = Email; } } } \ No newline at end of file diff --git a/Projects/SesNotifications.App/Pages/FindOpenEvents.cshtml b/Projects/SesNotifications.App/Pages/FindOpenEvents.cshtml index 82482cd..070dfca 100644 --- a/Projects/SesNotifications.App/Pages/FindOpenEvents.cshtml +++ b/Projects/SesNotifications.App/Pages/FindOpenEvents.cshtml @@ -70,5 +70,23 @@ } + +
+ @if (Model.OpenEvents.Count > 0) + { +
    + @for (var i = 1; i <= (int) ViewData["NumberOfPages"]; i++) + { +
  • + @i +
  • + } +
+ } +
diff --git a/Projects/SesNotifications.App/Pages/FindOpenEvents.cshtml.cs b/Projects/SesNotifications.App/Pages/FindOpenEvents.cshtml.cs index 179c010..dc7e0d8 100644 --- a/Projects/SesNotifications.App/Pages/FindOpenEvents.cshtml.cs +++ b/Projects/SesNotifications.App/Pages/FindOpenEvents.cshtml.cs @@ -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 FindOpenEventsModel : PageModel + public class FindOpenEventsModel : PageBase { [BindProperty] - public InputModel Input { get; set; } + public BaseEmailInputModel Input { get; set; } public IList OpenEvents { get; set; } = new List(); - public class InputModel + private readonly ISearchService _searchService; + + public FindOpenEventsModel(ISearchService searchService) + { + _searchService = searchService; + } + + protected override void Search() { - [Required] - [DataType(DataType.Date)] - public DateTime Start { get; set; } + var countOfResults = _searchService.FindOpenEventsCount(Input.Email, Input.Start.StartOfDay(), Input.End.EndOfDay()); - [Required] - [DataType(DataType.Date)] - public DateTime End { get; set; } + OpenEvents = _searchService.FindOpenEvents(Input.Email, Input.Start.StartOfDay(), Input.End.EndOfDay(), null, 0, PageSize); - public string Email { get; set; } + if (OpenEvents.Count > 0) + { + FirstId = (int)OpenEvents[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() + { + OpenEvents = _searchService.FindOpenEvents( + Email, + Start.StartOfDay(), + End.EndOfDay(), + FirstId, + PageNumber - 1, + PageSize); + } - public FindOpenEventsModel(ISearchService searchService) + protected override void CreateModel() { - _searchService = searchService; + Input = new BaseEmailInputModel(); } - public IActionResult OnPost() + protected override void SaveState() { - OpenEvents = _searchService.FindOpenEvents(Input.Email, Input.Start.StartOfDay(), Input.End.EndOfDay()); - return Page(); + SaveState(Input); + Input.Email = Email; } } } \ No newline at end of file diff --git a/Projects/SesNotifications.App/Pages/FindSendEvents.cshtml b/Projects/SesNotifications.App/Pages/FindSendEvents.cshtml index 1145e33..365b369 100644 --- a/Projects/SesNotifications.App/Pages/FindSendEvents.cshtml +++ b/Projects/SesNotifications.App/Pages/FindSendEvents.cshtml @@ -64,5 +64,23 @@ } + +
+ @if (Model.SendEvents.Count > 0) + { +
    + @for (var i = 1; i <= (int) ViewData["NumberOfPages"]; i++) + { +
  • + @i +
  • + } +
+ } +
diff --git a/Projects/SesNotifications.App/Pages/FindSendEvents.cshtml.cs b/Projects/SesNotifications.App/Pages/FindSendEvents.cshtml.cs index 45f8f66..c75d9ec 100644 --- a/Projects/SesNotifications.App/Pages/FindSendEvents.cshtml.cs +++ b/Projects/SesNotifications.App/Pages/FindSendEvents.cshtml.cs @@ -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 FindSendEventsModel : PageModel + public class FindSendEventsModel : PageBase { [BindProperty] - public InputModel Input { get; set; } + public BaseEmailInputModel Input { get; set; } public IList SendEvents { get; set; } = new List(); - public class InputModel + private readonly ISearchService _searchService; + + public FindSendEventsModel(ISearchService searchService) + { + _searchService = searchService; + } + + protected override void Search() { - [Required] - [DataType(DataType.Date)] - public DateTime Start { get; set; } + var countOfResults = _searchService.FindSendEventsCount(Input.Email, Input.Start.StartOfDay(), Input.End.EndOfDay()); - [Required] - [DataType(DataType.Date)] - public DateTime End { get; set; } + SendEvents = _searchService.FindSendEvents(Input.Email, Input.Start.StartOfDay(), Input.End.EndOfDay(), null, 0, PageSize); - public string Email { get; set; } + if (SendEvents.Count > 0) + { + FirstId = (int)SendEvents[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() + { + SendEvents = _searchService.FindSendEvents( + Email, + Start.StartOfDay(), + End.EndOfDay(), + FirstId, + PageNumber - 1, + PageSize); + } - public FindSendEventsModel(ISearchService searchService) + protected override void CreateModel() { - _searchService = searchService; + Input = new BaseEmailInputModel(); } - public IActionResult OnPost() + protected override void SaveState() { - SendEvents = _searchService.FindSendEvents(Input.Email, Input.Start.StartOfDay(), Input.End.EndOfDay()); - return Page(); + SaveState(Input); + Input.Email = Email; } } } \ No newline at end of file diff --git a/Projects/SesNotifications.App/Pages/PageBase.cs b/Projects/SesNotifications.App/Pages/PageBase.cs index 4cadcc7..8f436a3 100644 --- a/Projects/SesNotifications.App/Pages/PageBase.cs +++ b/Projects/SesNotifications.App/Pages/PageBase.cs @@ -7,7 +7,7 @@ namespace SesNotifications.App.Pages { public abstract class PageBase : PageModel { - protected const int PageSize = 50; + protected const int PageSize = 5; [TempData] public int FirstId { get; set; } diff --git a/Projects/SesNotifications.App/Services/Interfaces/ISearchService.cs b/Projects/SesNotifications.App/Services/Interfaces/ISearchService.cs index 2ca0726..1875235 100644 --- a/Projects/SesNotifications.App/Services/Interfaces/ISearchService.cs +++ b/Projects/SesNotifications.App/Services/Interfaces/ISearchService.cs @@ -25,6 +25,7 @@ public interface ISearchService int FindOpenEventsCount(string email, DateTime start, DateTime end); int FindSendEventsCount(string email, DateTime start, DateTime end); int FindDeliveryEventsCount(string email, DateTime start, DateTime end); + int FindBounceEventsCount(string email, DateTime start, DateTime end); int FindComplaintEventCount(string email, DateTime start, DateTime end); IList FindDeliveries(string email, DateTime start, DateTime end, long? firstId, int page, int pageSize); IList FindComplaints(string email, DateTime start, DateTime end, long? firstId, int page, int pageSize); @@ -34,7 +35,6 @@ public interface ISearchService IList FindDeliveryEvents(string email, DateTime start, DateTime end, long? firstId, int page, int pageSize); IList FindBounceEvents(string email, DateTime start, DateTime end, long? firstId, int page, int pageSize); IList FindComplaintEvents(string email, DateTime start, DateTime end, long? firstId, int page, int pageSize); - SesNotification FindRaw(long id); } } \ No newline at end of file diff --git a/Projects/SesNotifications.App/Services/SearchService.cs b/Projects/SesNotifications.App/Services/SearchService.cs index 0347443..069cc76 100644 --- a/Projects/SesNotifications.App/Services/SearchService.cs +++ b/Projects/SesNotifications.App/Services/SearchService.cs @@ -146,6 +146,11 @@ public int FindDeliveryEventsCount(string email, DateTime start, DateTime end) return _sesDeliveryEventsRepository.Count(email, start, end); } + public int FindBounceEventsCount(string email, DateTime start, DateTime end) + { + return _sesBounceEventsRepository.Count(email, start, end); + } + public int FindComplaintEventCount(string email, DateTime start, DateTime end) { return _sesComplaintEventsRepository.Count(email, start, end); diff --git a/Projects/SesNotifications.DataAccess/Repositories/CriteriaHelper.cs b/Projects/SesNotifications.DataAccess/Repositories/CriteriaHelper.cs new file mode 100644 index 0000000..c70f79f --- /dev/null +++ b/Projects/SesNotifications.DataAccess/Repositories/CriteriaHelper.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; +using NHibernate; +using NHibernate.Criterion; + +namespace SesNotifications.DataAccess.Repositories +{ + public static class CriteriaHelper + { + public static ICriteria AddIfNotEmpty(this ICriteria criteria, string value, string propertyName) + { + if (string.IsNullOrEmpty(value)) + { + return criteria; + } + + return criteria.Add(Restrictions.InsensitiveLike(propertyName, value)); + } + } +} diff --git a/Projects/SesNotifications.DataAccess/Repositories/Repository.cs b/Projects/SesNotifications.DataAccess/Repositories/Repository.cs index 4cc1bad..14cc5f0 100644 --- a/Projects/SesNotifications.DataAccess/Repositories/Repository.cs +++ b/Projects/SesNotifications.DataAccess/Repositories/Repository.cs @@ -1,4 +1,5 @@ using NHibernate; +using NHibernate.Criterion; namespace SesNotifications.DataAccess.Repositories { @@ -15,5 +16,5 @@ public Repository(ISession session) { Session = session; } - } + } } \ No newline at end of file diff --git a/Projects/SesNotifications.DataAccess/Repositories/SesBounceEventsRepository.cs b/Projects/SesNotifications.DataAccess/Repositories/SesBounceEventsRepository.cs index fba38dc..af9beb5 100644 --- a/Projects/SesNotifications.DataAccess/Repositories/SesBounceEventsRepository.cs +++ b/Projects/SesNotifications.DataAccess/Repositories/SesBounceEventsRepository.cs @@ -64,7 +64,7 @@ public IList FindByRecipientAndSentDateRange(string email, DateT public int Count(string email, DateTime start, DateTime end) { return Session.CreateCriteria() - .Add(Restrictions.InsensitiveLike(nameof(SesBounceEvent.BouncedRecipients), email)) + .AddIfNotEmpty(email, nameof(SesBounceEvent.BouncedRecipients)) .Add(Restrictions.Ge(nameof(SesBounceEvent.SentAt), start)) .Add(Restrictions.Le(nameof(SesBounceEvent.SentAt), end)) .List() @@ -76,7 +76,7 @@ public IList FindById(string email, DateTime start, DateTime end if (!firstId.HasValue) { return Session.CreateCriteria() - .Add(Restrictions.InsensitiveLike(nameof(SesBounceEvent.BouncedRecipients), email)) + .AddIfNotEmpty(email, nameof(SesBounceEvent.BouncedRecipients)) .Add(Restrictions.Ge(nameof(SesBounceEvent.SentAt), start)) .Add(Restrictions.Le(nameof(SesBounceEvent.SentAt), end)) .AddOrder(Order.Desc(nameof(SesBounceEvent.Id))) @@ -85,7 +85,7 @@ public IList FindById(string email, DateTime start, DateTime end } return Session.CreateCriteria() - .Add(Restrictions.InsensitiveLike(nameof(SesBounceEvent.BouncedRecipients), email)) + .AddIfNotEmpty(email, nameof(SesBounceEvent.BouncedRecipients)) .Add(Restrictions.Ge(nameof(SesBounceEvent.SentAt), start)) .Add(Restrictions.Le(nameof(SesBounceEvent.SentAt), end)) .Add(Restrictions.Le(nameof(SesBounceEvent.Id), firstId.Value - page * pageSize)) diff --git a/Projects/SesNotifications.DataAccess/Repositories/SesBouncesRepository.cs b/Projects/SesNotifications.DataAccess/Repositories/SesBouncesRepository.cs index d4115a6..1bd783e 100644 --- a/Projects/SesNotifications.DataAccess/Repositories/SesBouncesRepository.cs +++ b/Projects/SesNotifications.DataAccess/Repositories/SesBouncesRepository.cs @@ -64,7 +64,7 @@ public IList FindByRecipientAndSentDateRange(string email, DateTime s public int Count(string email, DateTime start, DateTime end) { return Session.CreateCriteria() - .Add(Restrictions.InsensitiveLike(nameof(SesBounce.BouncedRecipients), email)) + .AddIfNotEmpty(email, nameof(SesBounce.BouncedRecipients)) .Add(Restrictions.Ge(nameof(SesBounce.SentAt), start)) .Add(Restrictions.Le(nameof(SesBounce.SentAt), end)) .List() @@ -76,7 +76,7 @@ public IList FindById(string email, DateTime start, DateTime end, lon if (!firstId.HasValue) { return Session.CreateCriteria() - .Add(Restrictions.InsensitiveLike(nameof(SesBounce.BouncedRecipients), email)) + .AddIfNotEmpty(email, nameof(SesBounce.BouncedRecipients)) .Add(Restrictions.Ge(nameof(SesBounce.SentAt), start)) .Add(Restrictions.Le(nameof(SesBounce.SentAt), end)) .AddOrder(Order.Desc(nameof(SesBounce.Id))) @@ -85,7 +85,7 @@ public IList FindById(string email, DateTime start, DateTime end, lon } return Session.CreateCriteria() - .Add(Restrictions.InsensitiveLike(nameof(SesBounce.BouncedRecipients), email)) + .AddIfNotEmpty(email, nameof(SesBounce.BouncedRecipients)) .Add(Restrictions.Ge(nameof(SesBounce.SentAt), start)) .Add(Restrictions.Le(nameof(SesBounce.SentAt), end)) .Add(Restrictions.Le(nameof(SesBounce.Id), firstId.Value - page * pageSize)) diff --git a/Projects/SesNotifications.DataAccess/Repositories/SesComplaintEventsRepository.cs b/Projects/SesNotifications.DataAccess/Repositories/SesComplaintEventsRepository.cs index e75fb2c..ce7f07a 100644 --- a/Projects/SesNotifications.DataAccess/Repositories/SesComplaintEventsRepository.cs +++ b/Projects/SesNotifications.DataAccess/Repositories/SesComplaintEventsRepository.cs @@ -74,7 +74,7 @@ public IList FindByComplaintSubTypeAndSentDateRange(string co public int Count(string email, DateTime start, DateTime end) { return Session.CreateCriteria() - .Add(Restrictions.InsensitiveLike(nameof(SesComplaintEvent.ComplainedRecipients), email)) + .AddIfNotEmpty(email, nameof(SesComplaintEvent.ComplainedRecipients)) .Add(Restrictions.Ge(nameof(SesComplaintEvent.SentAt), start)) .Add(Restrictions.Le(nameof(SesComplaintEvent.SentAt), end)) .List() @@ -86,7 +86,7 @@ public IList FindById(string email, DateTime start, DateTime if (!firstId.HasValue) { return Session.CreateCriteria() - .Add(Restrictions.InsensitiveLike(nameof(SesComplaintEvent.ComplainedRecipients), email)) + .AddIfNotEmpty(email, nameof(SesComplaintEvent.ComplainedRecipients)) .Add(Restrictions.Ge(nameof(SesComplaintEvent.SentAt), start)) .Add(Restrictions.Le(nameof(SesComplaintEvent.SentAt), end)) .AddOrder(Order.Desc(nameof(SesComplaintEvent.Id))) @@ -95,7 +95,7 @@ public IList FindById(string email, DateTime start, DateTime } return Session.CreateCriteria() - .Add(Restrictions.InsensitiveLike(nameof(SesComplaintEvent.ComplainedRecipients), email)) + .AddIfNotEmpty(email, nameof(SesComplaintEvent.ComplainedRecipients)) .Add(Restrictions.Ge(nameof(SesComplaintEvent.SentAt), start)) .Add(Restrictions.Le(nameof(SesComplaintEvent.SentAt), end)) .Add(Restrictions.Le(nameof(SesComplaintEvent.Id), firstId.Value - page * pageSize)) diff --git a/Projects/SesNotifications.DataAccess/Repositories/SesComplaintsRepository.cs b/Projects/SesNotifications.DataAccess/Repositories/SesComplaintsRepository.cs index 3fa1dce..b2991a8 100644 --- a/Projects/SesNotifications.DataAccess/Repositories/SesComplaintsRepository.cs +++ b/Projects/SesNotifications.DataAccess/Repositories/SesComplaintsRepository.cs @@ -74,7 +74,7 @@ public IList FindByComplaintSubTypeAndSentDateRange(string complai public int Count(string email, DateTime start, DateTime end) { return Session.CreateCriteria() - .Add(Restrictions.InsensitiveLike(nameof(SesComplaint.ComplainedRecipients), email)) + .AddIfNotEmpty(email, nameof(SesComplaint.ComplainedRecipients)) .Add(Restrictions.Ge(nameof(SesComplaint.SentAt), start)) .Add(Restrictions.Le(nameof(SesComplaint.SentAt), end)) .List() @@ -86,7 +86,7 @@ public IList FindById(string email, DateTime start, DateTime end, if (!firstId.HasValue) { return Session.CreateCriteria() - .Add(Restrictions.InsensitiveLike(nameof(SesComplaint.ComplainedRecipients), email)) + .AddIfNotEmpty(email, nameof(SesComplaint.ComplainedRecipients)) .Add(Restrictions.Ge(nameof(SesComplaint.SentAt), start)) .Add(Restrictions.Le(nameof(SesComplaint.SentAt), end)) .AddOrder(Order.Desc(nameof(SesComplaint.Id))) @@ -95,7 +95,7 @@ public IList FindById(string email, DateTime start, DateTime end, } return Session.CreateCriteria() - .Add(Restrictions.InsensitiveLike(nameof(SesComplaint.ComplainedRecipients), email)) + .AddIfNotEmpty(email, nameof(SesComplaint.ComplainedRecipients)) .Add(Restrictions.Ge(nameof(SesComplaint.SentAt), start)) .Add(Restrictions.Le(nameof(SesComplaint.SentAt), end)) .Add(Restrictions.Le(nameof(SesComplaint.Id), firstId.Value - page * pageSize)) diff --git a/Projects/SesNotifications.DataAccess/Repositories/SesDeliveriesRepository.cs b/Projects/SesNotifications.DataAccess/Repositories/SesDeliveriesRepository.cs index a777b91..925b329 100644 --- a/Projects/SesNotifications.DataAccess/Repositories/SesDeliveriesRepository.cs +++ b/Projects/SesNotifications.DataAccess/Repositories/SesDeliveriesRepository.cs @@ -64,7 +64,7 @@ public IList FindByRecipientAndSentDateRange(string email, DateTime public int Count(string email, DateTime start, DateTime end) { return Session.CreateCriteria() - .Add(Restrictions.InsensitiveLike(nameof(SesDelivery.Recipients), email)) + .AddIfNotEmpty(email, nameof(SesDelivery.Recipients)) .Add(Restrictions.Ge(nameof(SesDelivery.SentAt), start)) .Add(Restrictions.Le(nameof(SesDelivery.SentAt), end)) .List() @@ -76,7 +76,7 @@ public IList FindById(string email, DateTime start, DateTime end, l if (!firstId.HasValue) { return Session.CreateCriteria() - .Add(Restrictions.InsensitiveLike(nameof(SesDelivery.Recipients), email)) + .AddIfNotEmpty(email, nameof(SesDelivery.Recipients)) .Add(Restrictions.Ge(nameof(SesDelivery.SentAt), start)) .Add(Restrictions.Le(nameof(SesDelivery.SentAt), end)) .AddOrder(Order.Desc(nameof(SesDelivery.Id))) @@ -85,7 +85,7 @@ public IList FindById(string email, DateTime start, DateTime end, l } return Session.CreateCriteria() - .Add(Restrictions.InsensitiveLike(nameof(SesDelivery.Recipients), email)) + .AddIfNotEmpty(email, nameof(SesDelivery.Recipients)) .Add(Restrictions.Ge(nameof(SesDelivery.SentAt), start)) .Add(Restrictions.Le(nameof(SesDelivery.SentAt), end)) .Add(Restrictions.Le(nameof(SesDelivery.Id), firstId.Value - page * pageSize)) diff --git a/Projects/SesNotifications.DataAccess/Repositories/SesDeliveryEventsRepository.cs b/Projects/SesNotifications.DataAccess/Repositories/SesDeliveryEventsRepository.cs index 22cd1bc..f0f54f2 100644 --- a/Projects/SesNotifications.DataAccess/Repositories/SesDeliveryEventsRepository.cs +++ b/Projects/SesNotifications.DataAccess/Repositories/SesDeliveryEventsRepository.cs @@ -64,7 +64,7 @@ public IList FindByRecipientAndSentDateRange(string email, Dat public int Count(string email, DateTime start, DateTime end) { return Session.CreateCriteria() - .Add(Restrictions.InsensitiveLike(nameof(SesDeliveryEvent.Recipients), email)) + .AddIfNotEmpty(email, nameof(SesDeliveryEvent.Recipients)) .Add(Restrictions.Ge(nameof(SesDeliveryEvent.SentAt), start)) .Add(Restrictions.Le(nameof(SesDeliveryEvent.SentAt), end)) .List() @@ -76,7 +76,7 @@ public IList FindById(string email, DateTime start, DateTime e if (!firstId.HasValue) { return Session.CreateCriteria() - .Add(Restrictions.InsensitiveLike(nameof(SesDeliveryEvent.Recipients), email)) + .AddIfNotEmpty(email, nameof(SesDeliveryEvent.Recipients)) .Add(Restrictions.Ge(nameof(SesDeliveryEvent.SentAt), start)) .Add(Restrictions.Le(nameof(SesDeliveryEvent.SentAt), end)) .AddOrder(Order.Desc(nameof(SesDeliveryEvent.Id))) @@ -85,7 +85,7 @@ public IList FindById(string email, DateTime start, DateTime e } return Session.CreateCriteria() - .Add(Restrictions.InsensitiveLike(nameof(SesDeliveryEvent.Recipients), email)) + .AddIfNotEmpty(email, nameof(SesDeliveryEvent.Recipients)) .Add(Restrictions.Ge(nameof(SesDeliveryEvent.SentAt), start)) .Add(Restrictions.Le(nameof(SesDeliveryEvent.SentAt), end)) .Add(Restrictions.Le(nameof(SesDeliveryEvent.Id), firstId.Value - page * pageSize)) diff --git a/Projects/SesNotifications.DataAccess/Repositories/SesOpensEventsRepository.cs b/Projects/SesNotifications.DataAccess/Repositories/SesOpensEventsRepository.cs index 668a6f6..c84cd93 100644 --- a/Projects/SesNotifications.DataAccess/Repositories/SesOpensEventsRepository.cs +++ b/Projects/SesNotifications.DataAccess/Repositories/SesOpensEventsRepository.cs @@ -65,7 +65,7 @@ public IList FindByRecipientAndSentDateRange(string email, DateTim public int Count(string email, DateTime start, DateTime end) { return Session.CreateCriteria() - .Add(Restrictions.InsensitiveLike(nameof(SesOpenEvent.Recipients), email)) + .AddIfNotEmpty(email, nameof(SesOpenEvent.Recipients)) .Add(Restrictions.Ge(nameof(SesOpenEvent.SentAt), start)) .Add(Restrictions.Le(nameof(SesOpenEvent.SentAt), end)) .List() @@ -77,7 +77,7 @@ public IList FindById(string email, DateTime start, DateTime end, if (!firstId.HasValue) { return Session.CreateCriteria() - .Add(Restrictions.InsensitiveLike(nameof(SesOpenEvent.Recipients), email)) + .AddIfNotEmpty(email, nameof(SesOpenEvent.Recipients)) .Add(Restrictions.Ge(nameof(SesOpenEvent.SentAt), start)) .Add(Restrictions.Le(nameof(SesOpenEvent.SentAt), end)) .AddOrder(Order.Desc(nameof(SesOpenEvent.Id))) @@ -86,7 +86,7 @@ public IList FindById(string email, DateTime start, DateTime end, } return Session.CreateCriteria() - .Add(Restrictions.InsensitiveLike(nameof(SesOpenEvent.Recipients), email)) + .AddIfNotEmpty(email, nameof(SesOpenEvent.Recipients)) .Add(Restrictions.Ge(nameof(SesOpenEvent.SentAt), start)) .Add(Restrictions.Le(nameof(SesOpenEvent.SentAt), end)) .Add(Restrictions.Le(nameof(SesOpenEvent), firstId.Value - page * pageSize)) diff --git a/Projects/SesNotifications.DataAccess/Repositories/SesSendEventsRepository.cs b/Projects/SesNotifications.DataAccess/Repositories/SesSendEventsRepository.cs index c817ed7..eac4a0f 100644 --- a/Projects/SesNotifications.DataAccess/Repositories/SesSendEventsRepository.cs +++ b/Projects/SesNotifications.DataAccess/Repositories/SesSendEventsRepository.cs @@ -64,7 +64,7 @@ public IList FindByRecipientAndSentDateRange(string email, DateTim public int Count(string email, DateTime start, DateTime end) { return Session.CreateCriteria() - .Add(Restrictions.InsensitiveLike(nameof(SesSendEvent.Recipients), email)) + .AddIfNotEmpty(email, nameof(SesSendEvent.Recipients)) .Add(Restrictions.Ge(nameof(SesSendEvent.SentAt), start)) .Add(Restrictions.Le(nameof(SesSendEvent.SentAt), end)) .List() @@ -76,7 +76,7 @@ public IList FindById(string email, DateTime start, DateTime end, if (!firstId.HasValue) { return Session.CreateCriteria() - .Add(Restrictions.InsensitiveLike(nameof(SesSendEvent.Recipients), email)) + .AddIfNotEmpty(email, nameof(SesSendEvent.Recipients)) .Add(Restrictions.Ge(nameof(SesSendEvent.SentAt), start)) .Add(Restrictions.Le(nameof(SesSendEvent.SentAt), end)) .AddOrder(Order.Desc(nameof(SesSendEvent.Id))) @@ -85,7 +85,7 @@ public IList FindById(string email, DateTime start, DateTime end, } return Session.CreateCriteria() - .Add(Restrictions.InsensitiveLike(nameof(SesSendEvent.Recipients), email)) + .AddIfNotEmpty(email, nameof(SesSendEvent.Recipients)) .Add(Restrictions.Ge(nameof(SesSendEvent.SentAt), start)) .Add(Restrictions.Le(nameof(SesSendEvent.SentAt), end)) .Add(Restrictions.Le(nameof(SesSendEvent), firstId.Value - page * pageSize))