From 769cacd8b613b467b9c082d9c7e008c172be9244 Mon Sep 17 00:00:00 2001 From: Shaed Parkar Date: Fri, 3 Nov 2023 11:47:33 +0000 Subject: [PATCH] move all mapping code --- .../NotificationApi.Contract/MessageType.cs | 1 + .../NotificationType.cs | 1 + ...ParticipantEmailNotificationsController.cs | 49 +------------------ .../Services/NotificationParameterMapper.cs | 47 ++++++++++++++++++ 4 files changed, 51 insertions(+), 47 deletions(-) diff --git a/NotificationApi/NotificationApi.Contract/MessageType.cs b/NotificationApi/NotificationApi.Contract/MessageType.cs index 6ad240bf..f95d7cfe 100644 --- a/NotificationApi/NotificationApi.Contract/MessageType.cs +++ b/NotificationApi/NotificationApi.Contract/MessageType.cs @@ -1,6 +1,7 @@ namespace NotificationApi.Contract { // Public contract for NotificationApi.Domain.Enums.MessageType + [Obsolete("Will be replaced with a new endpoint")] public enum MessageType { Email = 1, diff --git a/NotificationApi/NotificationApi.Contract/NotificationType.cs b/NotificationApi/NotificationApi.Contract/NotificationType.cs index 04e9bc4d..f0ff84c9 100644 --- a/NotificationApi/NotificationApi.Contract/NotificationType.cs +++ b/NotificationApi/NotificationApi.Contract/NotificationType.cs @@ -1,6 +1,7 @@ namespace NotificationApi.Contract { // Public contract for NotificationApi.Domain.Enums.NotificationType + [Obsolete("Will be replaced with a new endpoint")] public enum NotificationType { CreateIndividual = 1, diff --git a/NotificationApi/NotificationApi/Controllers/ParticipantEmailNotificationsController.cs b/NotificationApi/NotificationApi/Controllers/ParticipantEmailNotificationsController.cs index 672e046b..5d6037c2 100644 --- a/NotificationApi/NotificationApi/Controllers/ParticipantEmailNotificationsController.cs +++ b/NotificationApi/NotificationApi/Controllers/ParticipantEmailNotificationsController.cs @@ -159,24 +159,7 @@ RoleNames.Judge when request.HasAJudiciaryUsername() => NotificationType.Hearing }; var parameters = NotificationParameterMapper.MapToSingleDayConfirmationExistingUser(request); - - if (request.RoleName == RoleNames.Judge) - { - parameters.Add(NotifyParams.Judge, request.DisplayName); - parameters.Add(NotifyParams.CourtroomAccountUserName, request.Username); - } - - if (request.RoleName == RoleNames.JudicialOfficeHolder) - { - parameters.Add(NotifyParams.JudicialOfficeHolder, request.Name); - } - - if (request.RoleName == RoleNames.Representative) - { - parameters.Add(NotifyParams.ClientName, request.Representee); - parameters.Add(NotifyParams.SolicitorName, request.Name); - } - + await ProcessRequest(request.ContactEmail, request.ParticipantId, request.HearingId, notificationType, parameters); @@ -213,23 +196,6 @@ RoleNames.Judge when request.HasAJudiciaryUsername() => NotificationType var parameters = NotificationParameterMapper.MapToMultiDayConfirmationForExistingUser(request); - if (request.RoleName == RoleNames.Judge) - { - parameters.Add(NotifyParams.Judge, request.DisplayName); - parameters.Add(NotifyParams.CourtroomAccountUserName, request.Username.ToLower()); - } - - if (request.RoleName == RoleNames.JudicialOfficeHolder) - { - parameters.Add(NotifyParams.JudicialOfficeHolder, request.Name); - } - - if (request.RoleName == RoleNames.Representative) - { - parameters.Add(NotifyParams.ClientName, request.Representee); - parameters.Add(NotifyParams.SolicitorName, request.Name); - } - await ProcessRequest(request.ContactEmail, request.ParticipantId, request.HearingId, notificationType, parameters); @@ -260,18 +226,7 @@ RoleNames.JudicialOfficeHolder when request.HasAJudiciaryUsername() => Notificat }; var parameters = NotificationParameterMapper.MapToSingleDayReminder(request); - - if (request.RoleName == RoleNames.JudicialOfficeHolder) - { - parameters.Add(NotifyParams.JudicialOfficeHolder, request.Name); - } - - if (request.RoleName == RoleNames.Representative) - { - parameters.Add(NotifyParams.ClientName, request.Representee); - parameters.Add(NotifyParams.SolicitorName, request.Name); - } - + await ProcessRequest(request.ContactEmail, request.ParticipantId, request.HearingId, notificationType, parameters); return Ok(); diff --git a/NotificationApi/NotificationApi/Services/NotificationParameterMapper.cs b/NotificationApi/NotificationApi/Services/NotificationParameterMapper.cs index d529cc04..d9bcf8c4 100644 --- a/NotificationApi/NotificationApi/Services/NotificationParameterMapper.cs +++ b/NotificationApi/NotificationApi/Services/NotificationParameterMapper.cs @@ -80,6 +80,24 @@ public static Dictionary MapToSingleDayConfirmationExistingUser( {NotifyParams.UserName, request.Username.ToLower()}, {NotifyParams.DayMonthYearCy, request.ScheduledDateTime.ToEmailDateCyLocale()} }; + + if (request.RoleName == RoleNames.Judge) + { + parameters.Add(NotifyParams.Judge, request.DisplayName); + parameters.Add(NotifyParams.CourtroomAccountUserName, request.Username); + } + + if (request.RoleName == RoleNames.JudicialOfficeHolder) + { + parameters.Add(NotifyParams.JudicialOfficeHolder, request.Name); + } + + if (request.RoleName == RoleNames.Representative) + { + parameters.Add(NotifyParams.ClientName, request.Representee); + parameters.Add(NotifyParams.SolicitorName, request.Name); + } + return parameters; } @@ -99,6 +117,24 @@ public static Dictionary MapToMultiDayConfirmationForExistingUse {NotifyParams.UserName, request.Username.ToLower()}, {NotifyParams.TotalDays, request.TotalDays.ToString()}, }; + + if (request.RoleName == RoleNames.Judge) + { + parameters.Add(NotifyParams.Judge, request.DisplayName); + parameters.Add(NotifyParams.CourtroomAccountUserName, request.Username.ToLower()); + } + + if (request.RoleName == RoleNames.JudicialOfficeHolder) + { + parameters.Add(NotifyParams.JudicialOfficeHolder, request.Name); + } + + if (request.RoleName == RoleNames.Representative) + { + parameters.Add(NotifyParams.ClientName, request.Representee); + parameters.Add(NotifyParams.SolicitorName, request.Name); + } + return parameters; } @@ -115,6 +151,17 @@ public static Dictionary MapToSingleDayReminder(SingleDayHearing {NotifyParams.StartTime, request.ScheduledDateTime.ToEmailTimeGbLocale()}, {NotifyParams.UserName, request.Username.ToLower()}, }; + + if (request.RoleName == RoleNames.JudicialOfficeHolder) + { + parameters.Add(NotifyParams.JudicialOfficeHolder, request.Name); + } + + if (request.RoleName == RoleNames.Representative) + { + parameters.Add(NotifyParams.ClientName, request.Representee); + parameters.Add(NotifyParams.SolicitorName, request.Name); + } return parameters; }