47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
using Backend.Models;
|
|
using Backend.Repositories;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Backend.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("[controller]")]
|
|
public class IssueController : ControllerBase
|
|
{
|
|
private static readonly string[] Summaries = new[]
|
|
{
|
|
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
|
};
|
|
|
|
private readonly ILogger<IssueController> _logger;
|
|
private IIssueRepository _issueRepository;
|
|
|
|
public IssueController(
|
|
ILogger<IssueController> logger,
|
|
IIssueRepository issueRepository)
|
|
{
|
|
_issueRepository = issueRepository;
|
|
_logger = logger;
|
|
}
|
|
|
|
[HttpGet()]
|
|
public IActionResult Get(int id)
|
|
{
|
|
return Ok(_issueRepository.GetIssues());
|
|
}
|
|
|
|
[HttpGet("{id:int}")]
|
|
public IActionResult GetById(int id)
|
|
{
|
|
var result = _issueRepository.GetIssueById(id);
|
|
return (result != null) ? Ok(result) : NotFound();
|
|
}
|
|
|
|
[HttpGet("{project}")]
|
|
public IActionResult GetByProject(string project)
|
|
{
|
|
Issue[]? result = _issueRepository.GetIssuesByProject(project);
|
|
return (result != null) ? Ok(result) : NotFound(new {Title = "ERROR"});
|
|
}
|
|
}
|