From 69afe89bc6a8af7c7fcd5a3a522501fe5244d1b5 Mon Sep 17 00:00:00 2001 From: Kesh Ramduny Date: Mon, 29 Jun 2026 21:57:16 +0100 Subject: [PATCH 1/5] FCT2_20202 - Fix Authentication on Materials UI --- DdeiClient/Clients/MasterDataServiceClient.cs | 2775 ++++++++--------- DdeiClient/Model/MasterDataServiceCookie.cs | 43 - polaris-gateway/Functions/BaseFunction.cs | 61 +- .../Common/Dto/Request/CmsAuthValues.cs | 18 +- 4 files changed, 1329 insertions(+), 1568 deletions(-) delete mode 100644 DdeiClient/Model/MasterDataServiceCookie.cs diff --git a/DdeiClient/Clients/MasterDataServiceClient.cs b/DdeiClient/Clients/MasterDataServiceClient.cs index 83e365b2e..f2884994a 100644 --- a/DdeiClient/Clients/MasterDataServiceClient.cs +++ b/DdeiClient/Clients/MasterDataServiceClient.cs @@ -2,1797 +2,1654 @@ // Copyright (c) The Crown Prosecution Service. All rights reserved. // -namespace DdeiClient.Clients +namespace DdeiClient.Clients; + +using Common.Constants; +using Common.Dto.Request; +using Common.Dto.Request.HouseKeeping; +using Common.Dto.Response.HouseKeeping; +using Common.Dto.Response.HouseKeeping.Pcd; +using DdeiClient.Clients.Interfaces; +using DdeiClient.Diagnostics; +using DdeiClient.Utils; +using Microsoft; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using ApiClient = Cps.MasterDataService.Infrastructure.ApiClient; + +/// +/// Repesents Mds API client. +/// +public class MasterDataServiceClient(IMasterDataServiceApiClientFactory mdsApiClientFactory, ILoggerFactory loggerFactory) + : IMasterDataServiceClient { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.IO; - using System.Linq; - using System.Text.Json; - using Azure.Core; - using Common.Constants; - using Common.Dto.Request; - using Common.Dto.Request.HouseKeeping; - using Common.Dto.Response.HouseKeeping; - using Common.Dto.Response.HouseKeeping.Pcd; - using DdeiClient.Clients.Interfaces; - using DdeiClient.Diagnostics; - using DdeiClient.Model; - using DdeiClient.Utils; - using Microsoft; - using Microsoft.AspNetCore.Mvc; - using Microsoft.Extensions.Logging; - using ApiClient = Cps.MasterDataService.Infrastructure.ApiClient; + private readonly IMasterDataServiceApiClientFactory mdsApiClientFactory = mdsApiClientFactory; + private readonly ILogger logger = loggerFactory.CreateLogger(); - /// - /// Repesents Mds API client. - /// - public class MasterDataServiceClient( - IMasterDataServiceApiClientFactory mdsApiClientFactory, - ILoggerFactory loggerFactory) : IMasterDataServiceClient + /// + public async Task GetCaseSummaryAsync(GetCaseSummaryRequest request, CmsAuthValues cmsAuthValues) { - private readonly IMasterDataServiceApiClientFactory mdsApiClientFactory = mdsApiClientFactory; - private readonly ILogger logger = loggerFactory.CreateLogger(); - - /// - public async Task GetCaseSummaryAsync(GetCaseSummaryRequest request, CmsAuthValues cmsAuthValues) - { - Requires.NotNull(request); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); + Requires.NotNull(request); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); - var stopwatch = Stopwatch.StartNew(); + var stopwatch = Stopwatch.StartNew(); - var operationName = "GetCaseSummary"; + var operationName = "GetCaseSummary"; - CaseSummaryResponse result = null; + CaseSummaryResponse result = null; - try - { - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); - - var data = await client.GetCaseSummaryAsync(request.CaseId); + try + { + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); - if (data?.Urn is not null) - { - result = new CaseSummaryResponse( - data.Id, - data.Urn, - data.LeadDefendantFirstNames, - data.LeadDefendantSurname, - data.NumberOfDefendants, - data.UnitName); - } + var data = await client.GetCaseSummaryAsync(request.CaseId); - this.LogOperationCompletedEvent(operationName, request, stopwatch.Elapsed, string.Empty); - } - catch (Exception exception) + if (data?.Urn is not null) { - this.HandleException(operationName, exception, request, stopwatch.Elapsed); - throw; + result = new CaseSummaryResponse( + data.Id, + data.Urn, + data.LeadDefendantFirstNames, + data.LeadDefendantSurname, + data.NumberOfDefendants, + data.UnitName); } - return result; + this.LogOperationCompletedEvent(operationName, request, stopwatch.Elapsed, string.Empty); } - - /// - public async Task GetUnusedMaterialsAsync(GetUnusedMaterialsRequest request, CmsAuthValues cmsAuthValues) + catch (Exception exception) { - Requires.NotNull(request); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); - - var stopwatch = Stopwatch.StartNew(); - - const string OperationName = "GetUnusedMaterials"; - - try - { - UnusedMaterialsResponse results = new(); - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); - - string additionalInfo = $"received #0 unused materials"; - var data = await client.GetUnusedMaterialsAsync(request.CaseId); - - if (data is not null) - { - results = new UnusedMaterialsResponse - { - Exhibits = data.Exhibits?.Select(exhibit => new Exhibit( - exhibit.Id, - exhibit.Title, - exhibit.OriginalFileName, - string.Empty, - exhibit.DocumentType, - exhibit.Link, - exhibit.Status.ToString(), - exhibit.ReceivedDate?.DateTime, - exhibit.Reference, - exhibit.Producer)).ToList(), - - MgForms = data.MgForms?.Select(mgForm => new MgForm( - mgForm.Id, - mgForm.Title, - mgForm.OriginalFileName, - mgForm.MaterialType, - null, - mgForm.Link, - mgForm.Date.ToString(), - mgForm.Date?.DateTime)).ToList(), - - OtherMaterials = data.OtherMaterials?.Select(otherMaterial => new MgForm( - otherMaterial.Id, - otherMaterial.Title, - otherMaterial.OriginalFileName, - otherMaterial.MaterialType, - null, - otherMaterial.Link, - otherMaterial.Status.ToString(), - otherMaterial.Date?.DateTime)).ToList(), - - Statements = data.Statements?.Select(statement => new Statement( - statement.Id, - statement.WitnessId, - statement.Title, - statement.OriginalFileName, - string.Empty, - statement.DocumentType, - statement.Link, - statement.Status.ToString(), - statement.Date?.DateTime, - statement.StatementTakenDate?.DateTime)).ToList(), - }; - - // Generate additional info string based on the collections - additionalInfo = this.BuildAdditionalInfo(results); - } - - this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, additionalInfo); - return results; - } - catch (Exception exception) - { - this.HandleException(OperationName, exception, request, stopwatch.Elapsed); - throw; - } + this.HandleException(operationName, exception, request, stopwatch.Elapsed); + throw; } - /// - public async Task GetUsedExhibitsAsync(GetUsedExhibitsRequest request, CmsAuthValues cmsAuthValues) - { - Requires.NotNull(request); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); - - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "GetUsedExhibits"; - - try - { - UsedExhibitsResponse results = new() { Exhibits = [] }; - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); - - string additionalInfo = $"received #0 used exhibits"; - - var data = await client.GetUsedExhibitsAsync(request.CaseId); + return result; + } - if (data?.Exhibits is not null) - { - results = new UsedExhibitsResponse - { - Exhibits = data.Exhibits.Select(exhibit => new Exhibit( - exhibit.Id, - exhibit.Title, - exhibit.OriginalFileName, - string.Empty, - exhibit.DocumentType, - exhibit.Link, - exhibit.Status.ToString(), - exhibit.ReceivedDate?.DateTime, - exhibit.Reference, - exhibit.Producer)).ToList(), - }; + /// + public async Task GetUnusedMaterialsAsync(GetUnusedMaterialsRequest request, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(request); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); - if (results.Exhibits.Count != 0) - { - additionalInfo = $"received #{results.Exhibits.Count} used exhibits"; - } - } + var stopwatch = Stopwatch.StartNew(); - this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, additionalInfo); - return results; - } - catch (Exception exception) - { - this.HandleException(OperationName, exception, request, stopwatch.Elapsed); - throw; - } - } + const string OperationName = "GetUnusedMaterials"; - /// - public async Task GetUsedMgFormsAsync(GetUsedMgFormsRequest request, CmsAuthValues cmsAuthValues) + try { - Requires.NotNull(request); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); + UnusedMaterialsResponse results = new (); + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "GetUsedMgForms"; + string additionalInfo = $"received #0 unused materials"; + var data = await client.GetUnusedMaterialsAsync(request.CaseId); - try + if (data is not null) { - UsedMgFormsResponse? results = new() { MgForms = [] }; - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); - - var data = await client.GetUsedMgFormsAsync(request.CaseId); - - if (data?.MgForms is not null) + results = new UnusedMaterialsResponse { - results = new UsedMgFormsResponse - { - MgForms = data.MgForms?.Select(mgForm => new MgForm( - mgForm.Id, - mgForm.Title, - mgForm.OriginalFileName, - mgForm.MaterialType, - null, - mgForm.Link, - mgForm.Date.ToString(), - mgForm.Date?.DateTime)).ToList(), - }; - } + Exhibits = data.Exhibits?.Select(exhibit => new Exhibit( + exhibit.Id, + exhibit.Title, + exhibit.OriginalFileName, + string.Empty, + exhibit.DocumentType, + exhibit.Link, + exhibit.Status.ToString(), + exhibit.ReceivedDate?.DateTime, + exhibit.Reference, + exhibit.Producer)).ToList(), + + MgForms = data.MgForms?.Select(mgForm => new MgForm( + mgForm.Id, + mgForm.Title, + mgForm.OriginalFileName, + mgForm.MaterialType, + null, + mgForm.Link, + mgForm.Date.ToString(), + mgForm.Date?.DateTime)).ToList(), + + OtherMaterials = data.OtherMaterials?.Select(otherMaterial => new MgForm( + otherMaterial.Id, + otherMaterial.Title, + otherMaterial.OriginalFileName, + otherMaterial.MaterialType, + null, + otherMaterial.Link, + otherMaterial.Status.ToString(), + otherMaterial.Date?.DateTime)).ToList(), - string additionalInfo = results?.MgForms is { Count: > 0 } - ? $"received #{results.MgForms.Count} used MG forms" - : "received #0 used MG forms"; + Statements = data.Statements?.Select(statement => new Statement( + statement.Id, + statement.WitnessId, + statement.Title, + statement.OriginalFileName, + string.Empty, + statement.DocumentType, + statement.Link, + statement.Status.ToString(), + statement.Date?.DateTime, + statement.StatementTakenDate?.DateTime)).ToList(), + }; - this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, additionalInfo); - return results; - } - catch (Exception exception) - { - this.HandleException(OperationName, exception, request, stopwatch.Elapsed); - throw; + // Generate additional info string based on the collections + additionalInfo = this.BuildAdditionalInfo(results); } - } - /// - public async Task GetUsedOtherMaterialsAsync(GetUsedOtherMaterialsRequest request, CmsAuthValues cmsAuthValues) + this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, additionalInfo); + return results; + } + catch (Exception exception) { - Requires.NotNull(request); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); - - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "GetUsedOtherMaterials"; - - try - { - UsedOtherMaterialsResponse? results = new() { MgForms = [] }; - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); - - var data = await client.GetUsedOtherMaterialsAsync(request.CaseId); - - if (data?.MgForms is not null) - { - results = new UsedOtherMaterialsResponse - { - MgForms = data.MgForms?.Select(mgForm => new MgForm( - mgForm.Id, - mgForm.Title, - mgForm.OriginalFileName, - mgForm.MaterialType, - null, - mgForm.Link, - mgForm.Date.ToString(), - mgForm.Date?.DateTime)).ToList(), - }; - } - - string additionalInfo = results?.MgForms is { Count: > 0 } - ? $"received #{results.MgForms.Count} used other materials" - : "received #0 used other materials"; - this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, additionalInfo); - return results; - } - catch (Exception exception) - { - this.HandleException(OperationName, exception, request, stopwatch.Elapsed); - throw; - } + this.HandleException(OperationName, exception, request, stopwatch.Elapsed); + throw; } + } - /// - public async Task GetUsedStatementsAsync(GetUsedStatementsRequest request, CmsAuthValues cmsAuthValues) - { - Requires.NotNull(request); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); + /// + public async Task GetUsedExhibitsAsync(GetUsedExhibitsRequest request, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(request); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "GetUsedStatements"; + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "GetUsedExhibits"; - try - { - UsedStatementsResponse? results = new(); + try + { + UsedExhibitsResponse results = new () { Exhibits = new List() }; + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); + string additionalInfo = $"received #0 used exhibits"; - string additionalInfo = $"received #0 used statements"; - var data = await client.GetUsedStatementsAsync(request.CaseId); + var data = await client.GetUsedExhibitsAsync(request.CaseId); - if (data?.Statements is not null) + if (data?.Exhibits is not null) + { + results = new UsedExhibitsResponse { - results = new UsedStatementsResponse - { - Statements = data.Statements.Select(statement => new Statement( - statement.Id, - statement.WitnessId, - statement.Title, - statement.OriginalFileName, + Exhibits = data.Exhibits.Select(exhibit => new Exhibit( + exhibit.Id, + exhibit.Title, + exhibit.OriginalFileName, string.Empty, - statement.DocumentType, - statement.Link, - statement.Status.ToString(), - statement.Date?.DateTime, - statement.StatementTakenDate?.DateTime)).ToList(), - }; - } + exhibit.DocumentType, + exhibit.Link, + exhibit.Status.ToString(), + exhibit.ReceivedDate?.DateTime, + exhibit.Reference, + exhibit.Producer)).ToList(), + }; - if (results.Statements.Count != 0) + if (results.Exhibits.Count != 0) { - additionalInfo = $"received #{results.Statements.Count} used statements"; + additionalInfo = $"received #{results.Exhibits.Count} used exhibits"; } - - this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, additionalInfo); - return results; - } - catch (Exception exception) - { - this.HandleException(OperationName, exception, request, stopwatch.Elapsed); - throw; } - } - /// - public async Task> ListCommunicationsHkAsync(ListCommunicationsHkRequest request, CmsAuthValues cmsAuthValues) + this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, additionalInfo); + return results; + } + catch (Exception exception) { - Requires.NotNull(request); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); + this.HandleException(OperationName, exception, request, stopwatch.Elapsed); + throw; + } + } - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "ListCommunicationsHk"; + /// + public async Task GetUsedMgFormsAsync(GetUsedMgFormsRequest request, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(request); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); - try - { - List results = []; - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); - string additionalInfo = $"received #0 communications"; + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "GetUsedMgForms"; - var data = await client.ListCommunicationsHkAsync(request.CaseId); + try + { + UsedMgFormsResponse results = new () { MgForms = new List() }; + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); - if (data is not null) - { - results = data.Select( - communication => new Communication( - Id: communication.Id.GetValueOrDefault(), - OriginalFileName: communication.OriginalFileName, - Subject: communication.Subject, - DocumentTypeId: communication.DocumentTypeId.GetValueOrDefault(), - MaterialId: communication.MaterialId.GetValueOrDefault(), - Link: communication.Link, - Status: communication.Status, - Category: string.Empty, - Type: communication.DocumentTypeId?.ToString(), - HasAttachments: communication.HasAttachments, - Method: communication.Method, - Direction: communication.Direction, - Party: communication.Party, - Date: communication.Date?.DateTime)).ToList(); - } + var data = await client.GetUsedMgFormsAsync(request.CaseId); - if (results.Count != 0) + if (data?.MgForms is not null) + { + results = new UsedMgFormsResponse { - additionalInfo = $"received #{results.Count} communications"; - } + MgForms = data.MgForms?.Select(mgForm => new MgForm( + mgForm.Id, + mgForm.Title, + mgForm.OriginalFileName, + mgForm.MaterialType, + null, + mgForm.Link, + mgForm.Date.ToString(), + mgForm.Date?.DateTime)).ToList(), + }; + } - this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, additionalInfo); + string additionalInfo = results?.MgForms is { Count: > 0 } + ? $"received #{results.MgForms.Count} used MG forms" + : "received #0 used MG forms"; - return results; - } - catch (Exception exception) - { - this.HandleException(OperationName, exception, request, stopwatch.Elapsed); - throw; - } + this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, additionalInfo); + return results; } - - /// - public async Task GetAttachmentsAsync(GetAttachmentsRequest request, CmsAuthValues cmsAuthValues) + catch (Exception exception) { - Requires.NotNull(request); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); + this.HandleException(OperationName, exception, request, stopwatch.Elapsed); + throw; + } + } - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "GetAttachments"; - AttachmentsResponse results = new(); + /// + public async Task GetUsedOtherMaterialsAsync(GetUsedOtherMaterialsRequest request, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(request); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); - try - { - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); - string additionalInfo = $"received #0 attachments"; + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "GetUsedOtherMaterials"; - var data = await client.GetAttachmentsAsync(request.CommunicationId); - if (data?.Attachments is not null) - { - results = new AttachmentsResponse - { - Attachments = data.Attachments.Select(attachment => new Attachment( - attachment.MaterialId, - attachment.Name, - attachment.Description, - attachment.Link, - attachment.Classification, - attachment.DocumentTypeId, - attachment.NumOfDocVersions, - MapStatementSubType(attachment.Statement), - MapExhibitSubItem(attachment.Exhibit), - attachment.Tag, - attachment.DocId, - attachment.OriginalFileName, - attachment.CheckedOutTo, - attachment.DocumentId, - attachment.OcrProcessed, - attachment.Direction)).ToList(), - }; - } + try + { + UsedOtherMaterialsResponse results = new () { MgForms = new List() }; + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); - if (results.Attachments.Count != 0) - { - additionalInfo = $"received #{results.Attachments.Count} attachments"; - } + var data = await client.GetUsedOtherMaterialsAsync(request.CaseId); - this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, additionalInfo); - return results; - } - catch (Exception exception) + if (data?.MgForms is not null) { - this.HandleException(OperationName, exception, request, stopwatch.Elapsed); - throw; + results = new UsedOtherMaterialsResponse + { + MgForms = data.MgForms?.Select(mgForm => new MgForm( + mgForm.Id, + mgForm.Title, + mgForm.OriginalFileName, + mgForm.MaterialType, + null, + mgForm.Link, + mgForm.Date.ToString(), + mgForm.Date?.DateTime)).ToList(), + }; } - } - /// - public async Task GetMaterialDocumentAsync(GetDocumentRequest request, CmsAuthValues cmsAuthValues) + string additionalInfo = results?.MgForms is { Count: > 0 } + ? $"received #{results.MgForms.Count} used other materials" + : "received #0 used other materials"; + this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, additionalInfo); + return results; + } + catch (Exception exception) { - Requires.NotNull(request); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); + this.HandleException(OperationName, exception, request, stopwatch.Elapsed); + throw; + } + } - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "GetMaterialDocument"; - FileStreamResult? results; + /// + public async Task GetUsedStatementsAsync(GetUsedStatementsRequest request, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(request); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); - try - { - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "GetUsedStatements"; - int caseId = int.Parse(request.CaseId); + try + { + UsedStatementsResponse results = new () { Statements = new List() }; - var data = await client.GetMaterialDocumentAsync(caseId, request.FilePath); + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); - string fileDownloadName = Path.GetFileName(request.FilePath); - string? contentType = FileUtils.GetMimeType(fileDownloadName) ?? - throw new InvalidOperationException($"{LoggingConstants.HskUiLogPrefix} Content type cannot be determined for file: {fileDownloadName}"); + string additionalInfo = $"received #0 used statements"; + var data = await client.GetUsedStatementsAsync(request.CaseId); - // Create FileStreamResult using the stream and content type - results = new FileStreamResult(data.Stream, contentType) + if (data?.Statements is not null) + { + results = new UsedStatementsResponse { - FileDownloadName = fileDownloadName, + Statements = data.Statements.Select(statement => new Statement( + statement.Id, + statement.WitnessId, + statement.Title, + statement.OriginalFileName, + string.Empty, + statement.DocumentType, + statement.Link, + statement.Status.ToString(), + statement.Date?.DateTime, + statement.StatementTakenDate?.DateTime)).ToList(), }; - - this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, fileDownloadName); } - catch (Exception exception) + + if (results.Statements.Count != 0) { - this.HandleException(OperationName, exception, request, stopwatch.Elapsed); - throw; + additionalInfo = $"received #{results.Statements.Count} used statements"; } + this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, additionalInfo); return results; } - - /// - public async Task GetExhibitProducersAsync(GetExhibitProducersRequest request, CmsAuthValues cmsAuthValues) + catch (Exception exception) { - Requires.NotNull(request); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); - - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "GetExhibitProducers"; - ExhibitProducersResponse results = new(); - - try - { - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); + this.HandleException(OperationName, exception, request, stopwatch.Elapsed); + throw; + } + } - string additionalInfo = "received #0 producers"; + /// + public async Task> ListCommunicationsHkAsync(ListCommunicationsHkRequest request, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(request); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); - var data = await client.GetExhibitProducersAsync(request.CaseId); + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "ListCommunicationsHk"; - if (data != null) - { - results = new ExhibitProducersResponse - { - ExhibitProducers = data.ExhibitProducers?.Select(x => new ExhibitProducer( - x.Id, - x.Producer, - false)).ToList(), - }; + try + { + List results = new (); + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); + string additionalInfo = $"received #0 communications"; - if (results.ExhibitProducers?.Count > 0) - { - additionalInfo = $"retrieved #{results.ExhibitProducers.Count} producers"; - } - } + var data = await client.ListCommunicationsHkAsync(request.CaseId); - this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, additionalInfo); + if (data is not null) + { + results = data.Select( + communication => new Communication( + Id: communication.Id.GetValueOrDefault(), + OriginalFileName: communication.OriginalFileName, + Subject: communication.Subject, + DocumentTypeId: communication.DocumentTypeId.GetValueOrDefault(), + MaterialId: communication.MaterialId.GetValueOrDefault(), + Link: communication.Link, + Status: communication.Status, + Category: string.Empty, + Type: communication.DocumentTypeId?.ToString(), + HasAttachments: communication.HasAttachments, + Method: communication.Method, + Direction: communication.Direction, + Party: communication.Party, + Date: communication.Date?.DateTime)).ToList(); } - catch (Exception exception) + + if (results.Count != 0) { - this.HandleException(OperationName, exception, request, stopwatch.Elapsed); - throw; + additionalInfo = $"received #{results.Count} communications"; } + this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, additionalInfo); + return results; } - - /// - public async Task GetCaseDefendantsAsync(ListCaseDefendantsRequest request, CmsAuthValues cmsAuthValues) + catch (Exception exception) { - Requires.NotNull(request); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); + this.HandleException(OperationName, exception, request, stopwatch.Elapsed); + throw; + } + } - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "ListCaseDefendants"; - List results = new(); + /// + public async Task GetAttachmentsAsync(GetAttachmentsRequest request, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(request); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); - try - { - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "GetAttachments"; + AttachmentsResponse results = new (); - var data = await client.ListCaseDefendantsAsync(request.CaseId); + try + { + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); + string additionalInfo = $"received #0 attachments"; - var listCaseDefendantsResponse = new DefendantsResponse + var data = await client.GetAttachmentsAsync(request.CommunicationId); + if (data?.Attachments is not null) + { + results = new AttachmentsResponse { - Defendants = data.Select(defendant => new Defendant( - defendant.Id, - defendant.CaseId, - defendant.ListOrder, - defendant.Type, - defendant.FirstNames, - defendant.Surname, - DateTime.TryParse(defendant?.Dob, out var dob) ? dob : (DateTime?)null, - defendant?.PoliceRemandStatus?.ToString(), - defendant?.Youth, - defendant?.CustodyTimeLimit?.ToString(), - MapOffences(defendant?.Offences), - null, - MapProposedCharges(defendant?.ProposedCharges), - defendant?.NextHearing, - defendant?.DefendantPcdReview, - defendant?.Solicitor, - MapPersonalDetail(defendant?.PersonalDetail))).ToList(), + Attachments = data.Attachments.Select(attachment => new Attachment( + attachment.MaterialId, + attachment.Name, + attachment.Description, + attachment.Link, + attachment.Classification, + attachment.DocumentTypeId, + attachment.NumOfDocVersions, + MapStatementSubType(attachment.Statement), + MapExhibitSubItem(attachment.Exhibit), + attachment.Tag, + attachment.DocId, + attachment.OriginalFileName, + attachment.CheckedOutTo, + attachment.DocumentId, + attachment.OcrProcessed, + attachment.Direction)).ToList(), }; - - string additionalInfo = listCaseDefendantsResponse?.Defendants is { Count: > 0 } - ? $"received #{listCaseDefendantsResponse.Defendants.Count} defendants" - : "received #0 defendants"; - this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, additionalInfo); - - return listCaseDefendantsResponse; } - catch (Exception exception) + + if (results.Attachments.Count != 0) { - this.HandleException(OperationName, exception, request, stopwatch.Elapsed); - throw; + additionalInfo = $"received #{results.Attachments.Count} attachments"; } - } - /// - public async Task GetCaseWitnessesAsync(GetCaseWitnessesRequest request, CmsAuthValues cmsAuthValues) + this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, additionalInfo); + return results; + } + catch (Exception exception) { - Requires.NotNull(request); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); + this.HandleException(OperationName, exception, request, stopwatch.Elapsed); + throw; + } + } - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "ListCaseWitnesses"; - string additionalInfo = $"received #0 witnesses"; - WitnessesResponse results = new(); + /// + public async Task GetMaterialDocumentAsync(GetDocumentRequest request, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(request); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); - try - { - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "GetMaterialDocument"; + FileStreamResult? results; - var data = await client.ListCaseWitnessesAsync(request.CaseId); + try + { + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); - if (data is not null) - { - results.Witnesses = data.Select(witness => new Witness( - witness.CaseId, - witness.WitnessId, - witness.FirstName, - witness.Surname)).ToList(); - } + int caseId = int.Parse(request.CaseId); - if (results.Witnesses.Count > 0) - { - additionalInfo = $"retrieved #{results.Witnesses.Count} witnesses"; - } + var data = await client.GetMaterialDocumentAsync(caseId, request.FilePath); - this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, additionalInfo); - } - catch (Exception exception) + string fileDownloadName = Path.GetFileName(request.FilePath); + string? contentType = FileUtils.GetMimeType(fileDownloadName) ?? + throw new InvalidOperationException($"{LoggingConstants.HskUiLogPrefix} Content type cannot be determined for file: {fileDownloadName}"); + + // Create FileStreamResult using the stream and content type + results = new FileStreamResult(data.Stream, contentType) { - this.HandleException(OperationName, exception, request, stopwatch.Elapsed); - throw; - } + FileDownloadName = fileDownloadName, + }; - return results; + this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, fileDownloadName); } - - /// - public async Task GetWitnessStatementsAsync(GetWitnessStatementsRequest request, CmsAuthValues cmsAuthValues) + catch (Exception exception) { - Requires.NotNull(request); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); + this.HandleException(OperationName, exception, request, stopwatch.Elapsed); + throw; + } - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "GetStatementsForWitness"; - string additionalInfo = "received #0 statements"; + return results; + } - WitnessStatementsResponse results = new(); + /// + public async Task GetExhibitProducersAsync(GetExhibitProducersRequest request, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(request); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); - try - { - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "GetExhibitProducers"; + ExhibitProducersResponse results = new (); - var data = await client.GetStatementsForWitnessAsync(request.WitnessId); + try + { + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); + + string additionalInfo = "received #0 producers"; - if (data?.StatementsForWitness is not null) + var data = await client.GetExhibitProducersAsync(request.CaseId); + + if (data != null) + { + results = new ExhibitProducersResponse { - results.WitnessStatements = data.StatementsForWitness.Select(statement => - new WitnessStatement(statement.Id, statement.Title)).ToList(); - } + ExhibitProducers = data.ExhibitProducers?.Select(x => new ExhibitProducer( + x.Id, + x.Producer, + false)).ToList(), + }; - if (results.WitnessStatements?.Count > 0) + if (results.ExhibitProducers?.Count > 0) { - additionalInfo = $"retrieved #{results.WitnessStatements.Count} statements"; + additionalInfo = $"retrieved #{results.ExhibitProducers.Count} producers"; } } - catch (Exception exception) - { - this.HandleException(OperationName, exception, request, stopwatch.Elapsed); - throw; - } - return results; + this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, additionalInfo); } - - /// - public async Task AddCaseActionPlanAsync(int caseId, AddActionPlanRequest request, CmsAuthValues cmsAuthValues) + catch (Exception exception) { - Requires.NotNull(request); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); + this.HandleException(OperationName, exception, request, stopwatch.Elapsed); + throw; + } + + return results; + } - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "AddActionPlan"; + /// + public async Task GetCaseDefendantsAsync(ListCaseDefendantsRequest request, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(request); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); - try - { - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "ListCaseDefendants"; + List results = new (); - var mdsRequest = MapApAction(request); + try + { + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); + + var data = await client.ListCaseDefendantsAsync(request.CaseId); + + var listCaseDefendantsResponse = new DefendantsResponse + { + Defendants = data.Select(defendant => new Defendant( + defendant.Id, + defendant.CaseId, + defendant.ListOrder, + defendant.Type, + defendant.FirstNames, + defendant.Surname, + DateTime.TryParse(defendant?.Dob, out var dob) ? dob : (DateTime?)null, + defendant?.PoliceRemandStatus?.ToString(), + defendant?.Youth, + defendant?.CustodyTimeLimit?.ToString(), + MapOffences(defendant?.Offences), + null, + MapProposedCharges(defendant?.ProposedCharges), + defendant?.NextHearing, + defendant?.DefendantPcdReview, + defendant?.Solicitor, + MapPersonalDetail(defendant?.PersonalDetail))).ToList(), + }; - await client.AddActionPlanAsync(caseId, mdsRequest); + string additionalInfo = listCaseDefendantsResponse?.Defendants is { Count: > 0 } + ? $"received #{listCaseDefendantsResponse.Defendants.Count} defendants" + : "received #0 defendants"; + this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, additionalInfo); - this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, ""); - return new NoContentResult(); - } - catch (Exception exception) - { - this.HandleException(OperationName, exception, request, stopwatch.Elapsed); - throw; - } + return listCaseDefendantsResponse; } - - /// - public async Task AddWitnessAsync(AddWitnessRequest request, CmsAuthValues cmsAuthValues) + catch (Exception exception) { - Requires.NotNull(request); - Requires.NotNull(request.caseId); - Requires.NotNull(request.Surname); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); + this.HandleException(OperationName, exception, request, stopwatch.Elapsed); + throw; + } + } - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "AddWitness"; + /// + public async Task GetCaseWitnessesAsync(GetCaseWitnessesRequest request, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(request); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); - try - { - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "ListCaseWitnesses"; + string additionalInfo = $"received #0 witnesses"; + WitnessesResponse results = new (); - var mdsRequest = new ApiClient.Witness() - { - CaseId = request.caseId, - Surname = request.Surname, - FirstName = request.FirstName, - }; + try + { + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); - await client.AddWitnessAsync(request.caseId, mdsRequest); - this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, string.Empty); - return new NoContentResult(); + var data = await client.ListCaseWitnessesAsync(request.CaseId); + + if (data is not null) + { + results.Witnesses = data.Select(witness => new Witness( + witness.CaseId, + witness.WitnessId, + witness.FirstName, + witness.Surname)).ToList(); } - catch (Exception exception) + + if (results.Witnesses.Count > 0) { - this.HandleException(OperationName, exception, request, stopwatch.Elapsed); - throw; + additionalInfo = $"retrieved #{results.Witnesses.Count} witnesses"; } - } - /// - public async Task RenameMaterialAsync(RenameMaterialRequest request, CmsAuthValues cmsAuthValues) + this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, additionalInfo); + } + catch (Exception exception) { - Requires.NotNull(request); - Requires.NotNull(request.materialId); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); - - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "RenameMaterial"; + this.HandleException(OperationName, exception, request, stopwatch.Elapsed); + throw; + } - try - { - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); + return results; + } - var mdsRequest = new ApiClient.RenameMaterialRequest() - { - MaterialId = request.materialId, - Subject = request.subject, - }; + /// + public async Task GetWitnessStatementsAsync(GetWitnessStatementsRequest request, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(request); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); - var data = await client.RenameMaterialAsync(request.materialId, mdsRequest); + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "GetStatementsForWitness"; + string additionalInfo = "received #0 statements"; - if (data?.UpdateCommunication?.Id == null) - { - return default; - } + WitnessStatementsResponse results = new (); - RenameMaterialResponse result = new(new RenameMaterialData { Id = data.UpdateCommunication.Id }); + try + { + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); - this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, string.Empty); + var data = await client.GetStatementsForWitnessAsync(request.WitnessId); - return result; + if (data?.StatementsForWitness is not null) + { + results.WitnessStatements = data.StatementsForWitness.Select(statement => + new WitnessStatement(statement.Id, statement.Title)).ToList(); } - catch (Exception exception) + + if (results.WitnessStatements?.Count > 0) { - this.HandleException(OperationName, exception, request, stopwatch.Elapsed); - throw; + additionalInfo = $"retrieved #{results.WitnessStatements.Count} statements"; } } - - /// - public async Task ReclassifyCommunicationAsync(ReclassifyCommunicationRequest request, CmsAuthValues cmsAuthValues) + catch (Exception exception) { - Requires.NotNull(request); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); + this.HandleException(OperationName, exception, request, stopwatch.Elapsed); + throw; + } - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "ReclassifyCommunication"; + return results; + } - try - { - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); + /// + public async Task AddCaseActionPlanAsync(int caseId, AddActionPlanRequest request, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(request); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); - var mdsRequest = new ApiClient.HkReclassifyCommunicationRequest() - { - Classification = request.classification, - MaterialId = request.materialId, - DocumentTypeId = request.documentTypeId, - Used = request.used, - Subject = request.subject, - Statement = MapStatement(request.Statement), - Exhibit = MapExhibit(request.Exhibit), - }; + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "AddActionPlan"; - var data = await client.ReclassifyCommunicationAsync(mdsRequest); + try + { + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); - if (data?.ReclassifyCommunication?.Id == null) - { - return default; - } + var mdsRequest = MapApAction(request); - ReclassificationResponse result = new ReclassificationResponse(new ReclassifyCommunication { Id = data.ReclassifyCommunication.Id }); - this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, string.Empty); + await client.AddActionPlanAsync(caseId, mdsRequest); - return result; - } - catch (Exception exception) - { - this.HandleException(OperationName, exception, request, stopwatch.Elapsed); - throw; - } + this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, string.Empty); + return new NoContentResult(); } - - /// - public async Task CheckCaseLockAsync(int caseId, CmsAuthValues cmsAuthValues) + catch (Exception exception) { - if (caseId <= 0) - { - throw new ArgumentOutOfRangeException(nameof(caseId), "Case ID must be a positive integer."); - } + this.HandleException(OperationName, exception, request, stopwatch.Elapsed); + throw; + } + } - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); + /// + public async Task AddWitnessAsync(AddWitnessRequest request, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(request); + Requires.NotNull(request.caseId); + Requires.NotNull(request.Surname); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "CaseLockStatus"; + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "AddWitness"; - var dummyRequest = new BaseRequest(Guid.NewGuid()); + try + { + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); - try + var mdsRequest = new ApiClient.Witness() { - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); - - var data = await client.GetCaseLockStatusAsync(caseId); + CaseId = request.caseId, + Surname = request.Surname, + FirstName = request.FirstName, + }; - var result = new CaseLockedStatusResult - { - IsLocked = data.IsLocked, - LockedByUser = data.LockedByUser, - CaseLockedMessage = data.CaseLockedMessage, - IsLockedByCurrentUser = data.IsLockedByCurrentUser, - }; - this.LogOperationCompletedEvent(OperationName, dummyRequest, stopwatch.Elapsed, string.Empty); - return result; - } - catch (Exception exception) - { - this.HandleException(OperationName, exception, dummyRequest, stopwatch.Elapsed); - throw; - } + await client.AddWitnessAsync(request.caseId, mdsRequest); + this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, string.Empty); + return new NoContentResult(); } - - /// - public async Task DiscardMaterialAsync(DiscardMaterialRequest request, CmsAuthValues cmsAuthValues) + catch (Exception exception) { - Requires.NotNull(request); - Requires.NotNull(request.materialId); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); + this.HandleException(OperationName, exception, request, stopwatch.Elapsed); + throw; + } + } - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "DiscardMaterial"; + /// + public async Task RenameMaterialAsync(RenameMaterialRequest request, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(request); + Requires.NotNull(request.materialId); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); - try - { - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "RenameMaterial"; - var mdsReqest = new ApiClient.DiscardMaterialRequest() - { - MaterialId = request.materialId, - DiscardReason = request.discardReason, - DiscardReasonDescription = request.discardReasonDescription, - }; + try + { + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); - var data = await client.DiscardMaterialAsync(request.materialId, mdsReqest); - this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, string.Empty); + var mdsRequest = new ApiClient.RenameMaterialRequest() + { + MaterialId = request.materialId, + Subject = request.subject, + }; - if (data?.DiscardMaterial?.Id == null) - { - return default; - } + var data = await client.RenameMaterialAsync(request.materialId, mdsRequest); - DiscardMaterialResponse result = new DiscardMaterialResponse(new DiscardMaterialData { Id = data.DiscardMaterial.Id }); - return result; - } - catch (Exception exception) + if (data?.UpdateCommunication?.Id == null) { - this.HandleException(OperationName, exception, request, stopwatch.Elapsed); - throw; + return default; } - } - /// - public async Task SetMaterialReadStatusAsync(SetMaterialReadStatusRequest request, CmsAuthValues cmsAuthValues) - { - Requires.NotNull(request); - Requires.NotNull(request.materialId); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); + RenameMaterialResponse result = new (new RenameMaterialData { Id = data.UpdateCommunication.Id }); - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "SetMaterialReadStatus"; - try - { - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); + this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, string.Empty); - var mdsReqest = new ApiClient.MaterialReadStateRequest() - { - MaterialId = request.materialId, - State = (ApiClient.MaterialReadStateRequestState)request.state, - }; + return result; + } + catch (Exception exception) + { + this.HandleException(OperationName, exception, request, stopwatch.Elapsed); + throw; + } + } - var data = await client.SetMaterialReadStateAsync(request.materialId, mdsReqest); + /// + public async Task ReclassifyCommunicationAsync(ReclassifyCommunicationRequest request, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(request); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); - if (data?.CompleteCommunication?.Id == null) - { - return default; - } + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "ReclassifyCommunication"; - SetMaterialReadStatusResponse result = new SetMaterialReadStatusResponse(new SetMaterialReadStatusResponseData { Id = data.CompleteCommunication.Id }); + try + { + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); - this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, string.Empty); + var mdsRequest = new ApiClient.HkReclassifyCommunicationRequest() + { + Classification = request.classification, + MaterialId = request.materialId, + DocumentTypeId = request.documentTypeId, + Used = request.used, + Subject = request.subject, + Statement = MapStatement(request.Statement), + Exhibit = MapExhibit(request.Exhibit), + }; - return result; - } - catch (Exception exception) + var data = await client.ReclassifyCommunicationAsync(mdsRequest); + + if (data?.ReclassifyCommunication?.Id == null) { - this.HandleException(OperationName, exception, request, stopwatch.Elapsed); - throw; + return default; } - } - /// - public async Task> GetPcdRequestCoreAsync(GetPcdRequestsCoreRequest request, CmsAuthValues cmsAuthValues) + ReclassificationResponse result = new ReclassificationResponse(new ReclassifyCommunication { Id = data.ReclassifyCommunication.Id }); + this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, string.Empty); + + return result; + } + catch (Exception exception) { - Requires.NotNull(request); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); + this.HandleException(OperationName, exception, request, stopwatch.Elapsed); + throw; + } + } - if (string.IsNullOrEmpty(cmsAuthValues.CmsCookies)) - { - throw new ArgumentException($"{LoggingConstants.HskUiLogPrefix} CMS Cookies cannot be null or empty.", nameof(request)); - } + /// + public async Task CheckCaseLockAsync(int caseId, CmsAuthValues cmsAuthValues) + { + if (caseId <= 0) + { + throw new ArgumentOutOfRangeException(nameof(caseId), "Case ID must be a positive integer."); + } - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "PcdRequestCore"; + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); - List results = new(); - try - { - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "CaseLockStatus"; - var data = await client.GetCasePcdRequestCoreAsync(request.caseId); + var dummyRequest = new BaseRequest(Guid.NewGuid()); - if (data is not null) - { - results = data.Select(pcd => new PcdRequestCore() - { - Id = pcd.Id, - Type = pcd.Type, - DecisionRequiredBy = pcd.DecisionRequiredBy, - DecisionRequested = pcd.DecisionRequested, - }).ToList(); - } + try + { + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); - this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, string.Empty); + var data = await client.GetCaseLockStatusAsync(caseId); - return results; - } - catch (Exception exception) + var result = new CaseLockedStatusResult { - this.HandleException(OperationName, exception, request, stopwatch.Elapsed); - throw; - } + IsLocked = data.IsLocked, + LockedByUser = data.LockedByUser, + CaseLockedMessage = data.CaseLockedMessage, + IsLockedByCurrentUser = data.IsLockedByCurrentUser, + }; + this.LogOperationCompletedEvent(OperationName, dummyRequest, stopwatch.Elapsed, string.Empty); + return result; } - - /// - public async Task GetPcdRequestByPcdIdAsync(GetPcdRequestByPcdIdCoreRequest request, CmsAuthValues cmsAuthValues) + catch (Exception exception) { - Requires.NotNull(request); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); + this.HandleException(OperationName, exception, dummyRequest, stopwatch.Elapsed); + throw; + } + } - if (string.IsNullOrEmpty(cmsAuthValues.CmsCookies)) - { - throw new ArgumentException($"{LoggingConstants.HskUiLogPrefix} CMS Cookies cannot be null or empty.", nameof(request)); - } + /// + public async Task DiscardMaterialAsync(DiscardMaterialRequest request, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(request); + Requires.NotNull(request.materialId); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "GetCasePcdRequestByPcdId"; + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "DiscardMaterial"; - var results = new PcdRequestDto(); + try + { + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); - try + var mdsReqest = new ApiClient.DiscardMaterialRequest() { - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); - - var data = await client.GetCasePcdRequestByPcdIdAsync(request.caseId, request.pcdId); + MaterialId = request.materialId, + DiscardReason = request.discardReason, + DiscardReasonDescription = request.discardReasonDescription, + }; - if (data is not null) - { - results = - new PcdRequestDto() - { - CaseOutline = data.CaseOutline.Select(co => new PcdCaseOutlineLine() - { - Heading = co.Heading, - Text = co.Text, - TextWithCmsMarkup = co.TextWithCmsMarkup, - }).ToList(), - Comments = new PcdComments() - { - Text = data.Comments?.Text, - TextWithCmsMarkup = data.Comments?.TextWithCmsMarkup, - }, - Suspects = data.Suspects.Select(sus => new PcdRequestSuspect() - { - Surname = sus.Surname, - FirstNames = sus.FirstNames, - Dob = sus.Dob, - BailConditions = sus.BailConditions, - BailDate = sus.BailDate, - RemandStatus = sus.RemandStatus, - ProposedCharges = sus.ProposedCharges.Select(charge => new PcdProposedCharge() { Charge = charge.Charge, EarlyDate = charge.EarlyDate, LateDate = charge.LateDate, Location = charge.Location, Category = charge.Category }).ToList(), - }).ToList(), - PoliceContactDetails = data.PoliceContactDetails.Select(police => new PCDPoliceContactDetails() - { - Role = police.Role, - Rank = police.Rank, - Name = police.Name, - Number = police.Number, - }).ToList(), - MaterialProvided = data.MaterialProvided.Select(mat => new MaterialProvided() - { - Subject = mat.Subject, - Date = mat.Date, - }).ToList(), - Id = data.Id, - Type = data.Type, - DecisionRequested = data.DecisionRequested, - DecisionRequiredBy = data.DecisionRequiredBy, - }; - } + var data = await client.DiscardMaterialAsync(request.materialId, mdsReqest); + this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, string.Empty); - this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, string.Empty); - return results; - } - catch (Exception exception) + if (data?.DiscardMaterial?.Id == null) { - this.HandleException(OperationName, exception, request, stopwatch.Elapsed); - throw; + return default; } - } - /// - public async Task UpdateStatementAsync(UpdateStatementRequest request, CmsAuthValues cmsAuthValues) + DiscardMaterialResponse result = new DiscardMaterialResponse(new DiscardMaterialData { Id = data.DiscardMaterial.Id }); + return result; + } + catch (Exception exception) { - Requires.NotNull(request); - Requires.NotNull(request.MaterialId); - Requires.NotNull(request.WitnessId); - Requires.NotNull(request.StatementNumber); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); + this.HandleException(OperationName, exception, request, stopwatch.Elapsed); + throw; + } + } - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "UpdateStatement"; + /// + public async Task SetMaterialReadStatusAsync(SetMaterialReadStatusRequest request, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(request); + Requires.NotNull(request.materialId); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); + + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "SetMaterialReadStatus"; + try + { + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); - try + var mdsReqest = new ApiClient.MaterialReadStateRequest() { - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); + MaterialId = request.materialId, + State = (ApiClient.MaterialReadStateRequestState)request.state, + }; - var statementDate = ConvertToDateTimeOffset(request.StatementDate); + var data = await client.SetMaterialReadStateAsync(request.materialId, mdsReqest); - var mdsRequest = new ApiClient.UpdateStatementRequest - { - MaterialId = request.MaterialId, - WitnessId = request.WitnessId, - StatementNumber = request.StatementNumber, - StatementDate = statementDate, - Used = request.Used, - }; + if (data?.CompleteCommunication?.Id == null) + { + return default; + } - var data = await client.UpdateStatementAsync(request.CaseId, request.MaterialId, mdsRequest); + SetMaterialReadStatusResponse result = new SetMaterialReadStatusResponse(new SetMaterialReadStatusResponseData { Id = data.CompleteCommunication.Id }); - if (data?.UpdateStatement?.Id == null) - { - return default; - } + this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, string.Empty); - UpdateStatementResponse result = new UpdateStatementResponse(new UpdateStatementData { Id = data.UpdateStatement.Id }); - this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, string.Empty); - return result; - } - catch (Exception exception) - { - this.HandleException(OperationName, exception, request, stopwatch.Elapsed); - throw; - } + return result; + } + catch (Exception exception) + { + this.HandleException(OperationName, exception, request, stopwatch.Elapsed); + throw; } + } + + /// + public async Task> GetPcdRequestCoreAsync(GetPcdRequestsCoreRequest request, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(request); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); - /// - public async Task UpdateExhibitAsync(UpdateExhibitRequest request, CmsAuthValues cmsAuthValues) + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "PcdRequestCore"; + + List results = new (); + try { - Requires.NotNull(request); - Requires.NotNull(request.CaseId); - Requires.NotNull(request.MaterialId); - Requires.NotNull(request.DocumentType); - Requires.NotNull(request.Item); - Requires.NotNull(request.Reference); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "UpdateExhibit"; + var data = await client.GetCasePcdRequestCoreAsync(request.caseId); - try + if (data is not null) { - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); - - var mdsRequest = new ApiClient.UpdateExhibitRequest + results = data.Select(pcd => new PcdRequestCore() { - CaseId = request.CaseId, - MaterialId = request.MaterialId, - DocumentType = request.DocumentType, - Item = request.Item, - Reference = request.Reference, - Subject = request.Subject, - ExistingProducerOrWitnessId = request.ExistingProducerOrWitnessId, - NewProducer = request.NewProducer, - Used = request.Used, - }; + Id = pcd.Id, + Type = pcd.Type, + DecisionRequiredBy = pcd.DecisionRequiredBy, + DecisionRequested = pcd.DecisionRequested, + }).ToList(); + } - var data = await client.UpdateExhibitAsync(request.CaseId, request.MaterialId, mdsRequest); + this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, string.Empty); - if (data?.UpdateExhibit?.Id == null) - { - return default; - } + return results; + } + catch (Exception exception) + { + this.HandleException(OperationName, exception, request, stopwatch.Elapsed); + throw; + } + } - UpdateExhibitResponse result = new UpdateExhibitResponse(new UpdateExhibitData { Id = data.UpdateExhibit.Id }); + /// + public async Task GetPcdRequestByPcdIdAsync(GetPcdRequestByPcdIdCoreRequest request, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(request); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); - this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, string.Empty); - return result; + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "GetCasePcdRequestByPcdId"; - } - catch (Exception exception) - { - this.HandleException(OperationName, exception, request, stopwatch.Elapsed); - throw; - } - } + var results = new PcdRequestDto(); - /// - public async Task FirstInitialReviewGetCaseHistoryAsync(int caseId, CmsAuthValues cmsAuthValues) + try { - Requires.NotNull(caseId); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "FirstInitialReviewGetCaseHistory"; + var data = await client.GetCasePcdRequestByPcdIdAsync(request.caseId, request.pcdId); - try + if (data is not null) { - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); - - var data = await client.FirstInitialReviewGetCaseHistoryAsync(caseId); - return data; - } - catch (Exception exception) - { - this.HandleException(OperationName, exception, null, stopwatch.Elapsed); - throw; + results = + new PcdRequestDto() + { + CaseOutline = data.CaseOutline.Select(co => new PcdCaseOutlineLine() + { + Heading = co.Heading, + Text = co.Text, + TextWithCmsMarkup = co.TextWithCmsMarkup, + }).ToList(), + Comments = new PcdComments() + { + Text = data.Comments?.Text, + TextWithCmsMarkup = data.Comments?.TextWithCmsMarkup, + }, + Suspects = data.Suspects.Select(sus => new PcdRequestSuspect() + { + Surname = sus.Surname, + FirstNames = sus.FirstNames, + Dob = sus.Dob, + BailConditions = sus.BailConditions, + BailDate = sus.BailDate, + RemandStatus = sus.RemandStatus, + ProposedCharges = sus.ProposedCharges.Select(charge => new PcdProposedCharge() { Charge = charge.Charge, EarlyDate = charge.EarlyDate, LateDate = charge.LateDate, Location = charge.Location, Category = charge.Category }).ToList(), + }).ToList(), + PoliceContactDetails = data.PoliceContactDetails.Select(police => new PCDPoliceContactDetails() + { + Role = police.Role, + Rank = police.Rank, + Name = police.Name, + Number = police.Number, + }).ToList(), + MaterialProvided = data.MaterialProvided.Select(mat => new MaterialProvided() + { + Subject = mat.Subject, + Date = mat.Date, + }).ToList(), + Id = data.Id, + Type = data.Type, + DecisionRequested = data.DecisionRequested, + DecisionRequiredBy = data.DecisionRequiredBy, + }; } + + this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, string.Empty); + return results; + } + catch (Exception exception) + { + this.HandleException(OperationName, exception, request, stopwatch.Elapsed); + throw; } + } - /// - public async Task GetInitialReviewByHistoryIdAsync(int caseId, int historyId, CmsAuthValues cmsAuthValues, CancellationToken cancellationToken) + /// + public async Task UpdateStatementAsync(UpdateStatementRequest request, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(request); + Requires.NotNull(request.MaterialId); + Requires.NotNull(request.WitnessId); + Requires.NotNull(request.StatementNumber); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); + + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "UpdateStatement"; + + try { - Requires.NotNull(caseId); - Requires.NotNull(historyId); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "GetInitialReviewByHistoryId"; + var statementDate = ConvertToDateTimeOffset(request.StatementDate); - try + var mdsRequest = new ApiClient.UpdateStatementRequest { - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); + MaterialId = request.MaterialId, + WitnessId = request.WitnessId, + StatementNumber = request.StatementNumber, + StatementDate = statementDate, + Used = request.Used, + }; - var data = await client.GetInitialReviewByIdAsync(caseId, historyId, cancellationToken); - return data; - } - catch (Exception exception) + var data = await client.UpdateStatementAsync(request.CaseId, request.MaterialId, mdsRequest); + + if (data?.UpdateStatement?.Id == null) { - this.HandleException(OperationName, exception, null, stopwatch.Elapsed); - throw; + return default; } - } - /// - public async Task GetPcdAnalysisByIdAsync( - int caseId, - int historyId, - CmsAuthValues cmsAuthValues, - CancellationToken cancellationToken) + UpdateStatementResponse result = new UpdateStatementResponse(new UpdateStatementData { Id = data.UpdateStatement.Id }); + this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, string.Empty); + return result; + } + catch (Exception exception) { - Requires.NotNull(caseId); - Requires.NotNull(historyId); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); + this.HandleException(OperationName, exception, request, stopwatch.Elapsed); + throw; + } + } - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "GetInitialReviewByHistoryId"; + /// + public async Task UpdateExhibitAsync(UpdateExhibitRequest request, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(request); + Requires.NotNull(request.CaseId); + Requires.NotNull(request.MaterialId); + Requires.NotNull(request.DocumentType); + Requires.NotNull(request.Item); + Requires.NotNull(request.Reference); + Requires.NotNull(cmsAuthValues); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); + + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "UpdateExhibit"; + + try + { + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); + + var mdsRequest = new ApiClient.UpdateExhibitRequest + { + CaseId = request.CaseId, + MaterialId = request.MaterialId, + DocumentType = request.DocumentType, + Item = request.Item, + Reference = request.Reference, + Subject = request.Subject, + ExistingProducerOrWitnessId = request.ExistingProducerOrWitnessId, + NewProducer = request.NewProducer, + Used = request.Used, + }; - try - { - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); + var data = await client.UpdateExhibitAsync(request.CaseId, request.MaterialId, mdsRequest); - var data = await client.GetPcdAnalysisByIdAsync(caseId, historyId); - return data; - } - catch (Exception exception) + if (data?.UpdateExhibit?.Id == null) { - this.HandleException(OperationName, exception, null, stopwatch.Elapsed); - throw; + return default; } - } - /// - public async Task> GetHistoryEventsAsync(int caseId, CmsAuthValues cmsAuthValues) + UpdateExhibitResponse result = new UpdateExhibitResponse(new UpdateExhibitData { Id = data.UpdateExhibit.Id }); + + this.LogOperationCompletedEvent(OperationName, request, stopwatch.Elapsed, string.Empty); + return result; + } + catch (Exception exception) { - Requires.NotNull(caseId); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); + this.HandleException(OperationName, exception, request, stopwatch.Elapsed); + throw; + } + } - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "GetHistoryEvents"; + /// + public async Task FirstInitialReviewGetCaseHistoryAsync(int caseId, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(caseId); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); - try - { - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "FirstInitialReviewGetCaseHistory"; - var data = await client.GetCaseHistoryEventsAsync(caseId); - return data; - } - catch (Exception exception) - { - this.HandleException(OperationName, exception, null, stopwatch.Elapsed); - throw; - } - } + try + { + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); - /// - public async Task GetOffenceChargeByHistoryIdAsync(int caseId, int historyId, CmsAuthValues cmsAuthValues) + var data = await client.FirstInitialReviewGetCaseHistoryAsync(caseId); + return data; + } + catch (Exception exception) { - Requires.NotNull(caseId); - Requires.NotNull(historyId); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); + this.HandleException(OperationName, exception, null, stopwatch.Elapsed); + throw; + } + } - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "GetOffenceCharge"; + /// + public async Task GetInitialReviewByHistoryIdAsync(int caseId, int historyId, CmsAuthValues cmsAuthValues, CancellationToken cancellationToken) + { + Requires.NotNull(caseId); + Requires.NotNull(historyId); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); - try - { - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "GetInitialReviewByHistoryId"; - var data = await client.GetOffenceChangeByIdAsync(caseId, historyId); - return data; - } - catch (Exception exception) - { - this.HandleException(OperationName, exception, null, stopwatch.Elapsed); - throw; - } - } + try + { + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); - /// - public async Task GetPreChargeDecisionCaseHistoryEventDetailsAsync(int caseId, CmsAuthValues cmsAuthValues) + var data = await client.GetInitialReviewByIdAsync(caseId, historyId, cancellationToken); + return data; + } + catch (Exception exception) { - Requires.NotNull(caseId); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); + this.HandleException(OperationName, exception, null, stopwatch.Elapsed); + throw; + } + } - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "GetOffenceCharge"; + /// + public async Task GetPcdAnalysisByIdAsync( + int caseId, + int historyId, + CmsAuthValues cmsAuthValues, + CancellationToken cancellationToken) + { + Requires.NotNull(caseId); + Requires.NotNull(historyId); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); - try - { - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "GetInitialReviewByHistoryId"; - var data = await client.GetPreChargeDecisionOutcomesAsync(caseId); - return data; - } - catch (Exception exception) - { - this.HandleException(OperationName, exception, null, stopwatch.Elapsed); - throw; - } - } + try + { + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); - /// - public async Task GetPreChargeDecisionByHistoryId(int caseId, int historyId, CmsAuthValues cmsAuthValues) + var data = await client.GetPcdAnalysisByIdAsync(caseId, historyId); + return data; + } + catch (Exception exception) { - Requires.NotNull(caseId); - Requires.NotNull(historyId); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); + this.HandleException(OperationName, exception, null, stopwatch.Elapsed); + throw; + } + } - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "GetPreChargeDecisionByHistoryId"; + /// + public async Task> GetHistoryEventsAsync(int caseId, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(caseId); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); - try - { - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "GetHistoryEvents"; - var data = await client.GetPreChargeDecisionByIdAsync(caseId, historyId); - return data; - } - catch (Exception exception) - { - this.HandleException(OperationName, exception, null, stopwatch.Elapsed); - throw; - } - } + try + { + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); - /// - public async Task GetPcdReview(int caseId, CmsAuthValues cmsAuthValues) + var data = await client.GetCaseHistoryEventsAsync(caseId); + return data; + } + catch (Exception exception) { - Requires.NotNull(caseId); - Requires.NotNull(cmsAuthValues); - Requires.NotNull(cmsAuthValues.CmsCookies, nameof(cmsAuthValues.CmsCookies)); - Requires.NotNull(cmsAuthValues.CmsModernToken, nameof(cmsAuthValues.CmsModernToken)); + this.HandleException(OperationName, exception, null, stopwatch.Elapsed); + throw; + } + } - var stopwatch = Stopwatch.StartNew(); - const string OperationName = "GetPcdReview"; + /// + public async Task GetOffenceChargeByHistoryIdAsync(int caseId, int historyId, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(caseId); + Requires.NotNull(historyId); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); - try - { - var cookie = new MasterDataServiceCookie(cmsAuthValues.CmsCookies, cmsAuthValues.CmsModernToken); - var cookieString = JsonSerializer.Serialize(cookie); - var client = this.mdsApiClientFactory.Create(cookieString); + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "GetOffenceCharge"; - var data = await client.GetPcdReviewAsync(caseId); - return data; - } - catch (Exception exception) - { - this.HandleException(OperationName, exception, null, stopwatch.Elapsed); - throw; - } + try + { + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); + + var data = await client.GetOffenceChangeByIdAsync(caseId, historyId); + return data; } + catch (Exception exception) + { + this.HandleException(OperationName, exception, null, stopwatch.Elapsed); + throw; + } + } + + /// + public async Task GetPreChargeDecisionCaseHistoryEventDetailsAsync(int caseId, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(caseId); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); + + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "GetOffenceCharge"; - private static ExhibitAttachmentSubType MapExhibitSubItem(ApiClient.ExhibitAttachmentHkSubType exhibit) + try { - if (exhibit is null) - { - return null; - } + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); - return new ExhibitAttachmentSubType(exhibit.Reference, exhibit.Item, exhibit.Producer); + var data = await client.GetPreChargeDecisionOutcomesAsync(caseId); + return data; } + catch (Exception exception) + { + this.HandleException(OperationName, exception, null, stopwatch.Elapsed); + throw; + } + } - private static StatementAttachmentSubType MapStatementSubType(ApiClient.StatementAttachmentHkSubType statement) + /// + public async Task GetPreChargeDecisionByHistoryId(int caseId, int historyId, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(caseId); + Requires.NotNull(historyId); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); + + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "GetPreChargeDecisionByHistoryId"; + + try { - if (statement == null) - { - return null; - } + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); - return new StatementAttachmentSubType( - statement.WitnessName, - statement?.WitnessTitle, - statement?.WitnessShoulderNo, - statement.StatementNo, - statement.Date, - statement?.Witness); + var data = await client.GetPreChargeDecisionByIdAsync(caseId, historyId); + return data; } - - private static List MapOffences(ICollection offence) + catch (Exception exception) { - if (offence is null) - { - return null; - } + this.HandleException(OperationName, exception, null, stopwatch.Elapsed); + throw; + } + } - return new List( - offence.Select(offence => - new Offence( - offence.Id, - offence.ListOrder, - offence.Code, - offence.Type, - offence.Active, - offence.Description, - offence.FromDate, - offence.ToDate, - offence.LatestPlea, - offence.LatestVerdict, - offence.DisposedReason, - offence.LastHearingOutcome, - offence?.CustodyTimeLimit?.ToString(), - offence.LatestPleaDescription))); - } - - private static List MapProposedCharges(ICollection proposedCharges) - { - if (proposedCharges is null) - { - return null; - } + /// + public async Task GetPcdReview(int caseId, CmsAuthValues cmsAuthValues) + { + Requires.NotNull(caseId); + Requires.NotNull(cmsAuthValues.CmsAuthFullValue); - return new List( - proposedCharges.Select(charge => - new ProposedCharge( - charge.Id, - charge.CaseId, - charge.DefendantId, - charge.Surname, - charge.FirstNames, - charge.Code, - charge.Description, - MapLocation(charge.Location), - charge.FromDate, - charge.ToDate, - charge.ChargeParticulars, - charge.AnticipatedPlea.ToString(), - charge.AdjudicationCode.ToString()))); - } - - private static PersonalDetail MapPersonalDetail(ApiClient.DefendantPersonalDetail defendantPersonalDetail) - { - if (defendantPersonalDetail is null) - { - return null; - } + var stopwatch = Stopwatch.StartNew(); + const string OperationName = "GetPcdReview"; - return new PersonalDetail( - MappAddress(defendantPersonalDetail.Address), - defendantPersonalDetail.Email, - defendantPersonalDetail.Ethnicity.ToString(), - defendantPersonalDetail.Gender.ToString(), - defendantPersonalDetail.Occupation, - defendantPersonalDetail.HomePhoneNumber, - defendantPersonalDetail.MobilePhoneNumber, - defendantPersonalDetail.WorkPhoneNumber, - defendantPersonalDetail.PreferredCorrespondenceLanguage.ToString(), - defendantPersonalDetail.Religion.ToString(), - defendantPersonalDetail.Guardian); - } + try + { + var client = this.mdsApiClientFactory.Create(cmsAuthValues.CmsAuthFullValue); - private static Address MappAddress(ApiClient.PostalAddress address) + var data = await client.GetPcdReviewAsync(caseId); + return data; + } + catch (Exception exception) { - if (address is null) - { - return default; - } + this.HandleException(OperationName, exception, null, stopwatch.Elapsed); + throw; + } + } - return new Address( - address.Postcode, - address.AddressLine1, - address.AddressLine2, - address.AddressLine3, - address.AddressLine4, - address.AddressLine5, - address.AddressLine6, - address.AddressLine7, - address.AddressLine8); + private static ExhibitAttachmentSubType MapExhibitSubItem(ApiClient.ExhibitAttachmentHkSubType exhibit) + { + if (exhibit is null) + { + return null; } - private static Location MapLocation(ApiClient.InternationalAddress address) + return new ExhibitAttachmentSubType(exhibit.Reference, exhibit.Item, exhibit.Producer); + } + + private static StatementAttachmentSubType MapStatementSubType(ApiClient.StatementAttachmentHkSubType statement) + { + if (statement == null) { - if (address is null) - { - return default; - } + return null; + } - return new Location( - address.Country, - address.Postcode, - address.AddressLine1, - address.AddressLine2, - address.AddressLine3, - address.AddressLine4, - address.AddressLine5, - address.AddressLine6, - address.AddressLine7, - address.AddressLine8); + return new StatementAttachmentSubType( + statement.WitnessName, + statement?.WitnessTitle, + statement?.WitnessShoulderNo, + statement.StatementNo, + statement.Date, + statement?.Witness); + } + + private static List MapOffences(ICollection offence) + { + if (offence is null) + { + return null; } - private static ApiClient.ApAction MapApAction(AddActionPlanRequest addActionPlanRequest) + return new List( + offence.Select(offence => + new Offence( + offence.Id, + offence.ListOrder, + offence.Code, + offence.Type, + offence.Active, + offence.Description, + offence.FromDate, + offence.ToDate, + offence.LatestPlea, + offence.LatestVerdict, + offence.DisposedReason, + offence.LastHearingOutcome, + offence?.CustodyTimeLimit?.ToString(), + offence.LatestPleaDescription))); + } + + private static List MapProposedCharges(ICollection proposedCharges) + { + if (proposedCharges is null) { - return new ApiClient.ApAction() - { - FullDefendantName = addActionPlanRequest.fullDefendantName, - AllDefendants = addActionPlanRequest.allDefendants, - Date = ConvertToDateTimeOffset(addActionPlanRequest.date), - DateExpected = ConvertToDateTimeOffset(addActionPlanRequest.dateExpected.Value), - DateTimeCreated = addActionPlanRequest.dateTimeCreated, - ActionPointText = addActionPlanRequest.actionPointText, - Status = addActionPlanRequest.status, - StatusDescription = addActionPlanRequest.statusDescription, - ExpectedDateUpdated = addActionPlanRequest.expectedDateUpdated, - PartyType = addActionPlanRequest.partyType, - PoliceChangeReason = addActionPlanRequest.policeChangeReason, - StatusUpdated = addActionPlanRequest.statusUpdated, - SyncedWithPolice = addActionPlanRequest.syncedWithPolice, - CpsChangeReason = addActionPlanRequest.cpsChangeReason, - ChaserTaskDate = ConvertToDateTimeOffset(addActionPlanRequest.chaserTaskDate), - Steps = MapActionStep(addActionPlanRequest.steps), - }; + return null; } - private static ICollection MapActionStep(Step[] steps) + return new List( + proposedCharges.Select(charge => + new ProposedCharge( + charge.Id, + charge.CaseId, + charge.DefendantId, + charge.Surname, + charge.FirstNames, + charge.Code, + charge.Description, + MapLocation(charge.Location), + charge.FromDate, + charge.ToDate, + charge.ChargeParticulars, + charge.AnticipatedPlea.ToString(), + charge.AdjudicationCode.ToString()))); + } + + private static PersonalDetail MapPersonalDetail(ApiClient.DefendantPersonalDetail defendantPersonalDetail) + { + if (defendantPersonalDetail is null) { - return steps.Select(step => new ApiClient.ActionPlanStep - { - Code = step.code, - Description = step.description, - Text = step.text, - Hidden = step.hidden, - HiddenDraft = step.hiddenDraft, - }).ToList(); + return null; } - private static ApiClient.CommunicationStatementType MapStatement(ReclassifyStatementRequest statement) + return new PersonalDetail( + MappAddress(defendantPersonalDetail.Address), + defendantPersonalDetail.Email, + defendantPersonalDetail.Ethnicity.ToString(), + defendantPersonalDetail.Gender.ToString(), + defendantPersonalDetail.Occupation, + defendantPersonalDetail.HomePhoneNumber, + defendantPersonalDetail.MobilePhoneNumber, + defendantPersonalDetail.WorkPhoneNumber, + defendantPersonalDetail.PreferredCorrespondenceLanguage.ToString(), + defendantPersonalDetail.Religion.ToString(), + defendantPersonalDetail.Guardian); + } + + private static Address MappAddress(ApiClient.PostalAddress address) + { + if (address is null) { - if (statement == null) - { - return default; - } + return default; + } - return new ApiClient.CommunicationStatementType - { - Witness = statement.Witness, - StatementNo = statement.StatementNo, - Date = ConvertToDateTime(statement.Date), - }; + return new Address( + address.Postcode, + address.AddressLine1, + address.AddressLine2, + address.AddressLine3, + address.AddressLine4, + address.AddressLine5, + address.AddressLine6, + address.AddressLine7, + address.AddressLine8); + } + + private static Location MapLocation(ApiClient.InternationalAddress address) + { + if (address is null) + { + return default; } - private static ApiClient.CommunicationExhibitType MapExhibit(ReclassifyExhibitRequest exhibit) + return new Location( + address.Country, + address.Postcode, + address.AddressLine1, + address.AddressLine2, + address.AddressLine3, + address.AddressLine4, + address.AddressLine5, + address.AddressLine6, + address.AddressLine7, + address.AddressLine8); + } + + private static ApiClient.ApAction MapApAction(AddActionPlanRequest addActionPlanRequest) + { + return new ApiClient.ApAction() { - if (exhibit == null) - { - return default; - } + FullDefendantName = addActionPlanRequest.fullDefendantName, + AllDefendants = addActionPlanRequest.allDefendants, + Date = ConvertToDateTimeOffset(addActionPlanRequest.date), + DateExpected = ConvertToDateTimeOffset(addActionPlanRequest.dateExpected.Value), + DateTimeCreated = addActionPlanRequest.dateTimeCreated, + ActionPointText = addActionPlanRequest.actionPointText, + Status = addActionPlanRequest.status, + StatusDescription = addActionPlanRequest.statusDescription, + ExpectedDateUpdated = addActionPlanRequest.expectedDateUpdated, + PartyType = addActionPlanRequest.partyType, + PoliceChangeReason = addActionPlanRequest.policeChangeReason, + StatusUpdated = addActionPlanRequest.statusUpdated, + SyncedWithPolice = addActionPlanRequest.syncedWithPolice, + CpsChangeReason = addActionPlanRequest.cpsChangeReason, + ChaserTaskDate = ConvertToDateTimeOffset(addActionPlanRequest.chaserTaskDate), + Steps = MapActionStep(addActionPlanRequest.steps), + }; + } - return new ApiClient.CommunicationExhibitType - { - Item = exhibit.Item, - Reference = exhibit.Reference, - Producer = exhibit.Producer, - NewProducer = exhibit.NewProducer, - ExistingProducerOrWitnessId = exhibit.ExistingProducerOrWitnessId, - }; + private static ICollection MapActionStep(Step[] steps) + { + return steps.Select(step => new ApiClient.ActionPlanStep + { + Code = step.code, + Description = step.description, + Text = step.text, + Hidden = step.hidden, + HiddenDraft = step.hiddenDraft, + }).ToList(); + } + + private static ApiClient.CommunicationStatementType MapStatement(ReclassifyStatementRequest statement) + { + if (statement == null) + { + return default; } - private static DateTimeOffset ConvertToDateTimeOffset(DateOnly? date, TimeOnly? time = null) + return new ApiClient.CommunicationStatementType { - if (date is null) - { - return default; - } + Witness = statement.Witness, + StatementNo = statement.StatementNo, + Date = ConvertToDateTime(statement.Date), + }; + } - TimeOnly actualTime = time ?? TimeOnly.MinValue; - DateTime dateTime = date.Value.ToDateTime(actualTime); - TimeSpan offset = TimeZoneInfo.Local.GetUtcOffset(dateTime); - return new DateTimeOffset(dateTime, offset); + private static ApiClient.CommunicationExhibitType MapExhibit(ReclassifyExhibitRequest exhibit) + { + if (exhibit == null) + { + return default; } - private static DateTime ConvertToDateTime(DateOnly? date, TimeOnly? time = null) + return new ApiClient.CommunicationExhibitType { - if (date is null) - { - return default; - } - - TimeOnly actualTime = time ?? TimeOnly.MinValue; - DateTime dateTime = date.Value.ToDateTime(actualTime); + Item = exhibit.Item, + Reference = exhibit.Reference, + Producer = exhibit.Producer, + NewProducer = exhibit.NewProducer, + ExistingProducerOrWitnessId = exhibit.ExistingProducerOrWitnessId, + }; + } - // Mark as local time - return DateTime.SpecifyKind(dateTime, DateTimeKind.Local); + private static DateTimeOffset ConvertToDateTimeOffset(DateOnly? date, TimeOnly? time = null) + { + if (date is null) + { + return default; } - /// - /// Handles an exception that occurred while calling the MDS API. - /// - /// The operation name. - /// The exception to handle. - /// The request with a correspondence ID. - /// The duration of the operation. - private void HandleException( - string operationName, - Exception exception, - BaseRequest request, - TimeSpan duration) + TimeOnly actualTime = time ?? TimeOnly.MinValue; + DateTime dateTime = date.Value.ToDateTime(actualTime); + TimeSpan offset = TimeZoneInfo.Local.GetUtcOffset(dateTime); + return new DateTimeOffset(dateTime, offset); + } + + private static DateTime ConvertToDateTime(DateOnly? date, TimeOnly? time = null) + { + if (date is null) { - Requires.NotNull(operationName); - Requires.NotNull(exception); + return default; + } + + TimeOnly actualTime = time ?? TimeOnly.MinValue; + DateTime dateTime = date.Value.ToDateTime(actualTime); + + // Mark as local time + return DateTime.SpecifyKind(dateTime, DateTimeKind.Local); + } + + /// + /// Handles an exception that occurred while calling the MDS API. + /// + /// The operation name. + /// The exception to handle. + /// The request with a correspondence ID. + /// The duration of the operation. + private void HandleException( + string operationName, + Exception exception, + BaseRequest request, + TimeSpan duration) + { + Requires.NotNull(operationName); + Requires.NotNull(exception); - const string LogMessage = DiagnosticsUtility.Error + @"Calling the MDS API failed for {Operation} after {Duration}. Path: {Path}, Correspondence ID: {CorrespondenceId}, Failure: {Reason} + const string LogMessage = DiagnosticsUtility.Error + @"Calling the MDS API failed for {Operation} after {Duration}. Path: {Path}, Correspondence ID: {CorrespondenceId}, Failure: {Reason} - Failure response: {FailureResponse}"; - this.logger.LogError( - exception, - $"{LogMessage}", - string.Empty, - operationName, - duration, - request?.CorrespondenceId, - exception.ToAggregatedMessage(), - string.Empty); - } - - /// - /// Logs an operation completed event. - /// - /// The operation name. - /// The request with a correspondence ID. - /// The duration of the operation. - /// Any additional information. - private void LogOperationCompletedEvent( - string operationName, - BaseRequest request, - TimeSpan duration, - string additionalInfo) - { - const string LogMessage = @"Calling the MDS API succeeded for {Operation} after {Duration}. Path: {Path}, Correspondence ID: {CorrespondenceId} - - Additional info: {AdditionalInfo}"; + this.logger.LogError( + exception, + $"{LogMessage}", + string.Empty, + operationName, + duration, + request?.CorrespondenceId, + exception.ToAggregatedMessage(), + string.Empty); + } - this.logger.LogInformation( - LogMessage, - operationName, - string.Empty, - duration, - request.CorrespondenceId, - additionalInfo); - } + /// + /// Logs an operation completed event. + /// + /// The operation name. + /// The request with a correspondence ID. + /// The duration of the operation. + /// Any additional information. + private void LogOperationCompletedEvent( + string operationName, + BaseRequest request, + TimeSpan duration, + string additionalInfo) + { + const string LogMessage = @"Calling the MDS API succeeded for {Operation} after {Duration}. Path: {Path}, Correspondence ID: {CorrespondenceId} + - Additional info: {AdditionalInfo}"; - /// - /// Builds a string containing information about the unused materials, based on the provided response. - /// The information includes the number of unused exhibits, mg forms, other materials, and statements. - /// - /// The response object containing the lists of unused materials. - /// A string that describes the received unused materials, including counts for each type. - private string BuildAdditionalInfo(UnusedMaterialsResponse results) - { - string additionalInfo = string.Empty; - bool addedInfo = false; + this.logger.LogInformation( + LogMessage, + operationName, + string.Empty, + duration, + request.CorrespondenceId, + additionalInfo); + } - if (results.Exhibits?.Count > 0) - { - additionalInfo += $"received #{results.Exhibits.Count} unused exhibits"; - addedInfo = true; - } + /// + /// Builds a string containing information about the unused materials, based on the provided response. + /// The information includes the number of unused exhibits, mg forms, other materials, and statements. + /// + /// The response object containing the lists of unused materials. + /// A string that describes the received unused materials, including counts for each type. + private string BuildAdditionalInfo(UnusedMaterialsResponse results) + { + string additionalInfo = string.Empty; + bool addedInfo = false; - if (results.MgForms?.Count > 0) - { - additionalInfo += (addedInfo ? "," : "") + $" received #{results.MgForms.Count} unused mg forms"; - addedInfo = true; - } + if (results.Exhibits?.Count > 0) + { + additionalInfo += $"received #{results.Exhibits.Count} unused exhibits"; + addedInfo = true; + } - if (results.OtherMaterials?.Count > 0) - { - additionalInfo += (addedInfo ? "," : "") + $" received #{results.OtherMaterials.Count} unused other materials"; - addedInfo = true; - } + if (results.MgForms?.Count > 0) + { + additionalInfo += (addedInfo ? "," : string.Empty) + $" received #{results.MgForms.Count} unused mg forms"; + addedInfo = true; + } - if (results.Statements?.Count > 0) - { - additionalInfo += (addedInfo ? "," : "") + $" received #{results.Statements.Count} unused statements"; - } + if (results.OtherMaterials?.Count > 0) + { + additionalInfo += (addedInfo ? "," : string.Empty) + $" received #{results.OtherMaterials.Count} unused other materials"; + addedInfo = true; + } - if (!addedInfo) - { - additionalInfo = "received #0 unused materials"; - } + if (results.Statements?.Count > 0) + { + additionalInfo += (addedInfo ? "," : string.Empty) + $" received #{results.Statements.Count} unused statements"; + } - return additionalInfo; + if (!addedInfo) + { + additionalInfo = "received #0 unused materials"; } + + return additionalInfo; } -} \ No newline at end of file +} diff --git a/DdeiClient/Model/MasterDataServiceCookie.cs b/DdeiClient/Model/MasterDataServiceCookie.cs deleted file mode 100644 index 712e92260..000000000 --- a/DdeiClient/Model/MasterDataServiceCookie.cs +++ /dev/null @@ -1,43 +0,0 @@ -// -// Copyright (c) The Crown Prosecution Service. All rights reserved. -// - -namespace DdeiClient.Model -{ - using System; - using System.Globalization; - - /// - /// Mds cookie. - /// - public class MasterDataServiceCookie - { - /// - /// Initializes a new instance of the class. - /// - /// Auth cookie. - /// CMS auth token. - public MasterDataServiceCookie(string cookies, string token) - { - this.Cookies = cookies; - this.Token = token; - this.ExpiryTime = DateTime.UtcNow.AddHours(1).ToString("o", CultureInfo.InvariantCulture); - } - - /// - /// Gets CMS cookie. - /// - public string Cookies { get; init; } = string.Empty; - - /// - /// Gets CMS token. - /// - public string Token { get; init; } = string.Empty; - - /// - /// Gets token expiry. - /// - public string ExpiryTime { get; init; } = string.Empty; - } - -} diff --git a/polaris-gateway/Functions/BaseFunction.cs b/polaris-gateway/Functions/BaseFunction.cs index d363f712d..8de219f7f 100644 --- a/polaris-gateway/Functions/BaseFunction.cs +++ b/polaris-gateway/Functions/BaseFunction.cs @@ -2,16 +2,15 @@ // Copyright (c) The Crown Prosecution Service. All rights reserved. // -using System; -using System.Web; +namespace PolarisGateway.Functions; + using Common.Constants; using Common.Dto.Request; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; +using System; -namespace PolarisGateway.Functions; - -public class BaseFunction(ILogger? logger = null) +public class BaseFunction(ILogger logger = null) { private readonly ILogger logger = logger; @@ -25,59 +24,13 @@ protected static string EstablishCmsAuthValues(HttpRequest req) { req.Cookies.TryGetValue(HttpHeaderKeys.CmsAuthValues, out var cmsAuthValues); return cmsAuthValues; - } - - protected string GetCmsToken(HttpRequest req) - { - return this.GetCookiePartByIndex(req, 0); - } - - protected string GetCmsCookie(HttpRequest req, bool urlEncode = false) - { - string cookie = this.GetCookiePartByIndex(req, 4); - - if (urlEncode) - { - return HttpUtility.UrlEncode(cookie); - } - - return cookie; } protected CmsAuthValues BuildCmsAuthValues(HttpRequest req) { - var token = this.GetCmsToken(req) ?? string.Empty; - var cookie = this.GetCmsCookie(req) ?? string.Empty; + var cmsAuthValues = EstablishCmsAuthValues(req); var correlation = EstablishCorrelation(req); - return new CmsAuthValues(cookie, token, correlation); - } - - private string? GetCookiePartByIndex(HttpRequest req, int index) - { - if (req.Cookies == null) - { - return string.Empty; - } - - if (req.Cookies.TryGetValue(HttpHeaderKeys.CmsAuthValues, out string? cmsCookie)) - { - string[] cmsParts = cmsCookie.Split(','); - - if (cmsParts.Length > index) - { - return cmsParts[index].Split(':')[1].Replace("\"", string.Empty); - } - else - { - this.logger.LogWarning($"CMS cookie does not contain enough parts. Requested index: {index}."); - return null; - } - } - else - { - this.logger.LogWarning($"CMS cookie not found in the request."); - return null; - } + return new CmsAuthValues(cmsAuthValues, correlation); } -} \ No newline at end of file +} diff --git a/polaris-pipeline/Common/Dto/Request/CmsAuthValues.cs b/polaris-pipeline/Common/Dto/Request/CmsAuthValues.cs index aab1fba0a..c06b7da82 100644 --- a/polaris-pipeline/Common/Dto/Request/CmsAuthValues.cs +++ b/polaris-pipeline/Common/Dto/Request/CmsAuthValues.cs @@ -12,23 +12,17 @@ namespace Common.Dto.Request; /// /// Initializes a new instance of the class. /// -/// The CMS cookies, which may be null. -/// The CMS modern API token, which may be null. +/// The CMS authentication string value /// The correlation ID to track requests. -public class CmsAuthValues(string cmsCookies, string cmsModernToken, Guid correlationId = default) +public class CmsAuthValues(string cmsAuthFullValue, Guid correlationId = default) { /// - /// Gets or sets the CMS cookies. - /// - public string CmsCookies { get; set; } = cmsCookies; - - /// - /// Gets or sets the CMS modern API token. + /// Gets or sets the correlation ID used to track requests. /// - public string CmsModernToken { get; set; } = cmsModernToken; + public Guid CorrelationId { get; set; } = correlationId; /// - /// Gets or sets the correlation ID used to track requests. + /// Gets or sets the full CMS authentication value. /// - public Guid CorrelationId { get; set; } = correlationId; + public string CmsAuthFullValue { get; set; } = cmsAuthFullValue; } From c86f735ae49a4024fdec33b63c07c34a4d176406 Mon Sep 17 00:00:00 2001 From: Kesh Ramduny Date: Mon, 29 Jun 2026 22:26:19 +0100 Subject: [PATCH 2/5] Fix HK Unit tests --- .../BulkSetUnusedServiceTests.cs | 10 +- .../CaseActionPlanServiceTests.cs | 6 +- .../CaseInfoServiceTests.cs | 6 +- .../CaseMaterialServiceTests.cs | 13 +-- .../CommunicationServiceTests.cs | 97 ++++--------------- .../DocumentServiceTests.cs | 8 +- ...sificationOrchestrationServiceUnitTests.cs | 8 +- .../WitnessServiceTests.cs | 14 +-- hkui-functions-integration-tests/TestBase.cs | 2 +- .../CaseDefendantsServiceTests.cs | 6 +- .../CompleteReclassificationTests.cs | 10 +- 11 files changed, 58 insertions(+), 122 deletions(-) diff --git a/Cps.Fct.Hk.Ui.Services.Tests/BulkSetUnusedServiceTests.cs b/Cps.Fct.Hk.Ui.Services.Tests/BulkSetUnusedServiceTests.cs index c787f345d..e856b82ec 100644 --- a/Cps.Fct.Hk.Ui.Services.Tests/BulkSetUnusedServiceTests.cs +++ b/Cps.Fct.Hk.Ui.Services.Tests/BulkSetUnusedServiceTests.cs @@ -53,7 +53,7 @@ public async Task BulkSetUnusedAsync_AllMaterialsReclassified_ReturnsSuccess() }; // var cmsAuthValues = new CmsAuthValues(); - var cmsAuthValues = new CmsAuthValues("cookies", "token", Guid.NewGuid()); + var cmsAuthValues = new CmsAuthValues("cookies", Guid.NewGuid()); this.mockApiClient.Setup(client => client.ReclassifyCommunicationAsync(It.IsAny(), It.IsAny())) .ReturnsAsync((ReclassifyCommunicationRequest req, CmsAuthValues _) => @@ -91,7 +91,7 @@ public async Task BulkSetUnusedAsync_PartialSuccess_ReturnsPartialSuccess() new BulkSetUnusedRequest { materialId = 2, subject = "Material 2" }, }; - var cmsAuthValues = new CmsAuthValues("cookies", "token", Guid.NewGuid()); + var cmsAuthValues = new CmsAuthValues("cookies", Guid.NewGuid()); #pragma warning disable CS8620 // Argument cannot be used for parameter due to differences in the nullability of reference types. this.mockApiClient.Setup(client => client.ReclassifyCommunicationAsync(It.IsAny(), cmsAuthValues)) @@ -147,7 +147,7 @@ public async Task BulkSetUnusedAsync_AllMaterialsFail_ReturnsFailed() new BulkSetUnusedRequest { materialId = 2, subject = "Material 2" }, }; - var cmsAuthValues = new CmsAuthValues("cookies", "token", Guid.NewGuid()); + var cmsAuthValues = new CmsAuthValues("cookies", Guid.NewGuid()); this.mockApiClient.Setup(client => client.ReclassifyCommunicationAsync(It.IsAny(), It.IsAny())) .ThrowsAsync(new Exception("Reclassification failed")); @@ -184,7 +184,7 @@ public async Task BulkSetUnusedAsync_ApiThrowsException_ThrowsException() new BulkSetUnusedRequest { materialId = 1, subject = "Material 1" }, }; - var cmsAuthValues = new CmsAuthValues("cookies", "token", Guid.NewGuid()); + var cmsAuthValues = new CmsAuthValues("cookies", Guid.NewGuid()); this.mockApiClient.Setup(client => client.ReclassifyCommunicationAsync(It.IsAny(), cmsAuthValues)) .ThrowsAsync(exception); @@ -223,7 +223,7 @@ public async Task BulkSetUnusedAsync_LogsErrorWhenMaterialFails() new BulkSetUnusedRequest { materialId = 1, subject = "Material 1" }, }; - var cmsAuthValues = new CmsAuthValues("cookies", "token", Guid.NewGuid()); + var cmsAuthValues = new CmsAuthValues("cookies", Guid.NewGuid()); this.mockApiClient.Setup(client => client.ReclassifyCommunicationAsync(It.IsAny(), It.IsAny())) .ThrowsAsync(new Exception("Reclassification failed")); diff --git a/Cps.Fct.Hk.Ui.Services.Tests/CaseActionPlanServiceTests.cs b/Cps.Fct.Hk.Ui.Services.Tests/CaseActionPlanServiceTests.cs index c8fe785db..032826ad6 100644 --- a/Cps.Fct.Hk.Ui.Services.Tests/CaseActionPlanServiceTests.cs +++ b/Cps.Fct.Hk.Ui.Services.Tests/CaseActionPlanServiceTests.cs @@ -55,7 +55,7 @@ public async Task AddCaseActionPlanAsync_ReturnsNoContentResult_WhenApiCallIsSuc // Arrange string urn = "1234567890"; int caseId = 123; - var cmsAuthValues = new CmsAuthValues("validCmsToken", "validCmsCookies"); + var cmsAuthValues = new CmsAuthValues("validCmsToken"); AddCaseActionPlanRequest mockAddCaseActionPlanRequest = CreateMockAddCaseActionPlanRequest(); @@ -101,7 +101,7 @@ public async Task AddCaseActionPlanAsync_ThrowsException_WhenApiCallFails() // Arrange string urn = "1234567890"; int caseId = 123; - var cmsAuthValues = new CmsAuthValues("validCmsToken", "validCmsCookies"); + var cmsAuthValues = new CmsAuthValues("validCmsToken"); AddCaseActionPlanRequest mockAddCaseActionPlanRequest = CreateMockAddCaseActionPlanRequest(); @@ -146,7 +146,7 @@ public async Task AddCaseActionPlanAsync_LogsError_WhenCaseLocked() // Arrange string urn = "1234567890"; int caseId = 123; - var cmsAuthValues = new CmsAuthValues("validCmsToken", "validCmsCookies"); + var cmsAuthValues = new CmsAuthValues("validCmsToken"); AddCaseActionPlanRequest mockAddCaseActionPlanRequest = CreateMockAddCaseActionPlanRequest(); diff --git a/Cps.Fct.Hk.Ui.Services.Tests/CaseInfoServiceTests.cs b/Cps.Fct.Hk.Ui.Services.Tests/CaseInfoServiceTests.cs index 0af60ff75..8de17f7ab 100644 --- a/Cps.Fct.Hk.Ui.Services.Tests/CaseInfoServiceTests.cs +++ b/Cps.Fct.Hk.Ui.Services.Tests/CaseInfoServiceTests.cs @@ -46,7 +46,7 @@ public async Task GetCaseInfoAsync_ReturnsCaseSummary_WhenApiCallIsSuccessful() { // Arrange int caseId = 123; - var cmsAuthValues = new CmsAuthValues("validCmsToken", "validCmsCookies"); + var cmsAuthValues = new CmsAuthValues("validCmsToken"); // Setup the expected CaseSummary result var expectedCaseSummary = new CaseSummaryResponse(caseId, "06SC1234572", "Will", "SMITH", 2, "Hull UT"); @@ -82,7 +82,7 @@ public async Task GetCaseInfoAsync_ThrowsInvalidOperationException_WhenCaseSumma { // Arrange int caseId = 123; - var cmsAuthValues = new CmsAuthValues("validCmsToken", "validCmsCookies"); + var cmsAuthValues = new CmsAuthValues("validCmsToken"); // Setup the API client to return null for the case summary this.apiClientMock @@ -113,7 +113,7 @@ public async Task GetCaseInfoAsync_ThrowsException_WhenApiCallFails() { // Arrange int caseId = 123; - var cmsAuthValues = new CmsAuthValues("validCmsToken", "validCmsCookies"); + var cmsAuthValues = new CmsAuthValues("validCmsToken"); // Setup the API client to throw an exception this.apiClientMock diff --git a/Cps.Fct.Hk.Ui.Services.Tests/CaseMaterialServiceTests.cs b/Cps.Fct.Hk.Ui.Services.Tests/CaseMaterialServiceTests.cs index 83668a18c..03f255311 100644 --- a/Cps.Fct.Hk.Ui.Services.Tests/CaseMaterialServiceTests.cs +++ b/Cps.Fct.Hk.Ui.Services.Tests/CaseMaterialServiceTests.cs @@ -127,7 +127,7 @@ public void MapUsedExhibitsToCaseMaterials_ReturnsMappedCaseMaterials() DateTime receivedDate = new DateTime(2025, 04, 01); int caseId = 123; - var cmsAuthValues = new CmsAuthValues("validCmsToken", "validCmsCookies"); + var cmsAuthValues = new CmsAuthValues("validCmsToken"); var usedExhibitsResponse = new UsedExhibitsResponse { @@ -189,7 +189,7 @@ public void MapUsedExhibitsToCaseMaterials_WithNullDocumentType_ReturnsMappedCas // Arrange DateTime receivedDate = new DateTime(2025, 04, 01); int caseId = 123; - var cmsAuthValues = new CmsAuthValues("validCmsToken", "validCmsCookies"); + var cmsAuthValues = new CmsAuthValues("validCmsToken"); var usedExhibitsResponse = new UsedExhibitsResponse { @@ -855,7 +855,6 @@ public async Task Run_ReturnsUnprocessableEntityError_WhenExceptionIsThrownBy_Ge var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); this.mockCommunicationService @@ -889,7 +888,6 @@ public async Task Run_ReturnsUnprocessableEntityError_WhenExceptionIsThrownBy_Ge var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); this.mockCommunicationService @@ -923,7 +921,6 @@ public async Task Run_ReturnsUnprocessableEntityError_WhenExceptionIsThrownBy_Ge var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); this.mockCommunicationService @@ -957,7 +954,6 @@ public async Task Run_ReturnsUnprocessableEntityError_WhenExceptionIsThrownBy_Ge var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); this.mockCommunicationService @@ -1329,7 +1325,6 @@ public async Task Run_ReturnsUnprocessableEntityError_WhenExceptionIsThrownBy_Ge // Arrange var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); this.mockCommunicationService @@ -1361,7 +1356,6 @@ public async Task Run_ReturnsUnprocessableEntityError_WhenExceptionIsThrownBy_Ge // Arrange var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); this.mockCommunicationService @@ -1395,7 +1389,6 @@ public async Task Run_ReturnsUnprocessableEntityError_WhenExceptionIsThrownBy_Ge var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); ExhibitProducersResponse exhibitProducersResponse = BuildTestExhibitProducers(); @@ -1430,7 +1423,6 @@ public void MapExistingProducerOrWitnessId_ReturnsNull_WhenExhibitProducerIsNotP var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); ExhibitProducersResponse exhibitProducersResponse = BuildTestExhibitProducers(); @@ -1464,7 +1456,6 @@ public void MapExistingProducerOrWitnessId_ReturnsId_WhenExhibitProducerIsMatche var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var exhibitProducers = new ExhibitProducersResponse() diff --git a/Cps.Fct.Hk.Ui.Services.Tests/CommunicationServiceTests.cs b/Cps.Fct.Hk.Ui.Services.Tests/CommunicationServiceTests.cs index dcb573747..19a3b5e2f 100644 --- a/Cps.Fct.Hk.Ui.Services.Tests/CommunicationServiceTests.cs +++ b/Cps.Fct.Hk.Ui.Services.Tests/CommunicationServiceTests.cs @@ -4,29 +4,28 @@ namespace Cps.Fct.Hk.Ui.Services.Tests; +using Common.Constants; +using Common.Dto.Request; +using Common.Dto.Request.HouseKeeping; +using Common.Dto.Response.HouseKeeping; +using Common.Enums; +using Common.Exceptions; using Cps.Fct.Hk.Ui.Interfaces; +using Cps.Fct.Hk.Ui.Services.Tests.TestUtilities; +using DdeiClient.Clients.Interfaces; +using FluentAssertions; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Moq; -using Xunit; using System; using System.Collections.Generic; using System.Globalization; using System.Linq; -using System.Threading.Tasks; -using Cps.Fct.Hk.Ui.Services.Tests.TestUtilities; -using Microsoft.AspNetCore.Mvc; -using FluentAssertions; -using Microsoft.AspNetCore.Http; -using DdeiClient.Clients.Interfaces; -using Common.Dto.Response.HouseKeeping; -using Common.Dto.Request; -using Common.Dto.Request.HouseKeeping; -using Common.Constants; -using Common.Exceptions; using System.Threading; - +using System.Threading.Tasks; +using Xunit; using ApiClient = Cps.MasterDataService.Infrastructure.ApiClient; -using Common.Enums; /// /// Unit tests for the class. @@ -78,7 +77,6 @@ public async Task GetCommunicationsAsync_ShouldReturnMappedCommunications_WhenAp var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); this.apiClientMock @@ -131,7 +129,6 @@ public async Task GetCommunicationsAsync_ShouldLogErrorAndRethrow_WhenApiThrowsE var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); this.apiClientMock @@ -175,7 +172,6 @@ public async Task GetCommunicationsAsync_ShouldMapDocumentTypeInfo_WhenApiReturn var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); this.apiClientMock @@ -253,7 +249,6 @@ public async Task GetUsedStatementsAsync_ShouldReturn_WhenApiReturnsUsedStatemen var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); this.apiClientMock @@ -292,7 +287,6 @@ public async Task GetUsedStatementsAsync_ShouldLogErrorAndRethrow_WhenApiThrowsE var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); this.apiClientMock @@ -367,7 +361,7 @@ public async Task GetUsedExhibitsAsync_ShouldReturn_WhenApiReturnsUsedExhibits() var cmsAuthValues = new CmsAuthValues( "cookies", - "token", + Guid.NewGuid()); this.apiClientMock @@ -404,7 +398,6 @@ public async Task GetUsedExhibitsAsync_ShouldLogErrorAndRethrow_WhenApiThrowsExc var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); this.apiClientMock @@ -569,7 +562,6 @@ public async Task GetUnusedMaterialsAsync_ShouldReturn_WhenApiReturnsUnusedMater var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); this.apiClientMock @@ -630,7 +622,6 @@ public async Task GetUnusedMaterialsAsync_ShouldLogErrorAndRethrow_WhenApiThrows var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); this.apiClientMock @@ -670,7 +661,6 @@ public async Task GetAttachmentsAsync_ShouldReturnAttachments_WhenApiCallIsSucce var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var expectedResponse = new AttachmentsResponse @@ -728,7 +718,7 @@ public async Task GetAttachmentsAsync_ShouldReturnAttachmentsWithExhibitsAndStat var cmsAuthValues = new CmsAuthValues( "cookies", - "token", + Guid.NewGuid()); var expectedResponse = new AttachmentsResponse @@ -795,7 +785,6 @@ public async Task GetAttachmentsAsync_ShouldLogAndRethrowException_WhenApiCallFa var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var testException = new Exception("Simulated API error"); @@ -860,7 +849,6 @@ public async Task RetrieveAllAttachmentsAsync_ShouldRetrieveAttachments_WhenComm var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var attachmentsResponse = new AttachmentsResponse @@ -968,7 +956,6 @@ public async Task RetrieveAllAttachmentsAsync_ShouldRetrieveAttachmentsWithExhib var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var attachmentsResponse = new AttachmentsResponse @@ -1069,7 +1056,6 @@ public async Task RetrieveAllAttachmentsAsync_ShouldReturnEmptyList_WhenNoCommun var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); // Act @@ -1115,7 +1101,6 @@ public async Task RetrieveAllAttachmentsAsync_ShouldHandleCommunicationsWithoutA var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); // Act @@ -1161,7 +1146,6 @@ public async Task RetrieveAllAttachmentsAsync_ShouldLogAndRethrowException_WhenE var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var testException = new Exception("Simulated error"); @@ -1419,7 +1403,6 @@ public async Task GetCommunicationLinkAsync_CommunicationLinkFound_ReturnsLink() var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var apiCommunications = new List @@ -1479,7 +1462,7 @@ public async Task GetCaseMaterialLinkAsync_MaterialFoundInVariousSources_Returns // Arrange int caseId = 1; int materialId = 456; - var cmsAuthValues = new CmsAuthValues("cookies", "token", Guid.NewGuid()); + var cmsAuthValues = new CmsAuthValues("cookies", Guid.NewGuid()); List communications = source == "communications" ? new List { new(1, "File1", "Subject1", 123, materialId, expectedLink, "Active", "Category1", "Type1", false) } @@ -1590,7 +1573,6 @@ public async Task GetCommunicationLinkAsync_NoCommunications_ReturnsNotFoundResu var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); this.apiClientMock @@ -1619,7 +1601,6 @@ public async Task GetCommunicationLinkAsync_NoDirectLink_ChecksAttachments_Retur var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var apiCommunications = new List @@ -1698,7 +1679,6 @@ public async Task GetCommunicationLinkAsync_NoAttachments_ReturnsNotFoundResult( var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var apiCommunications = new List @@ -1758,7 +1738,6 @@ public async Task GetCommunicationLinkAsync_ThrowsException_ErrorIsLogged() var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); this.apiClientMock @@ -1785,7 +1764,6 @@ public async Task RenameMaterialAsync_ShouldReturn_AsExpected_SuccessLogged() // Arrange var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var expectedResponse = new RenameMaterialResponse(new RenameMaterialData @@ -1827,7 +1805,6 @@ public async Task RenameMaterialAsync_WhenApiThrow_ShouldThrowException() // Arrange var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); int caseId = 134; @@ -1866,7 +1843,6 @@ public async Task GetPcdRequestCore_ShouldThrowException_WhenApiClientThrowsExce var correlationId = Guid.NewGuid(); var cmsAuthValues = new CmsAuthValues( "cookies", - "token", correlationId); var request = new GetPcdRequestsCoreRequest(caseId, correlationId); this.apiClientMock.Setup(x => x.GetPcdRequestCoreAsync(request, cmsAuthValues)) @@ -1896,7 +1872,6 @@ public async Task GetPcdRequestByPcdIdAsync_ShouldThrowException_WhenApiClientTh var correlationId = Guid.NewGuid(); var cmsAuthValues = new CmsAuthValues( "cookies", - "token", correlationId); var request = new GetPcdRequestByPcdIdCoreRequest(caseId, pcdId, correlationId); this.apiClientMock.Setup(x => x.GetPcdRequestByPcdIdAsync(request, cmsAuthValues)) @@ -1922,7 +1897,6 @@ public async Task SetMaterialReadStatusAsync_ShouldReturn_AsExpected_SuccessLogg // Arrange var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var expectedResposne = new SetMaterialReadStatusResponse(new SetMaterialReadStatusResponseData @@ -1963,7 +1937,6 @@ public async Task SetMaterialReadStatusAsync_WhenApiThrow_ShouldThrowException() // Arrange var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var exceptionMocked = new BadHttpRequestException("Material does not exists in DDEI"); @@ -1998,7 +1971,6 @@ public async Task DiscardMaterialAsync_ShouldLogAndReturn_WhenApiReturnsSuccess( // Arrange var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var expectedResponse = new DiscardMaterialResponse(new DiscardMaterialData @@ -2046,7 +2018,6 @@ public async Task DiscardMaterialAsync_ShouldLogAndRethrowException_WhenApiCallF // Arrange var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); int caseId = 134; @@ -2124,7 +2095,6 @@ public async Task GetUsedMgFormsAsync_ShouldReturn_WhenApiReturnsUsedMgForms() var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); this.apiClientMock @@ -2167,7 +2137,6 @@ public async Task GetUsedMgFormsAsync_ShouldLogErrorAndRethrow_WhenApiThrowsExce var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); this.apiClientMock @@ -2238,7 +2207,6 @@ public async Task GetUsedOtherMaterialsAsync_ShouldReturn_WhenApiReturnsUsedOthe var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); this.apiClientMock @@ -2281,7 +2249,6 @@ public async Task GetUsedOtherMaterialsAsync_ShouldLogErrorAndRethrow_WhenApiThr var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); this.apiClientMock @@ -2326,7 +2293,6 @@ public async Task GetUsedMgFormsAsync_ShouldReturnEmptyResponse_WhenApiReturnsNo var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); this.apiClientMock @@ -2367,7 +2333,6 @@ public async Task GetUsedOtherMaterialsAsync_ShouldReturnEmptyResponse_WhenApiRe var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); this.apiClientMock @@ -2398,7 +2363,7 @@ public async Task GetExhibitProducersAsync_ReturnsExhibitProducersForCase_WhenAp { // Arrange int caseId = 4321; - var cmsAuthValues = new CmsAuthValues("validCmsToken", "validCmsCookies"); + var cmsAuthValues = new CmsAuthValues("validCmsToken"); var expectedProducers = new ExhibitProducersResponse { @@ -2437,7 +2402,7 @@ public async Task GetExhibitProducersAsync_ThrowsException_WhenApiCallFails() { // Arrange int caseId = 4321; - var cmsAuthValues = new CmsAuthValues("validCmsToken", "validCmsCookies"); + var cmsAuthValues = new CmsAuthValues("validCmsToken"); var expectedProducers = new ExhibitProducersResponse { @@ -2477,7 +2442,6 @@ public async Task UpdateStatementAsync_ShouldLogAndReturn_WhenApiReturnsSuccess( // Arrange var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var expectedResponse = new UpdateStatementResponse(new UpdateStatementData @@ -2523,7 +2487,7 @@ public async Task UpdateStatementAsync_ShouldLogAndRethrowException_WhenApiCallF // Arrange var cmsAuthValues = new CmsAuthValues( "cookies", - "token", + Guid.NewGuid()); int caseId = 134; @@ -2565,7 +2529,6 @@ public async Task UpdateExhibitAsync_ShouldLogAndReturn_WhenApiReturnsSuccess() // Arrange var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var expectedResponse = new UpdateExhibitResponse(new UpdateExhibitData @@ -2611,7 +2574,6 @@ public async Task UpdateExhibitAsync_ShouldLogAndRethrowException_WhenApiCallFai // Arrange var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); int caseId = 134; @@ -2658,7 +2620,6 @@ public async Task GetPcdReviewDetailAsync_ShouldReturnPcdReviewDetails_WhenApiCa var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var historyEvents = new List @@ -2723,7 +2684,6 @@ public async Task GetPcdReviewDetailAsync_ShouldReturnPcdReviewDetailsWithPreCha var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var historyEvents = new List @@ -2784,7 +2744,6 @@ public async Task GetPcdReviewDetailAsync_ShouldReturnPcdReviewDetailsWithoutPre var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var historyEvents = new List @@ -2835,7 +2794,6 @@ public async Task GetPcdReviewDetailAsync_ShouldThrowBadRequestException_WhenHis var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var historyEvents = new List @@ -2873,7 +2831,6 @@ public async Task GetPcdReviewDetailAsync_ShouldLogAndRethrowException_WhenApiCa var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); this.apiClientMock @@ -2909,7 +2866,6 @@ public async Task GetPcdReviewDetailAsync_ShouldPassCancellationToken_ToDownstre var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var historyEvents = new List @@ -2959,7 +2915,6 @@ public async Task GetPcdReviewCoreAsync_ShouldReturnEarlyAdvice_WhenPcdAnalysisA var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var historyEvents = new List @@ -3008,7 +2963,6 @@ public async Task GetPcdReviewCoreAsync_ShouldNotReturnEarlyAdvice_WhenInitialRe var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var historyEvents = new List @@ -3055,7 +3009,6 @@ public async Task GetPcdReviewCoreAsync_ShouldFilterOnlyPcdRelatedEvents_WhenHis var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); // Using the provided test data - only valid types @@ -3082,8 +3035,8 @@ public async Task GetPcdReviewCoreAsync_ShouldFilterOnlyPcdRelatedEvents_WhenHis var resultList = result.ToList(); // Verify only PCD-related events are returned - Assert.True(resultList.All(x => x.Type == PcdReviewCoreType.EarlyAdvice || - x.Type == PcdReviewCoreType.InitialReview || + Assert.True(resultList.All(x => x.Type == PcdReviewCoreType.EarlyAdvice || + x.Type == PcdReviewCoreType.InitialReview || x.Type == PcdReviewCoreType.PreChargeDecisionAnalysis)); // Verify the order is maintained @@ -3109,7 +3062,6 @@ public async Task GetPcdReviewCoreAsync_ShouldReturnEmptyCollection_WhenNoPcdRel var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var historyEvents = new List @@ -3148,7 +3100,6 @@ public async Task GetPcdReviewCoreAsync_ShouldReturnCorrectDates_ForAllPcdReview var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var testDate = "27/01/2026"; @@ -3193,7 +3144,6 @@ public async Task GetPcdReviewCoreAsync_ShouldReturnItemsOrderedById_WhenMultipl var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); // Events are provided out of order @@ -3242,7 +3192,6 @@ public async Task GetPcdReviewCoreAsync_ShouldLogInformation_WhenFetchingCaseHis var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var historyEvents = new List @@ -3281,7 +3230,6 @@ public async Task GetPcdReviewCoreAsync_ShouldLogAndRethrowException_WhenApiCall var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); this.apiClientMock @@ -3317,7 +3265,6 @@ public async Task GetPcdReviewCoreAsync_ShouldPassCancellationToken_ToDownstream var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var historyEvents = new List @@ -3352,7 +3299,6 @@ public async Task GetPcdReviewCoreAsync_ShouldReturnOnlyEarlyAdvice_WhenOnlyPcdA var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var historyEvents = new List @@ -3394,7 +3340,6 @@ public async Task GetPcdReviewCoreAsync_ShouldReturnOnlyInitialReview_WhenOnlyIn var cmsAuthValues = new CmsAuthValues( "cookies", - "token", Guid.NewGuid()); var historyEvents = new List diff --git a/Cps.Fct.Hk.Ui.Services.Tests/DocumentServiceTests.cs b/Cps.Fct.Hk.Ui.Services.Tests/DocumentServiceTests.cs index a5c410b5f..c294fe293 100644 --- a/Cps.Fct.Hk.Ui.Services.Tests/DocumentServiceTests.cs +++ b/Cps.Fct.Hk.Ui.Services.Tests/DocumentServiceTests.cs @@ -64,7 +64,7 @@ public async Task GetMaterialDocumentAsync_ValidDocument_ReturnsFileStreamResult // Arrange string caseId = "123"; string link = "/case/material/document.txt"; - var cmsAuthValues = new CmsAuthValues("valid cookies", "valid token", Guid.NewGuid()); + var cmsAuthValues = new CmsAuthValues("valid cookies", Guid.NewGuid()); var mockFileStreamResult = new FileStreamResult(new MemoryStream(), "text/plain") { FileDownloadName = "preview_document" }; string blobContainerName = "test-container"; string pdfBlobUrl = "https://blobstorage/test/preview_document.pdf"; @@ -140,7 +140,7 @@ public async Task GetMaterialDocumentAsync_DocumentNotFound_ThrowsInvalidOperati // Arrange string caseId = "123"; string link = "/case/material/missing_document.txt"; - var cmsAuthValues = new CmsAuthValues("valid cookies", "valid token", Guid.NewGuid()); + var cmsAuthValues = new CmsAuthValues("valid cookies", Guid.NewGuid()); this.mockApiClient .Setup(client => client.GetMaterialDocumentAsync(It.IsAny(), cmsAuthValues)) @@ -173,7 +173,7 @@ public async Task GetMaterialDocumentAsync_ExceptionThrown_ThrowsException() // Arrange string caseId = "123"; string link = "/case/material/document.txt"; - var cmsAuthValues = new CmsAuthValues("valid cookies", "valid token", Guid.NewGuid()); + var cmsAuthValues = new CmsAuthValues("valid cookies", Guid.NewGuid()); var exception = new Exception("DDEI API error"); this.mockApiClient @@ -208,7 +208,7 @@ public async Task GetMaterialDocumentAsync_NotSupportedExceptionThrown_ThrowsNot // Arrange string caseId = "123"; string link = "/case/material/document.txt"; - var cmsAuthValues = new CmsAuthValues("valid cookies", "valid token", Guid.NewGuid()); + var cmsAuthValues = new CmsAuthValues("valid cookies", Guid.NewGuid()); var exception = new NotSupportedException("DDEI API error"); this.mockApiClient diff --git a/Cps.Fct.Hk.Ui.Services.Tests/MaterialReclassificationOrchestrationServiceUnitTests.cs b/Cps.Fct.Hk.Ui.Services.Tests/MaterialReclassificationOrchestrationServiceUnitTests.cs index c492a0b02..798115a6a 100644 --- a/Cps.Fct.Hk.Ui.Services.Tests/MaterialReclassificationOrchestrationServiceUnitTests.cs +++ b/Cps.Fct.Hk.Ui.Services.Tests/MaterialReclassificationOrchestrationServiceUnitTests.cs @@ -57,7 +57,7 @@ public async Task CompleteReclassificationAsync_ReclassifyingMaterialToStatement int caseId = 232; int materialId = 123; int newWitnessId = 765; - var cmsAuthValues = new CmsAuthValues("valid cookies", "valid token", Guid.NewGuid()); + var cmsAuthValues = new CmsAuthValues("valid cookies", Guid.NewGuid()); var transactionId = Guid.NewGuid(); var reclassifyCaseMaterialRequest = CreateMockReclassifyToStatmentRequest(); @@ -153,7 +153,7 @@ public async Task CompleteReclassificationAsync_ReclassifyingMaterialToStatement int caseId = 232; int materialId = 123; int newWitnessId = 765; - var cmsAuthValues = new CmsAuthValues("valid cookies", "valid token", Guid.NewGuid()); + var cmsAuthValues = new CmsAuthValues("valid cookies", Guid.NewGuid()); var transactionId = Guid.NewGuid(); var reclassifyCaseMaterialRequest = CreateMockReclassifyToStatmentRequest(); @@ -247,7 +247,7 @@ public async Task CompleteReclassificationAsync_ReclassifyingMaterialToStatement // Arrange int caseId = 232; int materialId = 123; - var cmsAuthValues = new CmsAuthValues("valid cookies", "valid token", Guid.NewGuid()); + var cmsAuthValues = new CmsAuthValues("valid cookies", Guid.NewGuid()); var transactionId = Guid.NewGuid(); var reclassifyCaseMaterialRequest = CreateMockReclassifyToStatmentRequest(); @@ -342,7 +342,7 @@ public async Task CompleteReclassificationAsync_ReclassifyingMaterialToOther_All int caseId = 232; int materialId = 123; int newWitnessId = 765; - var cmsAuthValues = new CmsAuthValues("valid cookies", "valid token", Guid.NewGuid()); + var cmsAuthValues = new CmsAuthValues("valid cookies", Guid.NewGuid()); var transactionId = Guid.NewGuid(); var reclassifyCaseMaterialRequest = CreateMockReclassifyToOtherRequest(); diff --git a/Cps.Fct.Hk.Ui.Services.Tests/WitnessServiceTests.cs b/Cps.Fct.Hk.Ui.Services.Tests/WitnessServiceTests.cs index eb62aa0b7..6d49f2261 100644 --- a/Cps.Fct.Hk.Ui.Services.Tests/WitnessServiceTests.cs +++ b/Cps.Fct.Hk.Ui.Services.Tests/WitnessServiceTests.cs @@ -52,7 +52,7 @@ public async Task GetWitnessesForCaseAsync_ReturnsWitnessesForCase_WhenApiCallIs { // Arrange int caseId = 4321; - var cmsAuthValues = new CmsAuthValues("validCmsToken", "validCmsCookies"); + var cmsAuthValues = new CmsAuthValues("validCmsToken"); var expectedWitnesses = new WitnessesResponse { @@ -93,7 +93,7 @@ public async Task GetWitnessesForCaseAsync_ThrowsException_WhenApiCallFails() { // Arrange int caseId = 4321; - var cmsAuthValues = new CmsAuthValues("validCmsToken", "validCmsCookies"); + var cmsAuthValues = new CmsAuthValues("validCmsToken"); var expectedWitnesses = new WitnessesResponse { @@ -131,7 +131,7 @@ public async Task GetStatementsForWitnessAsync_ReturnsWitnessStatements_WhenApiC { // Arrange int witnessId = 789; - var cmsAuthValues = new CmsAuthValues("validCmsToken", "validCmsCookies"); + var cmsAuthValues = new CmsAuthValues("validCmsToken"); // Statements var statement1 = new WitnessStatement( @@ -180,7 +180,7 @@ public async Task GetStatementsForWitnessAsync_ThrowsExceptionAndLogsError_WhenA { // Arrange int witnessId = 789; - var cmsAuthValues = new CmsAuthValues("validCmsToken", "validCmsCookies"); + var cmsAuthValues = new CmsAuthValues("validCmsToken"); this.apiClientMock .Setup(x => x.GetWitnessStatementsAsync(It.IsAny(), cmsAuthValues)) @@ -211,7 +211,7 @@ public async Task AddWitnessAsync_ThrowsException_WhenApiCallFails() // Arrange int caseId = 4321; string urn = "12345671"; - var cmsAuthValues = new CmsAuthValues("validCmsToken", "validCmsCookies"); + var cmsAuthValues = new CmsAuthValues("validCmsToken"); this.apiClientMock .Setup(x => x.AddWitnessAsync(It.IsAny(), It.IsAny())) @@ -254,7 +254,7 @@ public async Task AddWitnessAsync_WhenNewWitnessDetailsNotFound_ThrowsAndLogsExc new (caseId, 432, "Bob", "Jackson"), }, }; - var cmsAuthValues = new CmsAuthValues("validCmsToken", "validCmsCookies"); + var cmsAuthValues = new CmsAuthValues("validCmsToken"); this.apiClientMock .Setup(x => x.AddWitnessAsync(It.IsAny(), It.IsAny())) @@ -312,7 +312,7 @@ public async Task AddWitnessAsyncReturnsOk_WhenApiCallSucceeds(string firstName, new (caseId, 432, "Bob", "Jackson"), }, }; - var cmsAuthValues = new CmsAuthValues("validCmsToken", "validCmsCookies"); + var cmsAuthValues = new CmsAuthValues("validCmsToken"); this.apiClientMock .Setup(x => x.AddWitnessAsync(It.IsAny(), It.IsAny())) diff --git a/hkui-functions-integration-tests/TestBase.cs b/hkui-functions-integration-tests/TestBase.cs index 71db76cba..651470911 100644 --- a/hkui-functions-integration-tests/TestBase.cs +++ b/hkui-functions-integration-tests/TestBase.cs @@ -415,7 +415,7 @@ protected internal async Task ResetAllCommunications() AuthenticationContext authContext = await this.AuthenticateAsync(authenticationRequest).ConfigureAwait(true); - CmsAuthValues cmsAuthValues = new CmsAuthValues(authContext.Cookies, authContext.Token); + CmsAuthValues cmsAuthValues = new CmsAuthValues(authContext.ToString()); var request = new ListCommunicationsHkRequest(caseId, Guid.NewGuid()); diff --git a/polaris-gateway.tests/Functions/HouseKeeping/CaseDefendantsServiceTests.cs b/polaris-gateway.tests/Functions/HouseKeeping/CaseDefendantsServiceTests.cs index 3eaf76d5a..d7ea33f99 100644 --- a/polaris-gateway.tests/Functions/HouseKeeping/CaseDefendantsServiceTests.cs +++ b/polaris-gateway.tests/Functions/HouseKeeping/CaseDefendantsServiceTests.cs @@ -49,7 +49,7 @@ public async Task GetCaseDefendantsAsync_ReturnsCaseDefendants_WhenApiCallIsSucc { // Arrange int caseId = 123; - var cmsAuthValues = new CmsAuthValues("validCmsToken", "validCmsCookies"); + var cmsAuthValues = new CmsAuthValues("validCmsToken"); // Setup the expected DefendantsResponse result var expectedCaseDefendants = new DefendantsResponse @@ -182,7 +182,7 @@ public async Task GetCaseDefendantsAsync_ThrowsInvalidOperationException_WhenCas { // Arrange int caseId = 123; - var cmsAuthValues = new CmsAuthValues("validCmsToken", "validCmsCookies"); + var cmsAuthValues = new CmsAuthValues("validCmsToken"); // Setup the API client to return null for the case defendants this.apiClientMock @@ -213,7 +213,7 @@ public async Task GetCaseDefendantsAsync_ThrowsException_WhenApiCallFails() { // Arrange int caseId = 123; - var cmsAuthValues = new CmsAuthValues("validCmsToken", "validCmsCookies"); + var cmsAuthValues = new CmsAuthValues("validCmsToken"); // Setup the API client to throw an exception this.apiClientMock diff --git a/polaris-gateway.tests/Functions/HouseKeeping/CompleteReclassificationTests.cs b/polaris-gateway.tests/Functions/HouseKeeping/CompleteReclassificationTests.cs index a91b1c802..d8f6ebcdd 100644 --- a/polaris-gateway.tests/Functions/HouseKeeping/CompleteReclassificationTests.cs +++ b/polaris-gateway.tests/Functions/HouseKeeping/CompleteReclassificationTests.cs @@ -61,7 +61,7 @@ public async Task Run_ReturnsOkResultWithOperationsResultobject_WhenAllOperation int caseId = 232; int materialId = 123; int newWitnessId = 765; - var cmsAuthValues = new CmsAuthValues("valid cookies", "valid token", Guid.NewGuid()); + var cmsAuthValues = new CmsAuthValues("valid cookies", Guid.NewGuid()); var transactionId = Guid.NewGuid(); var reclassifyCaseMaterialRequest = CreateMockReclassifyToOtherRequest(); @@ -132,7 +132,7 @@ public async Task Run_ReturnsMultStatusResultWithOperationsResultobject_WhenSome int caseId = 232; int materialId = 123; int newWitnessId = 765; - var cmsAuthValues = new CmsAuthValues("valid cookies", "valid token", Guid.NewGuid()); + var cmsAuthValues = new CmsAuthValues("valid cookies", Guid.NewGuid()); var transactionId = Guid.NewGuid(); var reclassifyCaseMaterialRequest = CreateMockReclassifyToOtherRequest(); @@ -205,7 +205,7 @@ public async Task Run_ReturnsUnprocessableEntityWithOperationsObjectResult_WhenA int caseId = 232; int materialId = 123; int newWitnessId = 765; - var cmsAuthValues = new CmsAuthValues("valid cookies", "valid token", Guid.NewGuid()); + var cmsAuthValues = new CmsAuthValues("valid cookies", Guid.NewGuid()); var transactionId = Guid.NewGuid(); var reclassifyCaseMaterialRequest = CreateMockReclassifyToOtherRequest(); @@ -278,7 +278,7 @@ public async Task ReturnsUnprocessableEntityError_WhenInvalidOperationExceptionI int caseId = 232; int materialId = 123; int newWitnessId = 765; - var cmsAuthValues = new CmsAuthValues("valid cookies", "valid token", Guid.NewGuid()); + var cmsAuthValues = new CmsAuthValues("valid cookies", Guid.NewGuid()); var transactionId = Guid.NewGuid(); var reclassifyCaseMaterialRequest = CreateMockReclassifyToOtherRequest(); @@ -345,7 +345,7 @@ public async Task Run_ReturnsUnauthorizedError_WhenUnauthorizedAccessExceptionIs int caseId = 232; int materialId = 123; int newWitnessId = 765; - var cmsAuthValues = new CmsAuthValues("valid cookies", "valid token", Guid.NewGuid()); + var cmsAuthValues = new CmsAuthValues("valid cookies", Guid.NewGuid()); var transactionId = Guid.NewGuid(); var reclassifyCaseMaterialRequest = CreateMockReclassifyToOtherRequest(); From 56be86e9c7b34c55144e6ab4a1e706f1e8eba8be Mon Sep 17 00:00:00 2001 From: Kesh Ramduny Date: Mon, 29 Jun 2026 22:43:31 +0100 Subject: [PATCH 3/5] handle null cookies from unit tests --- .../HouseKeeping/DiscardMaterialTests.cs | 28 +++++++++---------- polaris-gateway/Functions/BaseFunction.cs | 5 ++++ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/polaris-gateway.tests/Functions/HouseKeeping/DiscardMaterialTests.cs b/polaris-gateway.tests/Functions/HouseKeeping/DiscardMaterialTests.cs index cf2664324..9aaa6674e 100644 --- a/polaris-gateway.tests/Functions/HouseKeeping/DiscardMaterialTests.cs +++ b/polaris-gateway.tests/Functions/HouseKeeping/DiscardMaterialTests.cs @@ -4,23 +4,23 @@ namespace PolarisGateway.Tests.Functions.HouseKeeping; -using System.Threading.Tasks; +using Common.Constants; +using Common.Dto.Request; +using Common.Dto.Request.HouseKeeping; +using Common.Dto.Response.HouseKeeping; using Cps.Fct.Hk.Ui.Interfaces; +using Cps.Fct.Hk.Ui.Services.Tests.TestUtilities; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Moq; -using Xunit; -using Cps.Fct.Hk.Ui.Services.Tests.TestUtilities; using Microsoft.Extensions.Logging; -using System.Text.Json; -using System.Text; +using Moq; using PolarisGateway.Functions.HouseKeeping; -using Common.Dto.Request.HouseKeeping; using System; using System.IO; -using Common.Dto.Response.HouseKeeping; -using Common.Dto.Request; -using Common.Constants; +using System.Text; +using System.Text.Json; +using System.Threading.Tasks; +using Xunit; /// /// Unit tests for the function. @@ -38,8 +38,8 @@ public class DiscardMaterialTests public DiscardMaterialTests() { this.mockLogger = new TestLogger(); - this.mockCommunicationService = new Mock(); - + this.mockCommunicationService = new Mock(); + this.discardMaterial = new DiscardMaterial( this.mockLogger, this.mockCommunicationService.Object); @@ -163,8 +163,8 @@ public async Task Run_ReturnsUnprocessableEntityError_WhenInvalidOperationExcept // Assert ObjectResult objectResult = Assert.IsType(result); Assert.Equal(StatusCodes.Status422UnprocessableEntity, objectResult.StatusCode); - Assert.Equal("Material with Id [456] has not been found to discard.", objectResult.Value.ToString()); - + Assert.Equal("Material with Id [456] has not been found to discard.", objectResult.Value.ToString()); + Assert.Contains(this.mockLogger.Logs, log => log.LogLevel == LogLevel.Information && log.Message != null && log.Message.Contains($"{LoggingConstants.HskUiLogPrefix} DiscardMaterial function processed a request.")); diff --git a/polaris-gateway/Functions/BaseFunction.cs b/polaris-gateway/Functions/BaseFunction.cs index 8de219f7f..a00a37808 100644 --- a/polaris-gateway/Functions/BaseFunction.cs +++ b/polaris-gateway/Functions/BaseFunction.cs @@ -28,6 +28,11 @@ protected static string EstablishCmsAuthValues(HttpRequest req) protected CmsAuthValues BuildCmsAuthValues(HttpRequest req) { + if (req?.Cookies is null) + { + return null; + } + var cmsAuthValues = EstablishCmsAuthValues(req); var correlation = EstablishCorrelation(req); From d07216008e2dac62fc1f8193bf95019c07a3ca35 Mon Sep 17 00:00:00 2001 From: Kesh Ramduny Date: Mon, 29 Jun 2026 22:58:33 +0100 Subject: [PATCH 4/5] Make BuildCmsAuthValues static method --- polaris-gateway/Functions/BaseFunction.cs | 2 +- polaris-gateway/Functions/HouseKeeping/BulkSetUnused.cs | 2 +- polaris-gateway/Functions/HouseKeeping/DiscardMaterial.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetCaseDefendants.cs | 2 +- .../Functions/HouseKeeping/GetCaseExhibitProducers.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetCaseHistoryEvent.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetCaseInfo.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetCaseLockInfo.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetCaseMaterials.cs | 2 +- .../Functions/HouseKeeping/GetCaseMaterialsPreview.cs | 2 +- .../Functions/HouseKeeping/GetCaseWitnessStatements.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetInitialReview.cs | 2 +- .../Functions/HouseKeeping/GetInitialReviewByHistoryId.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetMaterialDocuments.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetOffenceChargeById.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetPCDRequestByPcdId.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetPCDRequestCore.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetPcdReview.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetPcdReviewCore.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetPcdReviewDetails.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetPreChargeDecision.cs | 2 +- .../Functions/HouseKeeping/GetPreChargeDecisionByHistoryId.cs | 2 +- polaris-gateway/Functions/HouseKeeping/RenameMaterial.cs | 2 +- polaris-gateway/Functions/HouseKeeping/SetMaterialReadStatus.cs | 2 +- polaris-gateway/Functions/HouseKeeping/UmaReclassify.cs | 2 +- polaris-gateway/Functions/HouseKeeping/UpdateExhibit.cs | 2 +- polaris-gateway/Functions/HouseKeeping/UpdateStatement.cs | 2 +- 27 files changed, 27 insertions(+), 27 deletions(-) diff --git a/polaris-gateway/Functions/BaseFunction.cs b/polaris-gateway/Functions/BaseFunction.cs index a00a37808..341049daf 100644 --- a/polaris-gateway/Functions/BaseFunction.cs +++ b/polaris-gateway/Functions/BaseFunction.cs @@ -26,7 +26,7 @@ protected static string EstablishCmsAuthValues(HttpRequest req) return cmsAuthValues; } - protected CmsAuthValues BuildCmsAuthValues(HttpRequest req) + protected static CmsAuthValues BuildCmsAuthValues(HttpRequest req) { if (req?.Cookies is null) { diff --git a/polaris-gateway/Functions/HouseKeeping/BulkSetUnused.cs b/polaris-gateway/Functions/HouseKeeping/BulkSetUnused.cs index fdfaabe59..0d4e2586d 100644 --- a/polaris-gateway/Functions/HouseKeeping/BulkSetUnused.cs +++ b/polaris-gateway/Functions/HouseKeeping/BulkSetUnused.cs @@ -66,7 +66,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = this.BuildCmsAuthValues(req); + var cmsAuthValues = BuildCmsAuthValues(req); // Deserialize the request body into IReadOnlyCollection string requestBody = await new StreamReader(req.Body).ReadToEndAsync().ConfigureAwait(true); diff --git a/polaris-gateway/Functions/HouseKeeping/DiscardMaterial.cs b/polaris-gateway/Functions/HouseKeeping/DiscardMaterial.cs index 3b7df567a..36f52729a 100644 --- a/polaris-gateway/Functions/HouseKeeping/DiscardMaterial.cs +++ b/polaris-gateway/Functions/HouseKeeping/DiscardMaterial.cs @@ -70,7 +70,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = this.BuildCmsAuthValues(request); + var cmsAuthValues = BuildCmsAuthValues(request); string requestBody = await new StreamReader(request.Body).ReadToEndAsync().ConfigureAwait(false); diff --git a/polaris-gateway/Functions/HouseKeeping/GetCaseDefendants.cs b/polaris-gateway/Functions/HouseKeeping/GetCaseDefendants.cs index dc8617b0a..919a2571b 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetCaseDefendants.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetCaseDefendants.cs @@ -64,7 +64,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = this.BuildCmsAuthValues(request); + var cmsAuthValues = BuildCmsAuthValues(request); DefendantsResponse? caseDefendants; try diff --git a/polaris-gateway/Functions/HouseKeeping/GetCaseExhibitProducers.cs b/polaris-gateway/Functions/HouseKeeping/GetCaseExhibitProducers.cs index 8d7d3598b..c57d0f71d 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetCaseExhibitProducers.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetCaseExhibitProducers.cs @@ -64,7 +64,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = this.BuildCmsAuthValues(request); + var cmsAuthValues = BuildCmsAuthValues(request); var exhibitTask = this.communicationService.GetExhibitProducersAsync(caseId, cmsAuthValues); var witnessTask = this.witnessService.GetCaseWitnessesAsync(caseId, cmsAuthValues); diff --git a/polaris-gateway/Functions/HouseKeeping/GetCaseHistoryEvent.cs b/polaris-gateway/Functions/HouseKeeping/GetCaseHistoryEvent.cs index 046164c43..19bd574be 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetCaseHistoryEvent.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetCaseHistoryEvent.cs @@ -66,7 +66,7 @@ public async Task Run( } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = this.BuildCmsAuthValues(request); + var cmsAuthValues = BuildCmsAuthValues(request); var result = await this.communicationService.GetHistoryEventsAsync(caseId, cmsAuthValues).ConfigureAwait(true); diff --git a/polaris-gateway/Functions/HouseKeeping/GetCaseInfo.cs b/polaris-gateway/Functions/HouseKeeping/GetCaseInfo.cs index fb3b0722b..faa5d95aa 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetCaseInfo.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetCaseInfo.cs @@ -61,7 +61,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = this.BuildCmsAuthValues(req); + var cmsAuthValues = BuildCmsAuthValues(req); CaseSummaryResponse caseSummary; try diff --git a/polaris-gateway/Functions/HouseKeeping/GetCaseLockInfo.cs b/polaris-gateway/Functions/HouseKeeping/GetCaseLockInfo.cs index ff0160774..da2815ae2 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetCaseLockInfo.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetCaseLockInfo.cs @@ -63,7 +63,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = this.BuildCmsAuthValues(req); + var cmsAuthValues = BuildCmsAuthValues(req); CaseLockedStatusResult caseLockSummary; try diff --git a/polaris-gateway/Functions/HouseKeeping/GetCaseMaterials.cs b/polaris-gateway/Functions/HouseKeeping/GetCaseMaterials.cs index 391eaf675..99a547931 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetCaseMaterials.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetCaseMaterials.cs @@ -70,7 +70,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, this.logger.LogInformation($"{LoggingConstants.HskUiLogPrefix} GetCaseMaterials function processed a request."); // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = this.BuildCmsAuthValues(req); + var cmsAuthValues = BuildCmsAuthValues(req); // Retrieve case materials var (communications, unusedMaterials, usedStatements, usedExhibits, usedMgForms, usedOtherMaterials, exhibitProducers) = diff --git a/polaris-gateway/Functions/HouseKeeping/GetCaseMaterialsPreview.cs b/polaris-gateway/Functions/HouseKeeping/GetCaseMaterialsPreview.cs index 7c6eed3e1..5a67ef3f5 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetCaseMaterialsPreview.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetCaseMaterialsPreview.cs @@ -75,7 +75,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = this.BuildCmsAuthValues(req); + var cmsAuthValues = BuildCmsAuthValues(req); // Get the material link string link = await this.GetLinkForMaterialAsync(caseId, materialId, cmsAuthValues).ConfigureAwait(true); diff --git a/polaris-gateway/Functions/HouseKeeping/GetCaseWitnessStatements.cs b/polaris-gateway/Functions/HouseKeeping/GetCaseWitnessStatements.cs index d702ee7a3..4c4ca7a8e 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetCaseWitnessStatements.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetCaseWitnessStatements.cs @@ -63,7 +63,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = this.BuildCmsAuthValues(request); + var cmsAuthValues = BuildCmsAuthValues(request); WitnessStatementsResponse? result = await this.witnessService.GetWitnessStatementsAsync(witnessId, cmsAuthValues).ConfigureAwait(false); diff --git a/polaris-gateway/Functions/HouseKeeping/GetInitialReview.cs b/polaris-gateway/Functions/HouseKeeping/GetInitialReview.cs index 77a9ff4ef..f19633ebf 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetInitialReview.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetInitialReview.cs @@ -66,7 +66,7 @@ public async Task Run( } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = this.BuildCmsAuthValues(request); + var cmsAuthValues = BuildCmsAuthValues(request); var result = await this.caseHistoryEventProvider.FirstInitialReviewGetCaseHistoryAsync(caseId, cmsAuthValues).ConfigureAwait(true); diff --git a/polaris-gateway/Functions/HouseKeeping/GetInitialReviewByHistoryId.cs b/polaris-gateway/Functions/HouseKeeping/GetInitialReviewByHistoryId.cs index 4e265cf87..1b3583f79 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetInitialReviewByHistoryId.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetInitialReviewByHistoryId.cs @@ -74,7 +74,7 @@ public async Task Run( } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = this.BuildCmsAuthValues(request); + var cmsAuthValues = BuildCmsAuthValues(request); var result = await this.communicationService.GetInitialReviewByHistoryIdAsync(caseId, historyId, cmsAuthValues, cancellationToken).ConfigureAwait(true); diff --git a/polaris-gateway/Functions/HouseKeeping/GetMaterialDocuments.cs b/polaris-gateway/Functions/HouseKeeping/GetMaterialDocuments.cs index fb8444d38..cdbec1c92 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetMaterialDocuments.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetMaterialDocuments.cs @@ -74,7 +74,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = this.BuildCmsAuthValues(req); + var cmsAuthValues = BuildCmsAuthValues(req); // Get the material link string link = await this.GetLinkForMaterialAsync(caseId, materialId, cmsAuthValues).ConfigureAwait(true); diff --git a/polaris-gateway/Functions/HouseKeeping/GetOffenceChargeById.cs b/polaris-gateway/Functions/HouseKeeping/GetOffenceChargeById.cs index 82e6c382c..4ed96daf6 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetOffenceChargeById.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetOffenceChargeById.cs @@ -77,7 +77,7 @@ public async Task Run( } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = this.BuildCmsAuthValues(request); + var cmsAuthValues = BuildCmsAuthValues(request); var result = await this.communicationService.GetOffenceChargeByHistoryIdAsync(caseId, historyId, cmsAuthValues).ConfigureAwait(true); diff --git a/polaris-gateway/Functions/HouseKeeping/GetPCDRequestByPcdId.cs b/polaris-gateway/Functions/HouseKeeping/GetPCDRequestByPcdId.cs index 371f79ab0..47264306c 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetPCDRequestByPcdId.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetPCDRequestByPcdId.cs @@ -66,7 +66,7 @@ public async Task Run( this.logger.LogInformation($"{LoggingConstants.HskUiLogPrefix} GetPCDRequestByPcdId function processed a request."); // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = this.BuildCmsAuthValues(request); + var cmsAuthValues = BuildCmsAuthValues(request); string requestBody = await new StreamReader(request.Body).ReadToEndAsync().ConfigureAwait(false); diff --git a/polaris-gateway/Functions/HouseKeeping/GetPCDRequestCore.cs b/polaris-gateway/Functions/HouseKeeping/GetPCDRequestCore.cs index 8f3950b7a..ea286bb68 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetPCDRequestCore.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetPCDRequestCore.cs @@ -64,7 +64,7 @@ public async Task Run( var stopwatch = Stopwatch.StartNew(); this.logger.LogInformation($"{LoggingConstants.HskUiLogPrefix} GetPCDRequestCore function processed a request."); - var cmsAuthValues = this.BuildCmsAuthValues(request); + var cmsAuthValues = BuildCmsAuthValues(request); string requestBody = await new StreamReader(request.Body).ReadToEndAsync().ConfigureAwait(false); diff --git a/polaris-gateway/Functions/HouseKeeping/GetPcdReview.cs b/polaris-gateway/Functions/HouseKeeping/GetPcdReview.cs index 245f0f244..e97227eee 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetPcdReview.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetPcdReview.cs @@ -66,7 +66,7 @@ public async Task Run( } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = this.BuildCmsAuthValues(request); + var cmsAuthValues = BuildCmsAuthValues(request); var result = await this.communicationService.GetPcdReview(caseId, cmsAuthValues); diff --git a/polaris-gateway/Functions/HouseKeeping/GetPcdReviewCore.cs b/polaris-gateway/Functions/HouseKeeping/GetPcdReviewCore.cs index 4e1fba8ca..7793f151b 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetPcdReviewCore.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetPcdReviewCore.cs @@ -70,7 +70,7 @@ public async Task Run( } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = this.BuildCmsAuthValues(request); + var cmsAuthValues = BuildCmsAuthValues(request); var result = await this.communicationService.GetPcdReviewCoreAsync(caseId, cmsAuthValues, cancellationToken); diff --git a/polaris-gateway/Functions/HouseKeeping/GetPcdReviewDetails.cs b/polaris-gateway/Functions/HouseKeeping/GetPcdReviewDetails.cs index d4a4f08f3..3ec0e525b 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetPcdReviewDetails.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetPcdReviewDetails.cs @@ -69,7 +69,7 @@ public async Task Run( } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = this.BuildCmsAuthValues(request); + var cmsAuthValues = BuildCmsAuthValues(request); var result = await this.communicationService.GetPcdReviewDetailAsync(caseId, historyId, cmsAuthValues, cancellationToken); diff --git a/polaris-gateway/Functions/HouseKeeping/GetPreChargeDecision.cs b/polaris-gateway/Functions/HouseKeeping/GetPreChargeDecision.cs index a4e1783ae..4d6c4f9a9 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetPreChargeDecision.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetPreChargeDecision.cs @@ -66,7 +66,7 @@ public async Task Run( } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = this.BuildCmsAuthValues(request); + var cmsAuthValues = BuildCmsAuthValues(request); var result = await this.communicationService.GetPreChargeDecisionCaseHistoryEventDetailsAsync(caseId, cmsAuthValues); diff --git a/polaris-gateway/Functions/HouseKeeping/GetPreChargeDecisionByHistoryId.cs b/polaris-gateway/Functions/HouseKeeping/GetPreChargeDecisionByHistoryId.cs index 0e221ae7d..81f87edef 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetPreChargeDecisionByHistoryId.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetPreChargeDecisionByHistoryId.cs @@ -73,7 +73,7 @@ public async Task Run( } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = this.BuildCmsAuthValues(request); + var cmsAuthValues = BuildCmsAuthValues(request); var result = await this.communicationService.GetPreChargeDecisionByHistoryId(caseId,historyId, cmsAuthValues).ConfigureAwait(true); diff --git a/polaris-gateway/Functions/HouseKeeping/RenameMaterial.cs b/polaris-gateway/Functions/HouseKeeping/RenameMaterial.cs index fe9a987a5..48a530282 100644 --- a/polaris-gateway/Functions/HouseKeeping/RenameMaterial.cs +++ b/polaris-gateway/Functions/HouseKeeping/RenameMaterial.cs @@ -72,7 +72,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = this.BuildCmsAuthValues(request); + var cmsAuthValues = BuildCmsAuthValues(request); CaseSummaryResponse caseSummary; diff --git a/polaris-gateway/Functions/HouseKeeping/SetMaterialReadStatus.cs b/polaris-gateway/Functions/HouseKeeping/SetMaterialReadStatus.cs index 922a76981..24d4d9063 100644 --- a/polaris-gateway/Functions/HouseKeeping/SetMaterialReadStatus.cs +++ b/polaris-gateway/Functions/HouseKeeping/SetMaterialReadStatus.cs @@ -74,7 +74,7 @@ public async Task Run( } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = this.BuildCmsAuthValues(request); + var cmsAuthValues = BuildCmsAuthValues(request); string requestBody = await new StreamReader(request.Body).ReadToEndAsync().ConfigureAwait(false); diff --git a/polaris-gateway/Functions/HouseKeeping/UmaReclassify.cs b/polaris-gateway/Functions/HouseKeeping/UmaReclassify.cs index e1c8dc52d..39d63d2ad 100644 --- a/polaris-gateway/Functions/HouseKeeping/UmaReclassify.cs +++ b/polaris-gateway/Functions/HouseKeeping/UmaReclassify.cs @@ -73,7 +73,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = this.BuildCmsAuthValues(req); + var cmsAuthValues = BuildCmsAuthValues(req); // Get the communications IReadOnlyCollection communications = null; diff --git a/polaris-gateway/Functions/HouseKeeping/UpdateExhibit.cs b/polaris-gateway/Functions/HouseKeeping/UpdateExhibit.cs index faf0527bd..a29a2affa 100644 --- a/polaris-gateway/Functions/HouseKeeping/UpdateExhibit.cs +++ b/polaris-gateway/Functions/HouseKeeping/UpdateExhibit.cs @@ -73,7 +73,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = this.BuildCmsAuthValues(request); + var cmsAuthValues = BuildCmsAuthValues(request); string requestBody = await new StreamReader(request.Body).ReadToEndAsync().ConfigureAwait(false); diff --git a/polaris-gateway/Functions/HouseKeeping/UpdateStatement.cs b/polaris-gateway/Functions/HouseKeeping/UpdateStatement.cs index 67c963d81..6dad5cfd3 100644 --- a/polaris-gateway/Functions/HouseKeeping/UpdateStatement.cs +++ b/polaris-gateway/Functions/HouseKeeping/UpdateStatement.cs @@ -72,7 +72,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = this.BuildCmsAuthValues(request); + var cmsAuthValues = BuildCmsAuthValues(request); string requestBody = await new StreamReader(request.Body).ReadToEndAsync().ConfigureAwait(false); From f6efc9fc37c1070ea37c6dafc152b9f20396bf68 Mon Sep 17 00:00:00 2001 From: Kesh Ramduny Date: Mon, 29 Jun 2026 23:34:51 +0100 Subject: [PATCH 5/5] Revert "Make BuildCmsAuthValues static method" This reverts commit d07216008e2dac62fc1f8193bf95019c07a3ca35. --- polaris-gateway/Functions/BaseFunction.cs | 2 +- polaris-gateway/Functions/HouseKeeping/BulkSetUnused.cs | 2 +- polaris-gateway/Functions/HouseKeeping/DiscardMaterial.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetCaseDefendants.cs | 2 +- .../Functions/HouseKeeping/GetCaseExhibitProducers.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetCaseHistoryEvent.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetCaseInfo.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetCaseLockInfo.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetCaseMaterials.cs | 2 +- .../Functions/HouseKeeping/GetCaseMaterialsPreview.cs | 2 +- .../Functions/HouseKeeping/GetCaseWitnessStatements.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetInitialReview.cs | 2 +- .../Functions/HouseKeeping/GetInitialReviewByHistoryId.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetMaterialDocuments.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetOffenceChargeById.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetPCDRequestByPcdId.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetPCDRequestCore.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetPcdReview.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetPcdReviewCore.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetPcdReviewDetails.cs | 2 +- polaris-gateway/Functions/HouseKeeping/GetPreChargeDecision.cs | 2 +- .../Functions/HouseKeeping/GetPreChargeDecisionByHistoryId.cs | 2 +- polaris-gateway/Functions/HouseKeeping/RenameMaterial.cs | 2 +- polaris-gateway/Functions/HouseKeeping/SetMaterialReadStatus.cs | 2 +- polaris-gateway/Functions/HouseKeeping/UmaReclassify.cs | 2 +- polaris-gateway/Functions/HouseKeeping/UpdateExhibit.cs | 2 +- polaris-gateway/Functions/HouseKeeping/UpdateStatement.cs | 2 +- 27 files changed, 27 insertions(+), 27 deletions(-) diff --git a/polaris-gateway/Functions/BaseFunction.cs b/polaris-gateway/Functions/BaseFunction.cs index 341049daf..a00a37808 100644 --- a/polaris-gateway/Functions/BaseFunction.cs +++ b/polaris-gateway/Functions/BaseFunction.cs @@ -26,7 +26,7 @@ protected static string EstablishCmsAuthValues(HttpRequest req) return cmsAuthValues; } - protected static CmsAuthValues BuildCmsAuthValues(HttpRequest req) + protected CmsAuthValues BuildCmsAuthValues(HttpRequest req) { if (req?.Cookies is null) { diff --git a/polaris-gateway/Functions/HouseKeeping/BulkSetUnused.cs b/polaris-gateway/Functions/HouseKeeping/BulkSetUnused.cs index 0d4e2586d..fdfaabe59 100644 --- a/polaris-gateway/Functions/HouseKeeping/BulkSetUnused.cs +++ b/polaris-gateway/Functions/HouseKeeping/BulkSetUnused.cs @@ -66,7 +66,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = BuildCmsAuthValues(req); + var cmsAuthValues = this.BuildCmsAuthValues(req); // Deserialize the request body into IReadOnlyCollection string requestBody = await new StreamReader(req.Body).ReadToEndAsync().ConfigureAwait(true); diff --git a/polaris-gateway/Functions/HouseKeeping/DiscardMaterial.cs b/polaris-gateway/Functions/HouseKeeping/DiscardMaterial.cs index 36f52729a..3b7df567a 100644 --- a/polaris-gateway/Functions/HouseKeeping/DiscardMaterial.cs +++ b/polaris-gateway/Functions/HouseKeeping/DiscardMaterial.cs @@ -70,7 +70,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = BuildCmsAuthValues(request); + var cmsAuthValues = this.BuildCmsAuthValues(request); string requestBody = await new StreamReader(request.Body).ReadToEndAsync().ConfigureAwait(false); diff --git a/polaris-gateway/Functions/HouseKeeping/GetCaseDefendants.cs b/polaris-gateway/Functions/HouseKeeping/GetCaseDefendants.cs index 919a2571b..dc8617b0a 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetCaseDefendants.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetCaseDefendants.cs @@ -64,7 +64,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = BuildCmsAuthValues(request); + var cmsAuthValues = this.BuildCmsAuthValues(request); DefendantsResponse? caseDefendants; try diff --git a/polaris-gateway/Functions/HouseKeeping/GetCaseExhibitProducers.cs b/polaris-gateway/Functions/HouseKeeping/GetCaseExhibitProducers.cs index c57d0f71d..8d7d3598b 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetCaseExhibitProducers.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetCaseExhibitProducers.cs @@ -64,7 +64,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = BuildCmsAuthValues(request); + var cmsAuthValues = this.BuildCmsAuthValues(request); var exhibitTask = this.communicationService.GetExhibitProducersAsync(caseId, cmsAuthValues); var witnessTask = this.witnessService.GetCaseWitnessesAsync(caseId, cmsAuthValues); diff --git a/polaris-gateway/Functions/HouseKeeping/GetCaseHistoryEvent.cs b/polaris-gateway/Functions/HouseKeeping/GetCaseHistoryEvent.cs index 19bd574be..046164c43 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetCaseHistoryEvent.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetCaseHistoryEvent.cs @@ -66,7 +66,7 @@ public async Task Run( } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = BuildCmsAuthValues(request); + var cmsAuthValues = this.BuildCmsAuthValues(request); var result = await this.communicationService.GetHistoryEventsAsync(caseId, cmsAuthValues).ConfigureAwait(true); diff --git a/polaris-gateway/Functions/HouseKeeping/GetCaseInfo.cs b/polaris-gateway/Functions/HouseKeeping/GetCaseInfo.cs index faa5d95aa..fb3b0722b 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetCaseInfo.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetCaseInfo.cs @@ -61,7 +61,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = BuildCmsAuthValues(req); + var cmsAuthValues = this.BuildCmsAuthValues(req); CaseSummaryResponse caseSummary; try diff --git a/polaris-gateway/Functions/HouseKeeping/GetCaseLockInfo.cs b/polaris-gateway/Functions/HouseKeeping/GetCaseLockInfo.cs index da2815ae2..ff0160774 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetCaseLockInfo.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetCaseLockInfo.cs @@ -63,7 +63,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = BuildCmsAuthValues(req); + var cmsAuthValues = this.BuildCmsAuthValues(req); CaseLockedStatusResult caseLockSummary; try diff --git a/polaris-gateway/Functions/HouseKeeping/GetCaseMaterials.cs b/polaris-gateway/Functions/HouseKeeping/GetCaseMaterials.cs index 99a547931..391eaf675 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetCaseMaterials.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetCaseMaterials.cs @@ -70,7 +70,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, this.logger.LogInformation($"{LoggingConstants.HskUiLogPrefix} GetCaseMaterials function processed a request."); // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = BuildCmsAuthValues(req); + var cmsAuthValues = this.BuildCmsAuthValues(req); // Retrieve case materials var (communications, unusedMaterials, usedStatements, usedExhibits, usedMgForms, usedOtherMaterials, exhibitProducers) = diff --git a/polaris-gateway/Functions/HouseKeeping/GetCaseMaterialsPreview.cs b/polaris-gateway/Functions/HouseKeeping/GetCaseMaterialsPreview.cs index 5a67ef3f5..7c6eed3e1 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetCaseMaterialsPreview.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetCaseMaterialsPreview.cs @@ -75,7 +75,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = BuildCmsAuthValues(req); + var cmsAuthValues = this.BuildCmsAuthValues(req); // Get the material link string link = await this.GetLinkForMaterialAsync(caseId, materialId, cmsAuthValues).ConfigureAwait(true); diff --git a/polaris-gateway/Functions/HouseKeeping/GetCaseWitnessStatements.cs b/polaris-gateway/Functions/HouseKeeping/GetCaseWitnessStatements.cs index 4c4ca7a8e..d702ee7a3 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetCaseWitnessStatements.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetCaseWitnessStatements.cs @@ -63,7 +63,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = BuildCmsAuthValues(request); + var cmsAuthValues = this.BuildCmsAuthValues(request); WitnessStatementsResponse? result = await this.witnessService.GetWitnessStatementsAsync(witnessId, cmsAuthValues).ConfigureAwait(false); diff --git a/polaris-gateway/Functions/HouseKeeping/GetInitialReview.cs b/polaris-gateway/Functions/HouseKeeping/GetInitialReview.cs index f19633ebf..77a9ff4ef 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetInitialReview.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetInitialReview.cs @@ -66,7 +66,7 @@ public async Task Run( } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = BuildCmsAuthValues(request); + var cmsAuthValues = this.BuildCmsAuthValues(request); var result = await this.caseHistoryEventProvider.FirstInitialReviewGetCaseHistoryAsync(caseId, cmsAuthValues).ConfigureAwait(true); diff --git a/polaris-gateway/Functions/HouseKeeping/GetInitialReviewByHistoryId.cs b/polaris-gateway/Functions/HouseKeeping/GetInitialReviewByHistoryId.cs index 1b3583f79..4e265cf87 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetInitialReviewByHistoryId.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetInitialReviewByHistoryId.cs @@ -74,7 +74,7 @@ public async Task Run( } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = BuildCmsAuthValues(request); + var cmsAuthValues = this.BuildCmsAuthValues(request); var result = await this.communicationService.GetInitialReviewByHistoryIdAsync(caseId, historyId, cmsAuthValues, cancellationToken).ConfigureAwait(true); diff --git a/polaris-gateway/Functions/HouseKeeping/GetMaterialDocuments.cs b/polaris-gateway/Functions/HouseKeeping/GetMaterialDocuments.cs index cdbec1c92..fb8444d38 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetMaterialDocuments.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetMaterialDocuments.cs @@ -74,7 +74,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = BuildCmsAuthValues(req); + var cmsAuthValues = this.BuildCmsAuthValues(req); // Get the material link string link = await this.GetLinkForMaterialAsync(caseId, materialId, cmsAuthValues).ConfigureAwait(true); diff --git a/polaris-gateway/Functions/HouseKeeping/GetOffenceChargeById.cs b/polaris-gateway/Functions/HouseKeeping/GetOffenceChargeById.cs index 4ed96daf6..82e6c382c 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetOffenceChargeById.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetOffenceChargeById.cs @@ -77,7 +77,7 @@ public async Task Run( } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = BuildCmsAuthValues(request); + var cmsAuthValues = this.BuildCmsAuthValues(request); var result = await this.communicationService.GetOffenceChargeByHistoryIdAsync(caseId, historyId, cmsAuthValues).ConfigureAwait(true); diff --git a/polaris-gateway/Functions/HouseKeeping/GetPCDRequestByPcdId.cs b/polaris-gateway/Functions/HouseKeeping/GetPCDRequestByPcdId.cs index 47264306c..371f79ab0 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetPCDRequestByPcdId.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetPCDRequestByPcdId.cs @@ -66,7 +66,7 @@ public async Task Run( this.logger.LogInformation($"{LoggingConstants.HskUiLogPrefix} GetPCDRequestByPcdId function processed a request."); // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = BuildCmsAuthValues(request); + var cmsAuthValues = this.BuildCmsAuthValues(request); string requestBody = await new StreamReader(request.Body).ReadToEndAsync().ConfigureAwait(false); diff --git a/polaris-gateway/Functions/HouseKeeping/GetPCDRequestCore.cs b/polaris-gateway/Functions/HouseKeeping/GetPCDRequestCore.cs index ea286bb68..8f3950b7a 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetPCDRequestCore.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetPCDRequestCore.cs @@ -64,7 +64,7 @@ public async Task Run( var stopwatch = Stopwatch.StartNew(); this.logger.LogInformation($"{LoggingConstants.HskUiLogPrefix} GetPCDRequestCore function processed a request."); - var cmsAuthValues = BuildCmsAuthValues(request); + var cmsAuthValues = this.BuildCmsAuthValues(request); string requestBody = await new StreamReader(request.Body).ReadToEndAsync().ConfigureAwait(false); diff --git a/polaris-gateway/Functions/HouseKeeping/GetPcdReview.cs b/polaris-gateway/Functions/HouseKeeping/GetPcdReview.cs index e97227eee..245f0f244 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetPcdReview.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetPcdReview.cs @@ -66,7 +66,7 @@ public async Task Run( } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = BuildCmsAuthValues(request); + var cmsAuthValues = this.BuildCmsAuthValues(request); var result = await this.communicationService.GetPcdReview(caseId, cmsAuthValues); diff --git a/polaris-gateway/Functions/HouseKeeping/GetPcdReviewCore.cs b/polaris-gateway/Functions/HouseKeeping/GetPcdReviewCore.cs index 7793f151b..4e1fba8ca 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetPcdReviewCore.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetPcdReviewCore.cs @@ -70,7 +70,7 @@ public async Task Run( } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = BuildCmsAuthValues(request); + var cmsAuthValues = this.BuildCmsAuthValues(request); var result = await this.communicationService.GetPcdReviewCoreAsync(caseId, cmsAuthValues, cancellationToken); diff --git a/polaris-gateway/Functions/HouseKeeping/GetPcdReviewDetails.cs b/polaris-gateway/Functions/HouseKeeping/GetPcdReviewDetails.cs index 3ec0e525b..d4a4f08f3 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetPcdReviewDetails.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetPcdReviewDetails.cs @@ -69,7 +69,7 @@ public async Task Run( } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = BuildCmsAuthValues(request); + var cmsAuthValues = this.BuildCmsAuthValues(request); var result = await this.communicationService.GetPcdReviewDetailAsync(caseId, historyId, cmsAuthValues, cancellationToken); diff --git a/polaris-gateway/Functions/HouseKeeping/GetPreChargeDecision.cs b/polaris-gateway/Functions/HouseKeeping/GetPreChargeDecision.cs index 4d6c4f9a9..a4e1783ae 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetPreChargeDecision.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetPreChargeDecision.cs @@ -66,7 +66,7 @@ public async Task Run( } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = BuildCmsAuthValues(request); + var cmsAuthValues = this.BuildCmsAuthValues(request); var result = await this.communicationService.GetPreChargeDecisionCaseHistoryEventDetailsAsync(caseId, cmsAuthValues); diff --git a/polaris-gateway/Functions/HouseKeeping/GetPreChargeDecisionByHistoryId.cs b/polaris-gateway/Functions/HouseKeeping/GetPreChargeDecisionByHistoryId.cs index 81f87edef..0e221ae7d 100644 --- a/polaris-gateway/Functions/HouseKeeping/GetPreChargeDecisionByHistoryId.cs +++ b/polaris-gateway/Functions/HouseKeeping/GetPreChargeDecisionByHistoryId.cs @@ -73,7 +73,7 @@ public async Task Run( } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = BuildCmsAuthValues(request); + var cmsAuthValues = this.BuildCmsAuthValues(request); var result = await this.communicationService.GetPreChargeDecisionByHistoryId(caseId,historyId, cmsAuthValues).ConfigureAwait(true); diff --git a/polaris-gateway/Functions/HouseKeeping/RenameMaterial.cs b/polaris-gateway/Functions/HouseKeeping/RenameMaterial.cs index 48a530282..fe9a987a5 100644 --- a/polaris-gateway/Functions/HouseKeeping/RenameMaterial.cs +++ b/polaris-gateway/Functions/HouseKeeping/RenameMaterial.cs @@ -72,7 +72,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = BuildCmsAuthValues(request); + var cmsAuthValues = this.BuildCmsAuthValues(request); CaseSummaryResponse caseSummary; diff --git a/polaris-gateway/Functions/HouseKeeping/SetMaterialReadStatus.cs b/polaris-gateway/Functions/HouseKeeping/SetMaterialReadStatus.cs index 24d4d9063..922a76981 100644 --- a/polaris-gateway/Functions/HouseKeeping/SetMaterialReadStatus.cs +++ b/polaris-gateway/Functions/HouseKeeping/SetMaterialReadStatus.cs @@ -74,7 +74,7 @@ public async Task Run( } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = BuildCmsAuthValues(request); + var cmsAuthValues = this.BuildCmsAuthValues(request); string requestBody = await new StreamReader(request.Body).ReadToEndAsync().ConfigureAwait(false); diff --git a/polaris-gateway/Functions/HouseKeeping/UmaReclassify.cs b/polaris-gateway/Functions/HouseKeeping/UmaReclassify.cs index 39d63d2ad..e1c8dc52d 100644 --- a/polaris-gateway/Functions/HouseKeeping/UmaReclassify.cs +++ b/polaris-gateway/Functions/HouseKeeping/UmaReclassify.cs @@ -73,7 +73,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = BuildCmsAuthValues(req); + var cmsAuthValues = this.BuildCmsAuthValues(req); // Get the communications IReadOnlyCollection communications = null; diff --git a/polaris-gateway/Functions/HouseKeeping/UpdateExhibit.cs b/polaris-gateway/Functions/HouseKeeping/UpdateExhibit.cs index a29a2affa..faf0527bd 100644 --- a/polaris-gateway/Functions/HouseKeeping/UpdateExhibit.cs +++ b/polaris-gateway/Functions/HouseKeeping/UpdateExhibit.cs @@ -73,7 +73,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = BuildCmsAuthValues(request); + var cmsAuthValues = this.BuildCmsAuthValues(request); string requestBody = await new StreamReader(request.Body).ReadToEndAsync().ConfigureAwait(false); diff --git a/polaris-gateway/Functions/HouseKeeping/UpdateStatement.cs b/polaris-gateway/Functions/HouseKeeping/UpdateStatement.cs index 6dad5cfd3..67c963d81 100644 --- a/polaris-gateway/Functions/HouseKeeping/UpdateStatement.cs +++ b/polaris-gateway/Functions/HouseKeeping/UpdateStatement.cs @@ -72,7 +72,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, } // Build CMS auth values from cookie extracted from the request - var cmsAuthValues = BuildCmsAuthValues(request); + var cmsAuthValues = this.BuildCmsAuthValues(request); string requestBody = await new StreamReader(request.Body).ReadToEndAsync().ConfigureAwait(false);