Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -238,5 +238,13 @@ public interface ICatalogueService
/// <returns>The allcatalogue result based on letters.</returns>
Task<AllCatalogueResponseViewModel> GetAllCataloguesAsync(string filterChar, int userId);

/// <summary>
/// The UpdateCatalogueOwnerAsync.
/// </summary>
/// <param name="userId">The userId.</param>
/// <param name="catalogueOwner">The catalogue owner.</param>
/// <returns>The catalogue view model.</returns>
Task<LearningHubValidationResult> UpdateCatalogueOwnerAsync(int userId, CatalogueOwnerViewModel catalogueOwner);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,18 @@ private LearningHubValidationResult ValidateEditAsync(CatalogueViewModel model)
IsValid = !details.Any(),
};
}
/// <summary>
/// The UpdateCatalogueOwnerAsync.
/// </summary>
/// <param name="userId">The userId.</param>
/// <param name="catalogueOwner">The catalogue owner.</param>
/// <returns>The catalogue view model.</returns>
public async Task<LearningHubValidationResult> UpdateCatalogueOwnerAsync(int userId, CatalogueOwnerViewModel catalogueOwner)
{
await this.catalogueNodeVersionRepository.UpdateCatalogueOwnerAsync(userId, catalogueOwner);

return new LearningHubValidationResult(true);
}

}
}
20 changes: 20 additions & 0 deletions OpenAPI/LearningHub.Nhs.OpenApi/Controllers/CatalogueController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,5 +374,25 @@ public async Task<IActionResult> AcceptAccessRequest(int accessRequestId)
return this.Ok(await this.catalogueService.AcceptAccessAsync(this.CurrentUserId.GetValueOrDefault(), accessRequestId));
}

/// <summary>
/// The UpdateCatalogueOwner.
/// </summary>
/// <param name="viewModel">The catalogue owner.</param>
/// <returns>The updated catalogue owner.</returns>
[HttpPut]
[Route("UpdateCatalogueOwner")]
public async Task<IActionResult> 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)));
}
}

}
}
Loading