-
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.
Adding bounce events in the database.
- Loading branch information
nbitounis
committed
Jun 2, 2020
1 parent
6b13c25
commit 8564761
Showing
6 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
Projects/SesNotifications.DataAccess/Entities/SesBounceEvent.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,14 @@ | ||
using System; | ||
|
||
namespace SesNotifications.DataAccess.Entities | ||
{ | ||
public class SesBounceEvent : SesCommon | ||
{ | ||
public virtual string BounceType { get; set; } | ||
public virtual string BounceSubType { get; set; } | ||
public virtual DateTime CreatedAt { get; set; } | ||
public virtual string FeedbackId { get; set; } | ||
public virtual string ReportingMta { get; set; } | ||
public virtual string BouncedRecipients { get; set; } | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
Projects/SesNotifications.DataAccess/Mappings/SesBounceEventMap.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,19 @@ | ||
using SesNotifications.DataAccess.Entities; | ||
|
||
namespace SesNotifications.DataAccess.Mappings | ||
{ | ||
public class SesBounceEventMap : SesCommonMap<SesBounceEvent> | ||
{ | ||
public SesBounceEventMap() | ||
{ | ||
Table("ses_notifications.bounceevents"); | ||
MapCommon(); | ||
Map(x => x.BounceType).Column("bounce_type"); | ||
Map(x => x.BounceSubType).Column("bounce_sub_type"); | ||
Map(x => x.CreatedAt).Column("created_at"); | ||
Map(x => x.FeedbackId).Column("feedback_id"); | ||
Map(x => x.ReportingMta).Column("reporting_mta"); | ||
Map(x => x.BouncedRecipients).Column("bounced_recipients"); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
Projects/SesNotifications.DataAccess/Repositories/Interfaces/ISesBounceEventsRepository.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 SesNotifications.DataAccess.Entities; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace SesNotifications.DataAccess.Repositories.Interfaces | ||
{ | ||
public interface ISesBounceEventsRepository | ||
{ | ||
void Save(SesBounceEvent sesBounceEvent); | ||
SesBounceEvent FindById(long id); | ||
IList<SesBounceEvent> FindByMessageId(string messageId); | ||
IList<SesBounceEvent> FindBySentDateRange(DateTime start, DateTime end); | ||
IList<SesBounceEvent> FindByRecipient(string email); | ||
IList<SesBounceEvent> FindByRecipientAndSentDateRange(string email, DateTime start, DateTime end); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
Projects/SesNotifications.DataAccess/Repositories/SesBounceEventsRepository.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,64 @@ | ||
using NHibernate; | ||
using NHibernate.Criterion; | ||
using SesNotifications.DataAccess.Entities; | ||
using SesNotifications.DataAccess.Repositories.Interfaces; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace SesNotifications.DataAccess.Repositories | ||
{ | ||
public class SesBounceEventsRepository : Repository, ISesBounceEventsRepository | ||
{ | ||
public SesBounceEventsRepository() | ||
{ | ||
} | ||
|
||
public SesBounceEventsRepository(ISession session) : base(session) | ||
{ | ||
} | ||
|
||
public void Save(SesBounceEvent sesBounceEvent) | ||
{ | ||
Session.Save(sesBounceEvent); | ||
} | ||
|
||
public SesBounceEvent FindById(long id) | ||
{ | ||
return Session.Get<SesBounceEvent>(id); | ||
} | ||
|
||
public IList<SesBounceEvent> FindByMessageId(string messageId) | ||
{ | ||
return Session.CreateCriteria<SesBounceEvent>() | ||
.Add(Restrictions.Eq(nameof(SesBounceEvent.MessageId), messageId)) | ||
.List<SesBounceEvent>(); | ||
} | ||
|
||
public IList<SesBounceEvent> FindBySentDateRange(DateTime start, DateTime end) | ||
{ | ||
return Session.CreateCriteria<SesBounceEvent>() | ||
.Add(Restrictions.Ge(nameof(SesBounceEvent.SentAt), start)) | ||
.Add(Restrictions.Le(nameof(SesBounceEvent.SentAt), end)) | ||
.AddOrder(Order.Desc(nameof(SesBounceEvent.SentAt))) | ||
.List<SesBounceEvent>(); | ||
} | ||
|
||
public IList<SesBounceEvent> FindByRecipient(string email) | ||
{ | ||
return Session.CreateCriteria<SesBounceEvent>() | ||
.Add(Restrictions.InsensitiveLike(nameof(SesBounceEvent.BouncedRecipients), email)) | ||
.AddOrder(Order.Desc(nameof(SesBounceEvent.SentAt))) | ||
.List<SesBounceEvent>(); | ||
} | ||
|
||
public IList<SesBounceEvent> FindByRecipientAndSentDateRange(string email, DateTime start, DateTime end) | ||
{ | ||
return Session.CreateCriteria<SesBounceEvent>() | ||
.Add(Restrictions.InsensitiveLike(nameof(SesBounceEvent.BouncedRecipients), email)) | ||
.Add(Restrictions.Ge(nameof(SesBounceEvent.SentAt), start)) | ||
.Add(Restrictions.Le(nameof(SesBounceEvent.SentAt), end)) | ||
.AddOrder(Order.Desc(nameof(SesBounceEvent.SentAt))) | ||
.List<SesBounceEvent>(); | ||
} | ||
} | ||
} |
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