laatzen/LaaProductionWeb/LaaProductionWeb.Blazor/Components/HeliumTester/Models/RecipesAssignmentModel.cs
2025-03-31 09:09:42 +02:00

56 lines
1.9 KiB
C#

namespace LaaProductionWeb.Blazor.Components.HeliumTester.Models
{
using LaaPackages.SqlClient;
using Microsoft.Extensions.Configuration;
using System.Collections.Generic;
public class RecipesAssignmentModel
{
private readonly SqlConnection sqlConnection;
public RecipesAssignmentModel(IConfiguration configuration)
{
var connectionString = configuration.GetConnectionString("Auftrag");
this.sqlConnection = SqlConnection.CreateSqlConnection(connectionString);
}
public IEnumerable<PcbRecipeEntity> LoadLast20PcbRecieps()
{
var latest20Recipes = this.sqlConnection
.CreateCommand(@"
SELECT TOP 20
Id
, PcbId
, HeliumRecipeId
, WaterRecipeId
, Region
, Dn
, Length
, Pressure
, Plate
, DeadVolume
, MeterType
FROM ht.PcbRecipe
ORDER BY Id DESC")
.ExecuteReader(x => new PcbRecipeEntity
{
Id = x.GetValue<int>(0),
PcbId = x.GetValue<int>(1),
HeliumRecipeId = x.GetValue<int>(2),
WaterRecipeId = x.GetValue<int>(3),
Region = x.GetValue<int>(4),
MeterSize = x.GetValue<int>(5),
BodyLength = x.GetValue<int>(6),
Pressure = x.GetValue<bool>(7),
PlateType = x.GetValue<string>(8),
DeadVolume = x.GetValue<double>(9),
MeterType = x.GetValue<int>(10),
});
return latest20Recipes;
}
}
}