< Summary

Information
Class: Chronicis.Api.Controllers.ArticleExternalLinksController
Assembly: Chronicis.Api
File(s): /home/runner/work/chronicis/chronicis/src/Chronicis.Api/Controllers/ArticleExternalLinksController.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 14
Coverable lines: 14
Total lines: 49
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
GetExternalLinks()100%210%

File(s)

/home/runner/work/chronicis/chronicis/src/Chronicis.Api/Controllers/ArticleExternalLinksController.cs

#LineLine coverage
 1using Chronicis.Api.Services.Articles;
 2using Chronicis.Shared.DTOs;
 3using Microsoft.AspNetCore.Authorization;
 4using Microsoft.AspNetCore.Mvc;
 5
 6namespace Chronicis.Api.Controllers;
 7
 8/// <summary>
 9/// API controller for article external links.
 10/// </summary>
 11[ApiController]
 12[Route("articles/{articleId:guid}/external-links")]
 13[Authorize]
 14public class ArticleExternalLinksController : ControllerBase
 15{
 16    private readonly IArticleExternalLinkService _externalLinkService;
 17    private readonly ILogger<ArticleExternalLinksController> _logger;
 18
 019    public ArticleExternalLinksController(
 020        IArticleExternalLinkService externalLinkService,
 021        ILogger<ArticleExternalLinksController> logger)
 22    {
 023        _externalLinkService = externalLinkService;
 024        _logger = logger;
 025    }
 26
 27    /// <summary>
 28    /// Gets all external links for a specific article.
 29    /// </summary>
 30    /// <param name="articleId">The article ID.</param>
 31    /// <returns>List of external links.</returns>
 32    [HttpGet]
 33    [ProducesResponseType(typeof(List<ArticleExternalLinkDto>), StatusCodes.Status200OK)]
 34    public async Task<ActionResult<List<ArticleExternalLinkDto>>> GetExternalLinks(Guid articleId)
 35    {
 36        try
 37        {
 038            var links = await _externalLinkService.GetExternalLinksForArticleAsync(articleId);
 039            return Ok(links);
 40        }
 041        catch (Exception ex)
 42        {
 043            _logger.LogError(ex, "Error retrieving external links for article {ArticleId}", articleId);
 044            return StatusCode(
 045                StatusCodes.Status500InternalServerError,
 046                "An error occurred while retrieving external links.");
 47        }
 048    }
 49}