-
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.
- Loading branch information
n.bitounis
committed
Jun 7, 2020
1 parent
06152df
commit 03c5f65
Showing
28 changed files
with
507 additions
and
205 deletions.
There are no files selected for viewing
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
63 changes: 43 additions & 20 deletions
63
Projects/SesNotifications.App/Pages/FindBounceEvents.cshtml.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 |
---|---|---|
@@ -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; } | ||
} | ||
} |
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
60 changes: 39 additions & 21 deletions
60
Projects/SesNotifications.App/Pages/FindBounces.cshtml.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 |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.