mirror of
https://gitlab.com/Hukuta47/cartrix.git
synced 2026-12-06 21:10:55 +00:00
Подлатал API и Web
This commit is contained in:
1 parent
ae561f8311
commit
34868984fb
26 files changed
+435
-104
No files matched your search
@@ -7,17 +7,11 @@ namespace CartriX.Shared.Mappers
|
||||
{
|
||||
public static class PrinterMap
|
||||
{
|
||||
public static PrinterName OnlyName(this Printer printer)
|
||||
{
|
||||
return new()
|
||||
{
|
||||
Name = printer.hostname
|
||||
};
|
||||
}
|
||||
public static async Task<PrinterDto> ToDtoAsync(this Printer printer)
|
||||
public static PrinterDto ToDto(this Printer printer)
|
||||
{
|
||||
return new()
|
||||
{
|
||||
name = printer.name,
|
||||
hostname = printer.hostname,
|
||||
ipAddress = printer.ipAddress,
|
||||
locationName = printer.location.name,
|
||||
@@ -26,16 +20,25 @@ namespace CartriX.Shared.Mappers
|
||||
}
|
||||
public static async Task<Printer> ToPrinterModelAsync(this CreatePrinterRequestDto requestDto, AppDbContext context)
|
||||
{
|
||||
Location location = (await context.Locations.AnyAsync(l => l.name == requestDto.locationValue)) ? await context.Locations.FirstAsync(l => l.name == requestDto.locationValue) : new() { name = requestDto.locationValue };
|
||||
Location location = (await context.Locations.AnyAsync(l => l.name == requestDto.locationValue)) ? await context.Locations.FirstAsync(l => l.name == requestDto.locationValue) : new() { name = requestDto.locationValue };
|
||||
PrinterModel model = (await context.PrinterModels.AnyAsync(m => m.name == requestDto.modelName)) ? await context.PrinterModels.FirstAsync(p => p.name == requestDto.modelName) : new() { name = requestDto.modelName };
|
||||
|
||||
return new()
|
||||
{
|
||||
name = requestDto.name,
|
||||
hostname = requestDto.hostname,
|
||||
ipAddress = requestDto.ipAddress,
|
||||
location = location,
|
||||
model = model
|
||||
};
|
||||
}
|
||||
public static PrinterDtoWithNameAndId ToDtoWithNameAndId(this Printer printer)
|
||||
{
|
||||
return new()
|
||||
{
|
||||
id = printer.id,
|
||||
name = printer.name
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user