2020-10-25 16:11:36 +02:00
|
|
|
using System.Threading.Tasks;
|
2020-10-26 16:20:47 +02:00
|
|
|
using MalwareMultiScan.Api.Data.Models;
|
2020-10-29 12:17:09 +02:00
|
|
|
using MalwareMultiScan.Api.Services.Interfaces;
|
2020-10-25 16:11:36 +02:00
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
namespace MalwareMultiScan.Api.Controllers
|
|
|
|
{
|
2020-10-29 16:09:56 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Scan results controller.
|
|
|
|
/// </summary>
|
2020-10-25 16:11:36 +02:00
|
|
|
[ApiController]
|
2020-10-27 09:57:39 +02:00
|
|
|
[Route("api/results")]
|
2020-10-25 16:11:36 +02:00
|
|
|
[Produces("application/json")]
|
|
|
|
public class ScanResultsController : Controller
|
|
|
|
{
|
2020-10-29 12:17:09 +02:00
|
|
|
private readonly IScanResultService _scanResultService;
|
2020-10-30 11:20:08 +02:00
|
|
|
|
2020-10-29 16:09:56 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Initialize scan results controller.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="scanResultService">Scan result service.</param>
|
2020-10-29 12:17:09 +02:00
|
|
|
public ScanResultsController(IScanResultService scanResultService)
|
2020-10-25 16:11:36 +02:00
|
|
|
{
|
2020-10-26 16:20:47 +02:00
|
|
|
_scanResultService = scanResultService;
|
2020-10-25 16:11:36 +02:00
|
|
|
}
|
2020-10-26 17:06:29 +02:00
|
|
|
|
2020-10-29 16:09:56 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Get scan result by id.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="id">Scan result id.</param>
|
2020-10-26 16:20:47 +02:00
|
|
|
[HttpGet("{id}")]
|
|
|
|
[ProducesResponseType(typeof(ScanResult), StatusCodes.Status200OK)]
|
2020-10-26 21:24:40 +02:00
|
|
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
2020-10-26 16:20:47 +02:00
|
|
|
public async Task<IActionResult> Index(string id)
|
2020-10-25 16:11:36 +02:00
|
|
|
{
|
2020-10-26 16:20:47 +02:00
|
|
|
var scanResult = await _scanResultService.GetScanResult(id);
|
|
|
|
|
|
|
|
if (scanResult == null)
|
|
|
|
return NotFound();
|
|
|
|
|
|
|
|
return Ok(scanResult);
|
2020-10-25 16:11:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|