mirror of
https://gitlab.com/Hukuta47/cartrix.git
synced 2026-12-05 04:20:55 +00:00
108 lines
4.1 KiB
C#
108 lines
4.1 KiB
C#
using CartriX.Api.Interfaces;
|
|
using CartriX.Api.Services;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace CartriX.Api.Controllers
|
|
{
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class PrinterController : ControllerBase
|
|
{
|
|
private readonly IPrinterService _printerService;
|
|
public PrinterController(IPrinterService printerService)
|
|
{
|
|
_printerService = printerService;
|
|
}
|
|
|
|
//[HttpGet("GetAllList")]
|
|
//public async Task<IActionResult> GetAllList()
|
|
//{
|
|
// var result = await _printerService.GetAllList();
|
|
// var coverted = result.Select(p => p.ToListDto());
|
|
|
|
// return Ok(coverted);
|
|
//}
|
|
|
|
|
|
//[HttpGet("GetAll")]
|
|
//public async Task<IActionResult> GetAll()
|
|
//{
|
|
// Console.WriteLine("Поступил запрос на вывод всего списка принтеров.");
|
|
// var result = await _printerService.GetAll();
|
|
|
|
// Console.WriteLine($"Конверация в {nameof(PrinterDto)}");
|
|
// var coverted = result.Select(p => p.ToDto());
|
|
|
|
// Console.WriteLine("Запрос был сделан успешно, вывод.");
|
|
// return Ok(coverted);
|
|
//}
|
|
|
|
//[HttpGet("GetById/{id}")]
|
|
//public async Task<IActionResult> GetById([FromRoute] int id)
|
|
//{
|
|
// Console.WriteLine("Поступил запрос на вывод всего списка принтеров.");
|
|
// var result = await _printerService.GetById(id);
|
|
// Console.WriteLine("Проверка, есть ли объект в базе данных.");
|
|
// if (result == null)
|
|
// {
|
|
// Console.WriteLine("Проверка пройдена, объект не найден.");
|
|
// return NotFound();
|
|
// }
|
|
// Console.WriteLine($"Проверка пройдена, объект найден, конвертация в {nameof(PrinterDto)}");
|
|
// var convert = result.ToQueryPrinterFromLocationDto();
|
|
// Console.WriteLine("Объект конвертирован для вывода информации");
|
|
// return Ok(convert);
|
|
//}
|
|
|
|
//[HttpPost("AddPrinter")]
|
|
//public async Task<IActionResult> Add([FromBody] CreatePrinterRequestDto requestDto)
|
|
//{
|
|
// await _printerService.AddPrinterAsync(requestDto);
|
|
// return Ok($"Принтер с названием хоста \"{requestDto.hostname}\" был добавлен.");
|
|
//}
|
|
//[HttpGet("PrintTypes")]
|
|
//public async Task<IActionResult> GetAllPrintType() => Ok(await _printerService.GetAllPrintTypes());
|
|
|
|
//[HttpGet("Models")]
|
|
//public async Task<IActionResult> GetAllModels()
|
|
//{
|
|
// var list = await _printerService.GetAllPrinterModel();
|
|
|
|
// var convert = list.Select(m => m.ToDto());
|
|
|
|
// return Ok(convert);
|
|
//}
|
|
|
|
//[HttpGet("GetSNMP/{ipAddressOrHostname}")]
|
|
//public async Task<IActionResult> GetPrinterListParametersFromSNMPAsync([FromRoute] string ipAddressOrHostname)
|
|
//{
|
|
// var result = await _printerService.GetPrinterListParametersFromSNMPAsync(ipAddressOrHostname);
|
|
// return Ok(result);
|
|
//}
|
|
|
|
//[HttpGet("GetSNMPOneData")]
|
|
//public async Task<IActionResult> GetQueryPrintAllDataFromSnmp([FromQuery] string ipAddress, [FromQuery] string Oid)
|
|
//{
|
|
// if (string.IsNullOrEmpty(ipAddress) || string.IsNullOrEmpty(Oid))
|
|
// {
|
|
// return BadRequest("ipAddress и Oid обязательны");
|
|
// }
|
|
// try
|
|
// {
|
|
// var result = await _printerService.GetQueryPrintAllDataFromSnmpAsync(ipAddress, Oid);
|
|
// return Ok(result);
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// return StatusCode(500, $"Ошибка: {ex.Message}");
|
|
// }
|
|
//}
|
|
|
|
|
|
//[HttpPut("ChangeLocation")]
|
|
//public IActionResult setLocationsSNMP() => Ok(_printerService.ChangeLocationDataSNMP());
|
|
|
|
|
|
}
|
|
}
|