mirror of
https://gitlab.com/Hukuta47/cartrix.git
synced 2026-12-06 21:10:55 +00:00
Был сделан запрос POST для создание записи о принтере
This commit is contained in:
1 parent
7a0e7e0801
commit
02160f451f
43 files changed
+1044
-634
No files matched your search
@@ -1,17 +1,43 @@
|
||||
using CartriX.Shared.Models;
|
||||
using CartriX.Shared.Classes;
|
||||
using CartriX.Shared.DTOs.Printer;
|
||||
using CartriX.Shared.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace CartriX.Shared.Mappers
|
||||
{
|
||||
public static class PrinterMap
|
||||
{
|
||||
public static PrinterNoLocation NoLocation(this Printer printer)
|
||||
public static PrinterName OnlyName(this Printer printer)
|
||||
{
|
||||
return new PrinterNoLocation
|
||||
return new()
|
||||
{
|
||||
Id = printer.Id,
|
||||
Name = printer.Hostname
|
||||
Name = printer.hostname
|
||||
};
|
||||
}
|
||||
public static PrinterDto ToDto(this Printer printer)
|
||||
{
|
||||
return new()
|
||||
{
|
||||
hostname = printer.hostname,
|
||||
ipAddress = printer.ipAddress,
|
||||
locationName = printer.location.name,
|
||||
modelName = printer.model.name
|
||||
};
|
||||
}
|
||||
public static Printer ToPrinterModel(this CreatePrinterRequestDto requestDto, AppDbContext context)
|
||||
{
|
||||
Location location = (context.Locations.Any(l => l.name == requestDto.locationValue)) ? context.Locations.First(l => l.name == requestDto.locationValue) : new() { name = requestDto.locationValue };
|
||||
PrinterModel model = (context.PrinterModels.Any(m => m.name == requestDto.modelName)) ? context.PrinterModels.First(p => p.name == requestDto.modelName) : new() { name = requestDto.modelName };
|
||||
|
||||
return new()
|
||||
{
|
||||
hostname = requestDto.hostname,
|
||||
ipAddress = requestDto.ipAddress,
|
||||
location = location,
|
||||
model = model
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user