Перевел некоторые методы на асинхрон

This commit is contained in:
Hukuta committed 2026-05-06 00:36:49 +09:00
1 parent 02160f451f
commit ae561f8311
2 files changed
+9 -15

No files matched your search

+5 -7
View File
@@ -1,9 +1,7 @@
using CartriX.Shared.Classes;
using CartriX.Shared.DTOs.Printer;
using CartriX.Shared.Models;
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.EntityFrameworkCore;
namespace CartriX.Shared.Mappers
{
@@ -16,7 +14,7 @@ namespace CartriX.Shared.Mappers
Name = printer.hostname
};
}
public static PrinterDto ToDto(this Printer printer)
public static async Task<PrinterDto> ToDtoAsync(this Printer printer)
{
return new()
{
@@ -26,10 +24,10 @@ namespace CartriX.Shared.Mappers
modelName = printer.model.name
};
}
public static Printer ToPrinterModel(this CreatePrinterRequestDto requestDto, AppDbContext context)
public static async Task<Printer> ToPrinterModelAsync(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 };
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()
{