2024-12-12 17:05:47 +05:00
|
|
|
|
using System.Net;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2024-12-16 15:38:46 +05:00
|
|
|
|
using DD.Persistence.Models;
|
|
|
|
|
using DD.Persistence.Repositories;
|
2024-12-12 17:05:47 +05:00
|
|
|
|
|
2024-12-16 15:38:46 +05:00
|
|
|
|
namespace DD.Persistence.API.Controllers;
|
2024-12-12 17:05:47 +05:00
|
|
|
|
|
|
|
|
|
/// <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);
|
|
|
|
|
}
|
|
|
|
|
}
|