Skip to content

Commit

Permalink
Renamed a lot of classes so that they make more sense.
Browse files Browse the repository at this point in the history
  • Loading branch information
n.bitounis committed Jun 1, 2020
1 parent cfc61bc commit 1bf57ad
Show file tree
Hide file tree
Showing 25 changed files with 226 additions and 226 deletions.
6 changes: 3 additions & 3 deletions Projects/SesNotifications.App/Factories/DbSesOpenFactory.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using System;
using SesNotifications.App.Models;
using SesOpen = SesNotifications.DataAccess.Entities.SesOpen;
using SesNotifications.DataAccess.Entities;

namespace SesNotifications.App.Factories
{
public static class DbSesOpenFactory
{
public static SesOpen Create(this SesOpenModel open, long notificationId)
public static SesOpenEvent Create(this SesOpenModel open, long notificationId)
{
return new SesOpen
return new SesOpenEvent
{
Id = notificationId,
NotificationId = notificationId,
Expand Down
6 changes: 3 additions & 3 deletions Projects/SesNotifications.App/Factories/DbSesSendFactory.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using System;
using SesNotifications.App.Models;
using SesSend = SesNotifications.DataAccess.Entities.SesSend;
using SesNotifications.DataAccess.Entities;

namespace SesNotifications.App.Factories
{
public static class DbSesSendFactory
{
public static SesSend Create(this SesSendModel open, long notificationId)
public static SesSendEvent Create(this SesSendModel open, long notificationId)
{
return new SesSend
return new SesSendEvent
{
Id = notificationId,
NotificationId = notificationId,
Expand Down
2 changes: 1 addition & 1 deletion Projects/SesNotifications.App/Pages/FindOpens.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<th>User Agent</th>
<th>IP Address</th>
</tr>
@foreach (var record in Model.Bounces)
@foreach (var record in Model.Opens)
{
<tr>
<td>@record.Id</td>
Expand Down
4 changes: 2 additions & 2 deletions Projects/SesNotifications.App/Pages/FindOpens.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class FindOpensModel : PageModel
[BindProperty]
public InputModel Input { get; set; }

public IList<SesOpen> Bounces { get; set; } = new List<SesOpen>();
public IList<SesOpenEvent> Opens { get; set; } = new List<SesOpenEvent>();

public class InputModel
{
Expand All @@ -37,7 +37,7 @@ public FindOpensModel(ISearchService searchService)

public IActionResult OnPost()
{
Bounces = _searchService.FindOpens(Input.Email, Input.Start, Input.End);
Opens = _searchService.FindOpens(Input.Email, Input.Start, Input.End);
return Page();
}
}
Expand Down
2 changes: 1 addition & 1 deletion Projects/SesNotifications.App/Pages/FindSends.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<th>FeedbackId</th>
<th>Reporting MTA</th>
</tr>
@foreach (var record in Model.Bounces)
@foreach (var record in Model.Sends)
{
<tr>
<td>@record.Id</td>
Expand Down
4 changes: 2 additions & 2 deletions Projects/SesNotifications.App/Pages/FindSends.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class FindSendsModel : PageModel
[BindProperty]
public InputModel Input { get; set; }

public IList<SesSend> Bounces { get; set; } = new List<SesSend>();
public IList<SesSendEvent> Sends { get; set; } = new List<SesSendEvent>();

public class InputModel
{
Expand All @@ -37,7 +37,7 @@ public FindSendsModel(ISearchService searchService)

public IActionResult OnPost()
{
Bounces = _searchService.FindSends(Input.Email, Input.Start, Input.End);
Sends = _searchService.FindSends(Input.Email, Input.Start, Input.End);
return Page();
}
}
Expand Down
2 changes: 1 addition & 1 deletion Projects/SesNotifications.App/Pages/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<div class="dropdown-menu">
<a class="dropdown-item" href="~/FindDeliveries">Deliveries</a>
<a class="dropdown-item" href="~/FindComplaints">Complaints</a>
<a class="dropdown-item" href="~/FindBounces">Bounces</a>
<a class="dropdown-item" href="~/FindBounces">Sends</a>
<a class="dropdown-item" href="~/FindOpens">Opens</a>
<a class="dropdown-item" href="~/FindSends">Sends</a>
<a class="dropdown-item" href="~/FindRaw">Raw</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public interface ISearchService
IList<SesDelivery> FindDeliveries(string email, DateTime start, DateTime end);
IList<SesComplaint> FindComplaints(string email, DateTime start, DateTime end);
IList<SesBounce> FindBounces(string email, DateTime start, DateTime end);
IList<SesOpen> FindOpens(string email, DateTime start, DateTime end);
IList<SesSend> FindSends(string email, DateTime start, DateTime end);
IList<SesOpenEvent> FindOpens(string email, DateTime start, DateTime end);
IList<SesSendEvent> FindSends(string email, DateTime start, DateTime end);
IList<SesNotification> FindRaw(DateTime start, DateTime end);
SesNotification FindRaw(long id);
}
Expand Down
16 changes: 8 additions & 8 deletions Projects/SesNotifications.App/Services/NotificationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ public class NotificationService : INotificationService
private readonly ISesBouncesRepository _sesBouncesRepository;
private readonly ISesComplaintsRepository _sesComplaintsRepository;
private readonly ISesDeliveriesRepository _sesDeliveriesRepository;
private readonly ISesOpensRepository _sesOpensRepository;
private readonly ISesSendsRepository _sesSendsRepository;
private readonly ISesOpensEventsRepository _sesOpensEventsRepository;
private readonly ISesSendEventsRepository _sesSendEventsRepository;
private readonly ILogger<NotificationService> _logger;

public NotificationService(INotificationsRepository notificationsRepository,
ISesBouncesRepository sesBouncesRepository,
ISesComplaintsRepository sesComplaintsRepository,
ISesDeliveriesRepository sesDeliveriesRepository,
ISesOpensRepository sesOpensRepository,
ISesSendsRepository sesSendsRepository,
ISesOpensEventsRepository sesOpensEventsRepository,
ISesSendEventsRepository sesSendEventsRepository,
ILogger<NotificationService> logger)
{
_notificationsRepository = notificationsRepository;
_sesBouncesRepository = sesBouncesRepository;
_sesComplaintsRepository = sesComplaintsRepository;
_sesDeliveriesRepository = sesDeliveriesRepository;
_sesOpensRepository = sesOpensRepository;
_sesSendsRepository = sesSendsRepository;
_sesOpensEventsRepository = sesOpensEventsRepository;
_sesSendEventsRepository = sesSendEventsRepository;
_logger = logger;
}

Expand Down Expand Up @@ -133,7 +133,7 @@ private void HandleOpen(string content)

var notification = SaveNotification(open.Mail, content);

_sesOpensRepository.Save(open.Create(notification.Id));
_sesOpensEventsRepository.Save(open.Create(notification.Id));
}

private void HandleSend(string content)
Expand All @@ -142,7 +142,7 @@ private void HandleSend(string content)

var notification = SaveNotification(send.Mail, content);

_sesSendsRepository.Save(send.Create(notification.Id));
_sesSendEventsRepository.Save(send.Create(notification.Id));
}

private SesNotification SaveNotification(SesMail mail, string content)
Expand Down
24 changes: 12 additions & 12 deletions Projects/SesNotifications.App/Services/SearchService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ public class SearchService : ISearchService
private readonly ISesBouncesRepository _sesBouncesRepository;
private readonly ISesComplaintsRepository _sesComplaintsRepository;
private readonly ISesDeliveriesRepository _sesDeliveriesRepository;
private readonly ISesOpensRepository _sesOpensRepository;
private readonly ISesSendsRepository _sesSendsRepository;
private readonly ISesOpensEventsRepository _sesOpensEventsRepository;
private readonly ISesSendEventsRepository _sesSendEventsRepository;
private readonly ILogger<SearchService> _logger;

public SearchService(INotificationsRepository notificationsRepository,
ISesBouncesRepository sesBouncesRepository,
ISesComplaintsRepository sesComplaintsRepository,
ISesDeliveriesRepository sesDeliveriesRepository,
ISesOpensRepository sesOpensRepository,
ISesSendsRepository sesSendsRepository,
ISesOpensEventsRepository sesOpensEventsRepository,
ISesSendEventsRepository sesSendEventsRepository,
ILogger<SearchService> logger)
{
_notificationsRepository = notificationsRepository;
_sesBouncesRepository = sesBouncesRepository;
_sesComplaintsRepository = sesComplaintsRepository;
_sesDeliveriesRepository = sesDeliveriesRepository;
_sesOpensRepository = sesOpensRepository;
_sesSendsRepository = sesSendsRepository;
_sesOpensEventsRepository = sesOpensEventsRepository;
_sesSendEventsRepository = sesSendEventsRepository;
_logger = logger;
}

Expand All @@ -57,18 +57,18 @@ public IList<SesBounce> FindBounces(string email, DateTime start, DateTime end)
: _sesBouncesRepository.FindByRecipientAndSentDateRange($"%{email}%", start, end);
}

public IList<SesOpen> FindOpens(string email, DateTime start, DateTime end)
public IList<SesOpenEvent> FindOpens(string email, DateTime start, DateTime end)
{
return string.IsNullOrEmpty(email)
? _sesOpensRepository.FindBySentDateRange(start, end)
: _sesOpensRepository.FindByRecipientAndSentDateRange($"%{email}%", start, end);
? _sesOpensEventsRepository.FindBySentDateRange(start, end)
: _sesOpensEventsRepository.FindByRecipientAndSentDateRange($"%{email}%", start, end);
}

public IList<SesSend> FindSends(string email, DateTime start, DateTime end)
public IList<SesSendEvent> FindSends(string email, DateTime start, DateTime end)
{
return string.IsNullOrEmpty(email)
? _sesSendsRepository.FindBySentDateRange(start, end)
: _sesSendsRepository.FindByRecipientAndSentDateRange($"%{email}%", start, end);
? _sesSendEventsRepository.FindBySentDateRange(start, end)
: _sesSendEventsRepository.FindByRecipientAndSentDateRange($"%{email}%", start, end);
}

public IList<SesNotification> FindRaw(DateTime start, DateTime end)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace SesNotifications.DataAccess.Entities
{
public class SesOpen : SesCommon
public class SesOpenEvent : SesCommon
{
public virtual string Recipients { get; set; }
public virtual DateTime OpenedAt { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace SesNotifications.DataAccess.Entities
{
public class SesSend : SesCommon
public class SesSendEvent : SesCommon
{
public virtual string Recipients { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace SesNotifications.DataAccess.Mappings
{
public class SesOpenMap : SesCommonMap<SesOpen>
public class SesOpenEventMap : SesCommonMap<SesOpenEvent>
{
public SesOpenMap()
public SesOpenEventMap()
{
Table("ses_notifications.opens");
MapCommon();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace SesNotifications.DataAccess.Mappings
{
public class SesSendMap : SesCommonMap<SesSend>
public class SesSendEventMap : SesCommonMap<SesSendEvent>
{
public SesSendMap()
public SesSendEventMap()
{
Table("ses_notifications.sends");
MapCommon();
Expand Down
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 ISesOpensEventsRepository
{
void Save(SesOpenEvent sesOpenEvent);
SesOpenEvent FindById(long id);
IList<SesOpenEvent> FindByMessageId(string messageId);
IList<SesOpenEvent> FindBySentDateRange(DateTime start, DateTime end);
IList<SesOpenEvent> FindByRecipient(string email);
IList<SesOpenEvent> FindByRecipientAndSentDateRange(string email, DateTime start, DateTime end);
}
}

This file was deleted.

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 ISesSendEventsRepository
{
void Save(SesSendEvent sesSendEvent);
SesSendEvent FindById(long id);
IList<SesSendEvent> FindByMessageId(string messageId);
IList<SesSendEvent> FindBySentDateRange(DateTime start, DateTime end);
IList<SesSendEvent> FindByRecipient(string email);
IList<SesSendEvent> FindByRecipientAndSentDateRange(string email, DateTime start, DateTime end);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using NHibernate;
using NHibernate.Criterion;
using SesNotifications.DataAccess.Entities;
using SesNotifications.DataAccess.Repositories.Interfaces;

namespace SesNotifications.DataAccess.Repositories
{
public class SesOpensEventsRepository : Repository, ISesOpensEventsRepository
{

public SesOpensEventsRepository()
{
}

public SesOpensEventsRepository(ISession session) : base(session)
{
}

public void Save(SesOpenEvent sesOpenEvent)
{
Session.Save(sesOpenEvent);
}

public SesOpenEvent FindById(long id)
{
return Session.Get<SesOpenEvent>(id);
}

public IList<SesOpenEvent> FindByMessageId(string messageId)
{
return Session.CreateCriteria<SesOpenEvent>()
.Add(Restrictions.Eq(nameof(SesOpenEvent.MessageId), messageId))
.List<SesOpenEvent>();
}

public IList<SesOpenEvent> FindBySentDateRange(DateTime start, DateTime end)
{
return Session.CreateCriteria<SesOpenEvent>()
.Add(Restrictions.Ge(nameof(SesOpenEvent.SentAt), start))
.Add(Restrictions.Le(nameof(SesOpenEvent.SentAt), end))
.AddOrder(Order.Desc(nameof(SesOpenEvent.SentAt)))
.List<SesOpenEvent>();
}

public IList<SesOpenEvent> FindByRecipient(string email)
{
return Session.CreateCriteria<SesOpenEvent>()
.Add(Restrictions.InsensitiveLike(nameof(SesOpenEvent.Recipients), email))
.AddOrder(Order.Desc(nameof(SesOpenEvent.SentAt)))
.List<SesOpenEvent>();
}

public IList<SesOpenEvent> FindByRecipientAndSentDateRange(string email, DateTime start, DateTime end)
{
return Session.CreateCriteria<SesOpenEvent>()
.Add(Restrictions.InsensitiveLike(nameof(SesOpenEvent.Recipients), email))
.Add(Restrictions.Ge(nameof(SesOpenEvent.SentAt), start))
.Add(Restrictions.Le(nameof(SesOpenEvent.SentAt), end))
.AddOrder(Order.Desc(nameof(SesOpenEvent.SentAt)))
.List<SesOpenEvent>();
}

}
}
Loading

0 comments on commit 1bf57ad

Please sign in to comment.