Skip to content

Commit 490d054

Browse files
authored
Merge pull request #1238 from TechnologyEnhancedLearning/TD-5502-CatalogeOwn
TD-5502-Replace Web API layer with Open API Layer -Admin Operations-Update Cataloge Owner Issue Resolved
2 parents acacd84 + 8d0f9a7 commit 490d054

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/ICatalogueService.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,5 +238,13 @@ public interface ICatalogueService
238238
/// <returns>The allcatalogue result based on letters.</returns>
239239
Task<AllCatalogueResponseViewModel> GetAllCataloguesAsync(string filterChar, int userId);
240240

241+
/// <summary>
242+
/// The UpdateCatalogueOwnerAsync.
243+
/// </summary>
244+
/// <param name="userId">The userId.</param>
245+
/// <param name="catalogueOwner">The catalogue owner.</param>
246+
/// <returns>The catalogue view model.</returns>
247+
Task<LearningHubValidationResult> UpdateCatalogueOwnerAsync(int userId, CatalogueOwnerViewModel catalogueOwner);
248+
241249
}
242250
}

OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/CatalogueService.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,18 @@ private LearningHubValidationResult ValidateEditAsync(CatalogueViewModel model)
11901190
IsValid = !details.Any(),
11911191
};
11921192
}
1193+
/// <summary>
1194+
/// The UpdateCatalogueOwnerAsync.
1195+
/// </summary>
1196+
/// <param name="userId">The userId.</param>
1197+
/// <param name="catalogueOwner">The catalogue owner.</param>
1198+
/// <returns>The catalogue view model.</returns>
1199+
public async Task<LearningHubValidationResult> UpdateCatalogueOwnerAsync(int userId, CatalogueOwnerViewModel catalogueOwner)
1200+
{
1201+
await this.catalogueNodeVersionRepository.UpdateCatalogueOwnerAsync(userId, catalogueOwner);
1202+
1203+
return new LearningHubValidationResult(true);
1204+
}
11931205

11941206
}
11951207
}

OpenAPI/LearningHub.Nhs.OpenApi/Controllers/CatalogueController.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,5 +374,25 @@ public async Task<IActionResult> AcceptAccessRequest(int accessRequestId)
374374
return this.Ok(await this.catalogueService.AcceptAccessAsync(this.CurrentUserId.GetValueOrDefault(), accessRequestId));
375375
}
376376

377+
/// <summary>
378+
/// The UpdateCatalogueOwner.
379+
/// </summary>
380+
/// <param name="viewModel">The catalogue owner.</param>
381+
/// <returns>The updated catalogue owner.</returns>
382+
[HttpPut]
383+
[Route("UpdateCatalogueOwner")]
384+
public async Task<IActionResult> UpdateCatalogueOwner(CatalogueOwnerViewModel viewModel)
385+
{
386+
try
387+
{
388+
var vr = await this.catalogueService.UpdateCatalogueOwnerAsync(this.CurrentUserId.GetValueOrDefault(), viewModel);
389+
return this.Ok(new ApiResponse(true, vr));
390+
}
391+
catch (Exception ex)
392+
{
393+
return this.Ok(new ApiResponse(false, new LearningHubValidationResult(false, ex.Message)));
394+
}
395+
}
396+
377397
}
378398
}

0 commit comments

Comments
 (0)