mirror of
https://gitlab.com/Hukuta47/cartrix.git
synced 2026-12-05 12:30:55 +00:00
фывфывфыв
This commit is contained in:
1 parent
47fb655a96
commit
e8529ee92a
46 files changed
+2514
-919
No files matched your search
@@ -21,19 +21,22 @@ namespace CartriX.Api.Controllers
|
||||
return (Item is not null) ? Ok(Item.ToItem()) : NotFound();
|
||||
}
|
||||
[HttpGet(nameof(Models))] public async Task<IActionResult> Models() => Ok(await _printerService.GetModelsAsync());
|
||||
[HttpGet(nameof(PrintTypes))] public async Task<IActionResult> PrintTypes() => Ok((await _printerService.GetPrintTypesAsync()).Select(t => t.ToPrintType()));
|
||||
[HttpGet(nameof(PrintTypes))] public async Task<IActionResult> PrintTypes() => Ok((await _printerService.GetPrintTypes()).Select(t => t.ToPrintType()));
|
||||
[HttpGet(nameof(ConnectionTypes))] public async Task<IActionResult> ConnectionTypes() => Ok(await _printerService.GetConnectionTypes());
|
||||
#endregion
|
||||
#region Post methods
|
||||
[HttpPost(nameof(Add))]
|
||||
public async Task<IActionResult> Add([FromBody] DTOs.Printer.AddPrinter printer)
|
||||
{
|
||||
if (printer is null)
|
||||
return BadRequest("Данные не были переданы.");
|
||||
|
||||
var result = await _printerService.AddAsync(printer);
|
||||
|
||||
|
||||
return Ok();
|
||||
try
|
||||
{
|
||||
await _printerService.AddAsync(printer);
|
||||
return Ok($"Принтер {printer.name} был добавлен без ошибок.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Problem(title: $"При выполнении было получено исключение.", detail: $"{ex.Message}");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in new issue
Block a user