From 8d0f9a7160e6119a42173b4b7114d34b36444455 Mon Sep 17 00:00:00 2001 From: AnjuJose011 <154979799+AnjuJose011@users.noreply.github.com> Date: Mon, 7 Jul 2025 14:51:18 +0100 Subject: [PATCH] fixes --- .../Services/ICatalogueService.cs | 8 ++++++++ .../Services/CatalogueService.cs | 12 +++++++++++ .../Controllers/CatalogueController.cs | 20 +++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/ICatalogueService.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/ICatalogueService.cs index f763808e..af8ba856 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/ICatalogueService.cs +++ b/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/ICatalogueService.cs @@ -238,5 +238,13 @@ public interface ICatalogueService /// The allcatalogue result based on letters. Task GetAllCataloguesAsync(string filterChar, int userId); + /// + /// The UpdateCatalogueOwnerAsync. + /// + /// The userId. + /// The catalogue owner. + /// The catalogue view model. + Task UpdateCatalogueOwnerAsync(int userId, CatalogueOwnerViewModel catalogueOwner); + } } \ No newline at end of file diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/CatalogueService.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/CatalogueService.cs index 53810f5d..9c78cdb0 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/CatalogueService.cs +++ b/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/CatalogueService.cs @@ -1190,6 +1190,18 @@ private LearningHubValidationResult ValidateEditAsync(CatalogueViewModel model) IsValid = !details.Any(), }; } + /// + /// The UpdateCatalogueOwnerAsync. + /// + /// The userId. + /// The catalogue owner. + /// The catalogue view model. + public async Task UpdateCatalogueOwnerAsync(int userId, CatalogueOwnerViewModel catalogueOwner) + { + await this.catalogueNodeVersionRepository.UpdateCatalogueOwnerAsync(userId, catalogueOwner); + + return new LearningHubValidationResult(true); + } } } diff --git a/OpenAPI/LearningHub.Nhs.OpenApi/Controllers/CatalogueController.cs b/OpenAPI/LearningHub.Nhs.OpenApi/Controllers/CatalogueController.cs index 55b812fd..35686597 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi/Controllers/CatalogueController.cs +++ b/OpenAPI/LearningHub.Nhs.OpenApi/Controllers/CatalogueController.cs @@ -374,5 +374,25 @@ public async Task AcceptAccessRequest(int accessRequestId) return this.Ok(await this.catalogueService.AcceptAccessAsync(this.CurrentUserId.GetValueOrDefault(), accessRequestId)); } + /// + /// The UpdateCatalogueOwner. + /// + /// The catalogue owner. + /// The updated catalogue owner. + [HttpPut] + [Route("UpdateCatalogueOwner")] + public async Task UpdateCatalogueOwner(CatalogueOwnerViewModel viewModel) + { + try + { + var vr = await this.catalogueService.UpdateCatalogueOwnerAsync(this.CurrentUserId.GetValueOrDefault(), viewModel); + return this.Ok(new ApiResponse(true, vr)); + } + catch (Exception ex) + { + return this.Ok(new ApiResponse(false, new LearningHubValidationResult(false, ex.Message))); + } + } + } }