52 lines
1.4 KiB
C#
52 lines
1.4 KiB
C#
|
using System.Net;
|
|||
|
using Microsoft.AspNetCore.Authorization;
|
|||
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
using Persistence.Models;
|
|||
|
using Persistence.Repositories;
|
|||
|
|
|||
|
namespace Persistence.API.Controllers;
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Работа с системами
|
|||
|
/// </summary>
|
|||
|
[ApiController]
|
|||
|
[Authorize]
|
|||
|
[Route("api/[controller]")]
|
|||
|
public class DataSourceSystemController : ControllerBase
|
|||
|
{
|
|||
|
private readonly IDataSourceSystemRepository dataSourceSystemRepository;
|
|||
|
|
|||
|
public DataSourceSystemController(IDataSourceSystemRepository dataSourceSystemRepository)
|
|||
|
{
|
|||
|
this.dataSourceSystemRepository = dataSourceSystemRepository;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Получить системы
|
|||
|
/// </summary>
|
|||
|
/// <param name="token"></param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpGet]
|
|||
|
public async Task<ActionResult<DataSourceSystemDto>> Get(CancellationToken token)
|
|||
|
{
|
|||
|
var result = await dataSourceSystemRepository.Get(token);
|
|||
|
|
|||
|
return Ok(result);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Добавить систему
|
|||
|
/// </summary>
|
|||
|
/// <param name="dataSourceSystemDto"></param>
|
|||
|
/// <param name="token"></param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpPost]
|
|||
|
[ProducesResponseType(typeof(int), (int)HttpStatusCode.Created)]
|
|||
|
public async Task<IActionResult> Add(DataSourceSystemDto dataSourceSystemDto, CancellationToken token)
|
|||
|
{
|
|||
|
await dataSourceSystemRepository.Add(dataSourceSystemDto, token);
|
|||
|
|
|||
|
return CreatedAtAction(nameof(Add), true);
|
|||
|
}
|
|||
|
}
|