mirror of
https://gitlab.com/Hukuta47/cartrix.git
synced 2026-12-06 13:00:55 +00:00
Убрал название принтерам, и исправил ошибку с указанием родительской модели картриджам, и название модели картриджу
This commit is contained in:
1 parent
eef2234192
commit
b9ef6dbe1c
40 files changed
+281
-1545
No files matched your search
@@ -7,56 +7,42 @@ namespace CartriX.Api.Controllers.Printer
|
||||
[ApiController]
|
||||
public class PrinterController(IPrinterService _service) : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Добавить принтер
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Маршрут который позволяет добавить принтер в базу данных
|
||||
/// </remarks>
|
||||
[ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(typeof(string), StatusCodes.Status500InternalServerError)]
|
||||
[HttpPost(nameof(AddPrinter))]
|
||||
public async Task<ActionResult> AddPrinter([FromBody] Shared.Models.Printer.PrinterAdd printer)
|
||||
{
|
||||
await _service.PrinterAddAsync(printer);
|
||||
return StatusCode(200, "Принтер успешно добавлен.");
|
||||
}
|
||||
/// <summary>
|
||||
/// Получить информацию о принтере
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Маршрут который позволяет получить информацию о принтере
|
||||
/// </remarks>
|
||||
[ProducesResponseType(typeof(Shared.Models.Printer.PrinterItem), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(string), StatusCodes.Status404NotFound)]
|
||||
[HttpGet(nameof(Item))]
|
||||
public async Task<ActionResult> Item([FromQuery] int Id)
|
||||
{
|
||||
var cartridge = await _service.GetPrinterAsync(Id);
|
||||
return (cartridge is not null) ? StatusCode(200, cartridge.ToItem())
|
||||
: StatusCode(404, $"Принтер с идентификатором \"{Id}\" не найден.");
|
||||
}
|
||||
/// <summary>
|
||||
/// Получить список типов подключения принтеров
|
||||
/// </summary>
|
||||
[ProducesResponseType(typeof(List<Shared.Models.Printer.PrinterConnectionTypeItem>), StatusCodes.Status200OK)]
|
||||
[HttpGet(nameof(ListConnectionType))]
|
||||
public async Task<ActionResult> ListConnectionType()
|
||||
{
|
||||
var result = await _service.GetListConnectionTypeAsync();
|
||||
return Ok(result.Select(t => t.ToItem()));
|
||||
}
|
||||
/// <summary>
|
||||
/// Получить список типов печати принтеров
|
||||
/// </summary>
|
||||
[ProducesResponseType(typeof(List<Shared.Models.Printer.PrinterPrintTypeItem>), StatusCodes.Status200OK)]
|
||||
[HttpGet(nameof(ListPrintType))]
|
||||
public async Task<ActionResult> ListPrintType()
|
||||
{
|
||||
var result = await _service.GetListPrintTypeAsync();
|
||||
return Ok(result.Select(t => t.ToItem()));
|
||||
}
|
||||
#region GET
|
||||
/// <summary>
|
||||
/// Получить информацию о принтере
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Маршрут который позволяет получить информацию о принтере
|
||||
/// </remarks>
|
||||
[ProducesResponseType(typeof(Shared.Models.Printer.PrinterItem), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(string), StatusCodes.Status404NotFound)]
|
||||
[HttpGet(nameof(Item))]
|
||||
public async Task<ActionResult> Item([FromQuery] int Id)
|
||||
{
|
||||
var cartridge = await _service.GetPrinterAsync(Id);
|
||||
return (cartridge is not null) ? StatusCode(200, cartridge.ToItem())
|
||||
: StatusCode(404, $"Принтер с идентификатором \"{Id}\" не найден.");
|
||||
}
|
||||
/// <summary>
|
||||
/// Получить список типов подключения принтеров
|
||||
/// </summary>
|
||||
[ProducesResponseType(typeof(List<Shared.Models.Printer.PrinterConnectionTypeItem>), StatusCodes.Status200OK)]
|
||||
[HttpGet(nameof(ListConnectionType))]
|
||||
public async Task<ActionResult> ListConnectionType()
|
||||
{
|
||||
var result = await _service.GetListConnectionTypeAsync();
|
||||
return Ok(result.Select(t => t.ToItem()));
|
||||
}
|
||||
/// <summary>
|
||||
/// Получить список типов печати принтеров
|
||||
/// </summary>
|
||||
[ProducesResponseType(typeof(List<Shared.Models.Printer.PrinterPrintTypeItem>), StatusCodes.Status200OK)]
|
||||
[HttpGet(nameof(ListPrintType))]
|
||||
public async Task<ActionResult> ListPrintType()
|
||||
{
|
||||
var result = await _service.GetListPrintTypeAsync();
|
||||
return Ok(result.Select(t => t.ToItem()));
|
||||
}
|
||||
/// <summary>
|
||||
/// Получить список адресов OID для полученяи счетчика печати страниц принтера
|
||||
/// </summary>
|
||||
@@ -64,9 +50,28 @@ namespace CartriX.Api.Controllers.Printer
|
||||
[HttpGet(nameof(GetAddressOIDs))]
|
||||
public async Task<ActionResult> GetAddressOIDs()
|
||||
{
|
||||
var result = await _service.GetOIDAddresses();
|
||||
return Ok(result.Select(a => a.OIDAddress));
|
||||
var result = await _service.GetOIDAddresses();
|
||||
return Ok(result.Select(a => a.OIDAddress));
|
||||
}
|
||||
#endregion
|
||||
#region POST
|
||||
/// <summary>
|
||||
/// Добавить принтер
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Маршрут который позволяет добавить принтер в базу данных
|
||||
/// </remarks>
|
||||
[ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(typeof(string), StatusCodes.Status500InternalServerError)]
|
||||
[HttpPost(nameof(AddPrinter))]
|
||||
public async Task<ActionResult> AddPrinter([FromBody] Shared.Models.Printer.PrinterAdd printer)
|
||||
{
|
||||
await _service.PrinterAddAsync(printer);
|
||||
return StatusCode(200, "Принтер успешно добавлен.");
|
||||
}
|
||||
#endregion
|
||||
#region PUT
|
||||
/// <summary>
|
||||
/// Поменять статус принтера
|
||||
/// </summary>
|
||||
@@ -75,15 +80,16 @@ namespace CartriX.Api.Controllers.Printer
|
||||
[HttpPatch(nameof(ChangeStatus))]
|
||||
public async Task<ActionResult> ChangeStatus([FromQuery] int PrinterId, [FromBody] int StatusId)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _service.ChangeStatusAsync(PrinterId, StatusId);
|
||||
try
|
||||
{
|
||||
await _service.ChangeStatusAsync(PrinterId, StatusId);
|
||||
return StatusCode(200);
|
||||
}
|
||||
catch (NullReferenceException ex)
|
||||
{
|
||||
return StatusCode(404, ex.Message);
|
||||
}
|
||||
catch (NullReferenceException ex)
|
||||
{
|
||||
return StatusCode(404, ex.Message);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user