Adding
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Agreements;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.DataTransfer
|
||||
{
|
||||
public class MemberOptInAgreementInformation : MemberOptInInformation
|
||||
{
|
||||
public MemberOptInAgreementInformation(MemberOptInSettings settings, Agreement agreement, IEnumerable<AgreementAccount> accounts, bool hasPendingUpdates)
|
||||
: base(settings, hasPendingUpdates)
|
||||
{
|
||||
Agreement = agreement;
|
||||
Accounts = accounts;
|
||||
}
|
||||
|
||||
public Agreement Agreement { get; set; }
|
||||
public IEnumerable<AgreementAccount> Accounts { get; set; }
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.DataTransfer;
|
||||
|
||||
public class MemberOptInInformation
|
||||
{
|
||||
public MemberOptInInformation(MemberOptInSettings settings, bool hasPendingUpdates)
|
||||
{
|
||||
MemberOptinSettings = settings;
|
||||
HasPendingUpdates = hasPendingUpdates;
|
||||
}
|
||||
|
||||
public MemberOptInSettings MemberOptinSettings { get; set; }
|
||||
public bool HasPendingUpdates { get; set; }
|
||||
}
|
||||
+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; }
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
|
||||
public enum BatchState
|
||||
{
|
||||
New,
|
||||
TransferPending
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
|
||||
public enum DnaAuditProcessType
|
||||
{
|
||||
DNAAgreement,
|
||||
DNAAccounts,
|
||||
DNAOrganization
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
|
||||
public enum EmailStatus
|
||||
{
|
||||
FailingDelivery,
|
||||
DeliveredSuccessfully
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
|
||||
public enum PreferenceType
|
||||
{
|
||||
ENotification,
|
||||
EStatements,
|
||||
UnifiedOptIn,
|
||||
ENotificationsEmail,
|
||||
EStatementsEmail,
|
||||
UnifiedOptInEmail
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
|
||||
public enum UserType
|
||||
{
|
||||
Associate,
|
||||
Member,
|
||||
System
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
|
||||
public enum XdiFileType
|
||||
{
|
||||
DeleteMember,
|
||||
AddMemberElectronic,
|
||||
UpdateMemberToElectronic,
|
||||
UpdateMemberToPrint,
|
||||
UpdateMemberEmail
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<AssemblyVersion>1.2.3</AssemblyVersion>
|
||||
<FileVersion>1.2.3</FileVersion>
|
||||
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="LCU.Api.Internal.FTPLib" Version="2.2.0" />
|
||||
<PackageReference Include="LCU.Library.Internal.CoreApiWrapperModel" Version="2.26.0" />
|
||||
<PackageReference Include="LCU.Library.Internal.LcuMassTransitModels" Version="1.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Text.Json.Serialization;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Models;
|
||||
|
||||
public abstract class Auditable
|
||||
{
|
||||
public string CreatedBy { get; set; }
|
||||
public DateTime Created { get; set; }
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public UserType CreatedByType { get; set; }
|
||||
public string LastUpdatedBy { get; set; }
|
||||
public DateTime LastUpdated { get; set; }
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public UserType LastUpdatedByType { get; set; }
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Models;
|
||||
|
||||
public interface IAuditableChanges
|
||||
{
|
||||
void SystemModified(Auditable entity, string modifiedBy);
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Requests;
|
||||
|
||||
public class MemberOptinRequest : IValidatableObject
|
||||
{
|
||||
[Required] public string UserId { get; set; }
|
||||
public string Email { get; set; }
|
||||
[Required] public string Value { get; set; }
|
||||
[Required] public string LegalReference { get; set; }
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
var results = new List<ValidationResult>();
|
||||
|
||||
if (!string.Equals(Value, DeliveryPreference.Electronic, StringComparison.InvariantCultureIgnoreCase) &&
|
||||
!string.Equals(Value, DeliveryPreference.Paper, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
results.Add(new ValidationResult(
|
||||
$"Invalid Option for Unified Opt-In Preference",
|
||||
new[] { "Value" }));
|
||||
}
|
||||
|
||||
if (string.Equals(Value, DeliveryPreference.Electronic, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Email))
|
||||
{
|
||||
results.Add(new ValidationResult("Email is required when Opting in", new[] { "Email" }));
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
var unused = new System.Net.Mail.MailAddress(Email);
|
||||
}
|
||||
catch
|
||||
{
|
||||
results.Add(new ValidationResult("Invalid Email Format", new[] { "Email" }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
public bool IsElectronicRequest()
|
||||
{
|
||||
return string.Equals(Value, DeliveryPreference.Electronic, StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
||||
public bool IsPaperRequest()
|
||||
{
|
||||
return string.Equals(Value, DeliveryPreference.Paper, StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Requests;
|
||||
|
||||
public class MemberPreferenceRequest
|
||||
{
|
||||
[Required]
|
||||
public string UserId { get; set; }
|
||||
[Required]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public PreferenceType Preference { get; set; }
|
||||
[Required]
|
||||
public string Value { get; set; }
|
||||
[Required]
|
||||
public string LegalReference { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user