feat(notification-outbox): add Type field to NotificationList
This commit is contained in:
@@ -1,9 +1,12 @@
|
|||||||
|
using ScadaLink.Commons.Types.Enums;
|
||||||
|
|
||||||
namespace ScadaLink.Commons.Entities.Notifications;
|
namespace ScadaLink.Commons.Entities.Notifications;
|
||||||
|
|
||||||
public class NotificationList
|
public class NotificationList
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
public NotificationType Type { get; set; } = NotificationType.Email;
|
||||||
public ICollection<NotificationRecipient> Recipients { get; set; } = new List<NotificationRecipient>();
|
public ICollection<NotificationRecipient> Recipients { get; set; } = new List<NotificationRecipient>();
|
||||||
|
|
||||||
public NotificationList(string name)
|
public NotificationList(string name)
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ public class NotificationListConfiguration : IEntityTypeConfiguration<Notificati
|
|||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(200);
|
.HasMaxLength(200);
|
||||||
|
|
||||||
|
builder.Property(n => n.Type)
|
||||||
|
.HasConversion<string>()
|
||||||
|
.HasMaxLength(32)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
builder.HasMany(n => n.Recipients)
|
builder.HasMany(n => n.Recipients)
|
||||||
.WithOne()
|
.WithOne()
|
||||||
.HasForeignKey(r => r.NotificationListId)
|
.HasForeignKey(r => r.NotificationListId)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using ScadaLink.Commons.Entities.Instances;
|
|||||||
using ScadaLink.Commons.Entities.Notifications;
|
using ScadaLink.Commons.Entities.Notifications;
|
||||||
using ScadaLink.Commons.Entities.Sites;
|
using ScadaLink.Commons.Entities.Sites;
|
||||||
using ScadaLink.Commons.Entities.Templates;
|
using ScadaLink.Commons.Entities.Templates;
|
||||||
|
using ScadaLink.Commons.Types.Enums;
|
||||||
using ScadaLink.ConfigurationDatabase;
|
using ScadaLink.ConfigurationDatabase;
|
||||||
using ScadaLink.ConfigurationDatabase.Repositories;
|
using ScadaLink.ConfigurationDatabase.Repositories;
|
||||||
using ScadaLink.ConfigurationDatabase.Services;
|
using ScadaLink.ConfigurationDatabase.Services;
|
||||||
@@ -224,6 +225,17 @@ public class NotificationRepositoryTests : IDisposable
|
|||||||
Assert.Null(await _repository.GetNotificationListByIdAsync(list.Id));
|
Assert.Null(await _repository.GetNotificationListByIdAsync(list.Id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task NotificationList_PersistsType()
|
||||||
|
{
|
||||||
|
var list = new NotificationList("ops") { Type = NotificationType.Email };
|
||||||
|
await _repository.AddNotificationListAsync(list);
|
||||||
|
await _repository.SaveChangesAsync();
|
||||||
|
_context.ChangeTracker.Clear();
|
||||||
|
var loaded = await _repository.GetListByNameAsync("ops");
|
||||||
|
Assert.Equal(NotificationType.Email, loaded!.Type);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Constructor_NullContext_Throws()
|
public void Constructor_NullContext_Throws()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user