-
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.
* Google authentication is now made optional if ClientId in configura…
…tion is set to a null or empty value. * Added a search function that combines all events.
- Loading branch information
n.bitounis
committed
Jun 10, 2020
1 parent
60c0ce5
commit e703ff3
Showing
15 changed files
with
361 additions
and
34 deletions.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
Projects/SesNotifications.App/Pages/FindOperational.cshtml
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,82 @@ | ||
@page | ||
@model SesNotifications.App.Pages.FindOperationalModel | ||
@{ | ||
ViewData["Title"] = "Operational view"; | ||
} | ||
|
||
<!DOCTYPE html> | ||
|
||
<h1>@ViewData["Title"]</h1> | ||
<h4>Search for events 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>Notification ID</th> | ||
<th>Notification Type</th> | ||
<th>Source</th> | ||
<th>Recipients</th> | ||
<th>Sent at</th> | ||
<th>Created at</th> | ||
<th>Detail 1</th> | ||
<th>Detail 2</th> | ||
<th>Raw model</th> | ||
<th>Raw message</th> | ||
</tr> | ||
@foreach (var record in Model.Operational) | ||
{ | ||
<tr> | ||
<td>@record.NotificationId</td> | ||
<td>@record.NotificationType</td> | ||
<td>@record.Source</td> | ||
<td>@record.Recipients</td> | ||
<td>@record.SentAt.ToString("yyyy-MM-dd HH:mm:ssZ")</td> | ||
<td>@record.CreatedAt.ToString("yyyy-MM-dd HH:mm:ssZ")</td> | ||
<td>@record.Detail1</td> | ||
<td>@record.Detail2</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.Operational.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="FindOperational" | ||
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: 63 additions & 0 deletions
63
Projects/SesNotifications.App/Pages/FindOperational.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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System.Collections.Generic; | ||
using Microsoft.AspNetCore.Mvc; | ||
using SesNotifications.App.Helpers; | ||
using SesNotifications.App.Services.Interfaces; | ||
using SesNotifications.DataAccess.Entities; | ||
|
||
namespace SesNotifications.App.Pages | ||
{ | ||
public class FindOperationalModel : PageBase | ||
{ | ||
[BindProperty] | ||
public BaseEmailInputModel Input { get; set; } | ||
|
||
public IList<SesOperational> Operational { get; set; } = new List<SesOperational>(); | ||
|
||
private readonly ISearchService _searchService; | ||
|
||
public FindOperationalModel(ISearchService searchService) | ||
{ | ||
_searchService = searchService; | ||
} | ||
|
||
protected override void Search() | ||
{ | ||
var countOfResults = _searchService.FindOperationalCount(Input.Email, Input.Start.StartOfDay(), Input.End.EndOfDay()); | ||
|
||
Operational = _searchService.FindOperational(Input.Email, Input.Start.StartOfDay(), Input.End.EndOfDay(), null, 0, PageSize); | ||
|
||
if (Operational.Count > 0) | ||
{ | ||
FirstId = (int)Operational[0].NotificationId; | ||
} | ||
|
||
PageNumber = 1; | ||
NumberOfPages = countOfResults / PageSize + 1; | ||
Start = Input.Start; | ||
End = Input.End; | ||
Email = Input.Email; | ||
} | ||
|
||
protected override void GetPage() | ||
{ | ||
Operational = _searchService.FindOperational( | ||
Email, | ||
Start.StartOfDay(), | ||
End.EndOfDay(), | ||
FirstId, | ||
PageNumber - 1, | ||
PageSize); | ||
} | ||
|
||
protected override void CreateModel() | ||
{ | ||
Input = new BaseEmailInputModel(); | ||
} | ||
|
||
protected override void SaveState() | ||
{ | ||
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
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
16 changes: 16 additions & 0 deletions
16
Projects/SesNotifications.DataAccess/Entities/SesOperational.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; | ||
|
||
namespace SesNotifications.DataAccess.Entities | ||
{ | ||
public class SesOperational | ||
{ | ||
public virtual long NotificationId { get; set; } | ||
public virtual string NotificationType { get; set; } | ||
public virtual DateTime SentAt { get; set; } | ||
public virtual string Source { get; set; } | ||
public virtual DateTime CreatedAt { get; set; } | ||
public virtual string Recipients { get; set; } | ||
public virtual string Detail1 { get; set; } | ||
public virtual string Detail2 { get; set; } | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
Projects/SesNotifications.DataAccess/Mappings/SesOperationalMap.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,22 @@ | ||
using FluentNHibernate.Mapping; | ||
using SesNotifications.DataAccess.Entities; | ||
|
||
namespace SesNotifications.DataAccess.Mappings | ||
{ | ||
public class SesOperationalMap : ClassMap<SesOperational> | ||
{ | ||
public SesOperationalMap() | ||
{ | ||
Table("ses_notifications.operational"); | ||
Id(x => x.NotificationId).Column("notification_id"); | ||
Map(x => x.NotificationType).Column("notification_type"); | ||
Map(x => x.Recipients).Column("recipients"); | ||
Map(x => x.CreatedAt).Column("created_at"); | ||
Map(x => x.SentAt).Column("sent_at"); | ||
Map(x => x.Source).Column("source"); | ||
Map(x => x.Detail1).Column("detail1"); | ||
Map(x => x.Detail2).Column("detail2"); | ||
ReadOnly(); | ||
} | ||
} | ||
} |
Oops, something went wrong.