mirror of
https://gitlab.com/Hukuta47/cartrix.git
synced 2026-12-05 12:30:55 +00:00
Крче много чего сдлелал, я похерил коммиты и комментарий соотвествощий
>:(
This commit is contained in:
1 parent
c39880ab68
commit
7a0e7e0801
20 files changed
+417
-48
No files matched your search
@@ -1,5 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using CartriX.Api.Services;
|
||||
using CartriX.Shared.DTOs.Printer;
|
||||
using CartriX.Shared.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace CartriX.Api.Controllers
|
||||
{
|
||||
@@ -8,20 +10,42 @@ namespace CartriX.Api.Controllers
|
||||
public class PrinterController : ControllerBase
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
private readonly PrinterNetworkService _printerNetworkService;
|
||||
|
||||
public PrinterController(AppDbContext context)
|
||||
public PrinterController(AppDbContext context, PrinterNetworkService printerNetworkService)
|
||||
{
|
||||
_context = context;
|
||||
_printerNetworkService = printerNetworkService;
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public ActionResult GetPrinter(int id)
|
||||
{
|
||||
Printer printer = _context.Printers.Find(id)!;
|
||||
if (printer == null)
|
||||
return printer == null ? NotFound() : Ok(printer);
|
||||
}
|
||||
|
||||
[HttpGet("GetSNMP/{IpAddressOrHostname}")]
|
||||
public async Task<IActionResult> GetSNMPQueryResult(string IpAddressOrHostname)
|
||||
{
|
||||
try
|
||||
{
|
||||
return NotFound();
|
||||
QueryPrinterToAdd? printerData = await _printerNetworkService.GetPrinterListParametersAsync(IpAddressOrHostname);
|
||||
|
||||
return Ok(printerData);
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
return Problem(detail: ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Problem(detail: ex.Message);
|
||||
}
|
||||
return Ok(printer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user