Adding
This commit is contained in:
+9
@@ -0,0 +1,9 @@
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
|
||||
public class ApplicationUser
|
||||
{
|
||||
public string UserName { get; set; }
|
||||
public UserType UserType { get; set; }
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
|
||||
public static class DeliveryPreference
|
||||
{
|
||||
public const string Paper = "Paper";
|
||||
public const string Electronic = "Electronic";
|
||||
public const string Hold = "Hold";
|
||||
public const string Microfiche = "Microfiche";
|
||||
|
||||
public static string MapMailCodeToPreference(string mailCode)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(mailCode)) return "";
|
||||
|
||||
switch (mailCode)
|
||||
{
|
||||
case "3":
|
||||
return DeliveryPreference.Hold;
|
||||
case "4":
|
||||
return DeliveryPreference.Microfiche;
|
||||
case "5":
|
||||
return DeliveryPreference.Electronic;
|
||||
default:
|
||||
return DeliveryPreference.Paper;
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Text.Json.Serialization;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
|
||||
public class DnaAuditProcess
|
||||
{
|
||||
public int ProcessId { get; set; }
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public DnaAuditProcessType DnaProcessType { get; set; }
|
||||
public DateTime LastUpdated { get; set; }
|
||||
public int ConsecutiveFailures { get; set; }
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
|
||||
public interface IMemberPreferences
|
||||
{
|
||||
Task Add(MemberPreference preferenceChange);
|
||||
}
|
||||
+186
@@ -0,0 +1,186 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Models;
|
||||
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Entities
|
||||
{
|
||||
public class MemberOptInSettings : Auditable
|
||||
{
|
||||
public MemberOptInSettings()
|
||||
{
|
||||
}
|
||||
|
||||
public int Id { get; set; }
|
||||
public string UserId { get; set; }
|
||||
public string EStatements { get; set; }
|
||||
public string ENotifications { get; set; }
|
||||
public string UniversalOptIn { get; set; }
|
||||
public string LegalVersion { get; set; }
|
||||
public DateTime? LegalDate { get; set; }
|
||||
public string UnifiedOptInEmail { get; set; }
|
||||
public EmailStatus? UnifiedOptInEmailStatus { get; set; }
|
||||
public DateTime? UnifiedOptInEmailFirstSent { get; set; }
|
||||
public DateTime? UnifiedOptInEmailLastSent { get; set; }
|
||||
public int UnifiedOptInEmailStatusCount { get; set; } = 0;
|
||||
public string EStatementsEmail { get; set; }
|
||||
public EmailStatus? EStatementsEmailStatus { get; set; }
|
||||
public DateTime? EStatementsEmailFirstSent { get; set; }
|
||||
public DateTime? EStatementsEmailLastSent { get; set; }
|
||||
public int EStatementsEmailStatusCount { get; set; } = 0;
|
||||
public string ENotificationsEmail { get; set; }
|
||||
public EmailStatus? ENotificationsEmailStatus { get; set; }
|
||||
public DateTime? ENotificationsEmailFirstSent { get; set; }
|
||||
public DateTime? ENotificationsEmailLastSent { get; set; }
|
||||
public int ENotificationsEmailStatusCount { get; set; } = 0;
|
||||
|
||||
public void ApplyAll(IReadOnlyCollection<MemberPreference> memberPreferences)
|
||||
{
|
||||
Id = 0;
|
||||
UserId = "";
|
||||
EStatements = null;
|
||||
ENotifications = null;
|
||||
UniversalOptIn = null;
|
||||
LegalVersion = null;
|
||||
LegalDate = null;
|
||||
UnifiedOptInEmail = null;
|
||||
EStatementsEmail = null;
|
||||
ENotificationsEmail = null;
|
||||
|
||||
if (memberPreferences != null && memberPreferences.Any())
|
||||
{
|
||||
UserId = memberPreferences.First().UserId;
|
||||
foreach (var memberPreference in memberPreferences)
|
||||
{
|
||||
Apply(memberPreference);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Apply(MemberPreference memberPreference)
|
||||
{
|
||||
void ClearUnifiedOptInEmailTracking()
|
||||
{
|
||||
UnifiedOptInEmailStatus = null;
|
||||
UnifiedOptInEmailFirstSent = null;
|
||||
UnifiedOptInEmailLastSent = null;
|
||||
UnifiedOptInEmailStatusCount = 0;
|
||||
}
|
||||
|
||||
void ClearENotificationEmailTracking()
|
||||
{
|
||||
ENotificationsEmailStatus = null;
|
||||
ENotificationsEmailFirstSent = null;
|
||||
ENotificationsEmailLastSent = null;
|
||||
ENotificationsEmailStatusCount = 0;
|
||||
}
|
||||
|
||||
void ClearEStatementsEmailTracking()
|
||||
{
|
||||
EStatementsEmailStatus = null;
|
||||
EStatementsEmailFirstSent = null;
|
||||
EStatementsEmailLastSent = null;
|
||||
EStatementsEmailStatusCount = 0;
|
||||
}
|
||||
|
||||
switch (memberPreference.Preference)
|
||||
{
|
||||
case PreferenceType.UnifiedOptIn:
|
||||
{
|
||||
if (!memberPreference.Value.Equals(UniversalOptIn, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
ClearUnifiedOptInEmailTracking();
|
||||
}
|
||||
|
||||
UniversalOptIn = memberPreference.Value;
|
||||
LegalVersion = memberPreference.LegalReference;
|
||||
LegalDate = DateTime.Now;
|
||||
|
||||
break;
|
||||
}
|
||||
case PreferenceType.UnifiedOptInEmail:
|
||||
{
|
||||
ClearUnifiedOptInEmailTracking();
|
||||
UnifiedOptInEmail = memberPreference.Value;
|
||||
|
||||
break;
|
||||
}
|
||||
case PreferenceType.ENotification:
|
||||
{
|
||||
if (!memberPreference.Value.Equals(ENotifications, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
ClearENotificationEmailTracking();
|
||||
}
|
||||
|
||||
ENotifications = memberPreference.Value;
|
||||
|
||||
break;
|
||||
}
|
||||
case PreferenceType.ENotificationsEmail:
|
||||
{
|
||||
ClearENotificationEmailTracking();
|
||||
ENotificationsEmail = memberPreference.Value;
|
||||
|
||||
break;
|
||||
}
|
||||
case PreferenceType.EStatements:
|
||||
{
|
||||
if (!memberPreference.Value.Equals(EStatements, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
ClearEStatementsEmailTracking();
|
||||
}
|
||||
|
||||
EStatements = memberPreference.Value;
|
||||
|
||||
break;
|
||||
}
|
||||
case PreferenceType.EStatementsEmail:
|
||||
{
|
||||
ClearEStatementsEmailTracking();
|
||||
EStatementsEmail = memberPreference.Value;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new InvalidOperationException(
|
||||
$"Unknown preference type update: {memberPreference.Preference}");
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsUnifiedPaperEnrolled()
|
||||
{
|
||||
return string.Equals(UniversalOptIn, DeliveryPreference.Paper, StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
||||
public bool IsUnifiedElectronicEnrolled()
|
||||
{
|
||||
return string.Equals(UniversalOptIn, DeliveryPreference.Electronic, StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
||||
public bool HasAnyUnifiedPreference()
|
||||
{
|
||||
return !string.IsNullOrWhiteSpace(UniversalOptIn);
|
||||
}
|
||||
|
||||
public bool IsOldNoticesElectronicEnrolled()
|
||||
{
|
||||
return string.Equals(ENotifications, DeliveryPreference.Electronic, StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
||||
public bool IsOldStatementsElectronicEnrolled()
|
||||
{
|
||||
return string.Equals(EStatements, DeliveryPreference.Electronic, StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
||||
public bool Compare(MemberOptInSettings other)
|
||||
{
|
||||
return other != null && other.ENotifications == ENotifications &&
|
||||
other.EStatements == EStatements &&
|
||||
other.UniversalOptIn == UniversalOptIn &&
|
||||
other.UnifiedOptInEmail == UnifiedOptInEmail &&
|
||||
other.EStatementsEmail == EStatementsEmail &&
|
||||
other.ENotificationsEmail == ENotificationsEmail;
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Models;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
|
||||
public class MemberPreference : Auditable
|
||||
{
|
||||
public MemberPreference()
|
||||
{
|
||||
}
|
||||
|
||||
public int Id { get; set; }
|
||||
public string UserId { get; set; }
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public PreferenceType Preference { get; set; }
|
||||
public string Value { get; set; }
|
||||
public string LegalReference { get; set; }
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Text.Json.Serialization;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
|
||||
public class XdiBatchItem
|
||||
{
|
||||
public string UserId { get; set; }
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public BatchState BatchState { get; set; }
|
||||
public DateTime Created { get; set; }
|
||||
public DateTime LastUpdated { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user