Move logic out the the class libs

This commit is contained in:
Alex Pedersen
2026-07-30 10:11:54 +02:00
parent 97688542fe
commit 6df185d519
21 changed files with 44 additions and 99 deletions

View File

@@ -8,8 +8,8 @@ namespace Pos.Models
{
public class AmountGridModel
{
public string PaymentMethodText { get; set; }
public string PaymentMethodText { get; set; } = string.Empty;
public decimal Amount { get; set; }
public string AmountText { get; set; }
public string AmountText { get; set; } = string.Empty;
}
}

View File

@@ -1,7 +0,0 @@
namespace Pos.Models
{
public class Class1
{
}
}

View File

@@ -8,11 +8,11 @@ namespace Pos.Json
{
public class BodyModel
{
public ProductModel[] products { get; set; }
public ProductModel[] products { get; set; } = Array.Empty<ProductModel>();
public float totalPrice { get; set; }
public float totalVat { get; set; }
public int receiptNumber { get; set; }
public string receiptTime { get; set; }
public string staff { get; set; }
public string receiptTime { get; set; } = string.Empty;
public string staff { get; set; } = string.Empty;
}
}

View File

@@ -8,8 +8,8 @@ namespace Pos.Json
{
public class FooterModel
{
public string value { get; set; }
public PrintStylesModel printStyles { get; set; }
public string value { get; set; } = string.Empty;
public PrintStylesModel printStyles { get; set; } = new();
public int textAlignment { get; set; }
public int feedingLines { get; set; }
}

View File

@@ -8,8 +8,8 @@ namespace Pos.Json
{
public class HeaderModel
{
public string value { get; set; }
public PrintStylesModel printStyles { get; set; }
public string value { get; set; } = string.Empty;
public PrintStylesModel printStyles { get; set; } = new();
public int textAlignment { get; set; }
public int feedingLines { get; set; }
}

View File

@@ -8,9 +8,9 @@ namespace Pos.Json
{
public class PosReceipt
{
public string logoBase64 { get; set; }
public HeaderModel[] header { get; set; }
public string logoBase64 { get; set; } = string.Empty;
public HeaderModel[] header { get; set; } = Array.Empty<HeaderModel>();
public BodyModel bodyModel { get; set; } = new();
public FooterModel[] footer { get; set; }
public FooterModel[] footer { get; set; } = Array.Empty<FooterModel>();
}
}

View File

@@ -8,8 +8,8 @@ namespace Pos.Json
{
public class ProductModel
{
public string product { get; set; }
public string noOfProduct { get; set; }
public string product { get; set; } = string.Empty;
public string noOfProduct { get; set; } = string.Empty;
public float price { get; set; }
public float totalPrice { get; set; }
}

View File

@@ -13,7 +13,7 @@ namespace Pos.Json
public class SaleOfDayDetail
{
public string Category { get; set; }
public string Category { get; set; } = string.Empty;
public decimal TotalSale { get; set; }
}
}

View File

@@ -8,7 +8,7 @@ namespace Pos.Models
{
public class PriceLineModel
{
public string Name { get; set; }
public string Name { get; set; } = string.Empty;
public int NumberProducts { get; set; }
public decimal Price { get; set; }
public int Id { get; set; }

View File

@@ -8,10 +8,10 @@ namespace Pos.Models
{
public class SaleGridModel
{
public string Navn { get; set; }
public string Stk { get; set; }
public string Pris { get; set; }
public string Total { get; set; }
public SaleGridInternalModel SaleGridInternalModel { get; set; }
public string Navn { get; set; } = string.Empty;
public string Stk { get; set; } = string.Empty;
public string Pris { get; set; } = string.Empty;
public string Total { get; set; } = string.Empty;
public SaleGridInternalModel SaleGridInternalModel { get; set; } = new();
}
}

View File

@@ -8,8 +8,8 @@ namespace Pos.Models
{
public class TotalSaleCategory
{
public string Category { get; set; }
public string Category { get; set; } = string.Empty;
public decimal Sale { get; set; }
public string SaleString { get; set; }
public string SaleString { get; set; } = string.Empty;
}
}

View File

@@ -10,8 +10,8 @@ namespace Pos.Service
private static bool _invalidEmployee = false;
private static bool _invalidProductGroup = false;
private static List<EmployeeEntity> _employees;
private static List<ProductGroupEntity> _productGroups;
private static List<EmployeeEntity> _employees = new();
private static List<ProductGroupEntity> _productGroups = new();
public static void Invalidate()

View File

@@ -6,4 +6,14 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="10.0.10" />
<PackageReference Include="RestSharp" Version="108.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Pos.Models\Pos.Models.csproj" />
<ProjectReference Include="..\Pos.Ui\Database\Database.csproj" />
</ItemGroup>
</Project>

View File

@@ -84,7 +84,9 @@ namespace Pos.Service
LoadConfig loadConfig = new LoadConfig();
IConfiguration config = loadConfig.ByEnvironment();
string url = config["API:URL"];
string url = config["API:URL"]
?? throw new InvalidOperationException(
"API:URL mangler i konfigurationen.");
RestClient restClient = new RestClient($"{url}/api/PosPrinter/SaleOfDay");
RestRequest request = new RestRequest();
@@ -159,7 +161,9 @@ namespace Pos.Service
LoadConfig loadConfig = new LoadConfig();
IConfiguration config = loadConfig.ByEnvironment();
string apiUrl = config["API:URL"];
string apiUrl = config["API:URL"]
?? throw new InvalidOperationException(
"API:URL mangler i konfigurationen.");
string url = $"{apiUrl}/api/PosPrinter/Receipt";
RestClient restClient = new RestClient(url);

View File

@@ -18,12 +18,10 @@
<None Remove="Icons\settings.png" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="RestSharp" Version="108.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Database\Database.csproj" />
<ProjectReference Include="..\..\Pos.Models\Pos.Models.csproj" />
<ProjectReference Include="..\..\Pos.Service\Pos.Service.csproj" />
</ItemGroup>
<ItemGroup>

View File

@@ -1,60 +0,0 @@
//public class Rootobject
//{
// public string logoBase64 { get; set; }
// public Header[] header { get; set; }
// public Bodymodel bodyModel { get; set; }
// public Footer[] footer { get; set; }
//}
//public class Bodymodel
//{
// public Product[] products { get; set; }
// public int totalPrice { get; set; }
// public int totalVat { get; set; }
// public int receiptNumber { get; set; }
// public string receiptTime { get; set; }
// public string staff { get; set; }
//}
//public class Product
//{
// public string product { get; set; }
// public string noOfProduct { get; set; }
// public float price { get; set; }
// public float totalPrice { get; set; }
//}
//public class Header
//{
// public string value { get; set; }
// public Printstyles printStyles { get; set; }
// public int textAlignment { get; set; }
// public int feedingLines { get; set; }
//}
//public class Printstyles
//{
// public bool fontB { get; set; }
// public bool bold { get; set; }
// public bool doubleHeight { get; set; }
// public bool doubleWidth { get; set; }
// public bool underline { get; set; }
//}
//public class Footer
//{
// public string value { get; set; }
// public Printstyles1 printStyles { get; set; }
// public int textAlignment { get; set; }
// public int feedingLines { get; set; }
//}
//public class Printstyles1
//{
// public bool fontB { get; set; }
// public bool bold { get; set; }
// public bool doubleHeight { get; set; }
// public bool doubleWidth { get; set; }
// public bool underline { get; set; }
//}