From 6df185d519104ac1158971d53188a8c7b3035f6a Mon Sep 17 00:00:00 2001 From: Alex Pedersen <64533006+Allemand1001DK@users.noreply.github.com> Date: Thu, 30 Jul 2026 10:11:54 +0200 Subject: [PATCH] Move logic out the the class libs --- .../Models => Pos.Models}/AmountGridModel.cs | 4 +- PointOfSale/Pos.Models/Class1.cs | 7 --- .../Pos/Models => Pos.Models}/Enums.cs | 2 +- .../Pos => Pos.Models}/Json/BodyModel.cs | 6 +- .../Pos => Pos.Models}/Json/FooterModel.cs | 4 +- .../Pos => Pos.Models}/Json/HeaderModel.cs | 4 +- .../Pos => Pos.Models}/Json/PosReceipt.cs | 6 +- .../Json/PrintStylesModel.cs | 0 .../Pos => Pos.Models}/Json/ProductModel.cs | 4 +- .../Pos => Pos.Models}/Json/SaleOfDayModel.cs | 2 +- .../Models => Pos.Models}/PriceLineModel.cs | 2 +- .../SaleGridInternalModel.cs | 0 .../Models => Pos.Models}/SaleGridModel.cs | 10 ++-- .../TotalSaleCategory.cs | 4 +- .../Models => Pos.Models}/TotalSaleDetail.cs | 0 .../Service => Pos.Service}/CacheService.cs | 4 +- PointOfSale/Pos.Service/Pos.Service.csproj | 10 ++++ .../Service => Pos.Service}/SaleService.cs | 8 ++- .../SalesTransactionService.cs | 0 PointOfSale/Pos.Ui/Pos/Pos.csproj | 6 +- PointOfSale/Pos.Ui/Pos/json.cs | 60 ------------------- 21 files changed, 44 insertions(+), 99 deletions(-) rename PointOfSale/{Pos.Ui/Pos/Models => Pos.Models}/AmountGridModel.cs (63%) delete mode 100644 PointOfSale/Pos.Models/Class1.cs rename PointOfSale/{Pos.Ui/Pos/Models => Pos.Models}/Enums.cs (98%) rename PointOfSale/{Pos.Ui/Pos => Pos.Models}/Json/BodyModel.cs (60%) rename PointOfSale/{Pos.Ui/Pos => Pos.Models}/Json/FooterModel.cs (68%) rename PointOfSale/{Pos.Ui/Pos => Pos.Models}/Json/HeaderModel.cs (68%) rename PointOfSale/{Pos.Ui/Pos => Pos.Models}/Json/PosReceipt.cs (51%) rename PointOfSale/{Pos.Ui/Pos => Pos.Models}/Json/PrintStylesModel.cs (100%) rename PointOfSale/{Pos.Ui/Pos => Pos.Models}/Json/ProductModel.cs (68%) rename PointOfSale/{Pos.Ui/Pos => Pos.Models}/Json/SaleOfDayModel.cs (87%) rename PointOfSale/{Pos.Ui/Pos/Models => Pos.Models}/PriceLineModel.cs (86%) rename PointOfSale/{Pos.Ui/Pos/Models => Pos.Models}/SaleGridInternalModel.cs (100%) rename PointOfSale/{Pos.Ui/Pos/Models => Pos.Models}/SaleGridModel.cs (50%) rename PointOfSale/{Pos.Ui/Pos/Models => Pos.Models}/TotalSaleCategory.cs (65%) rename PointOfSale/{Pos.Ui/Pos/Models => Pos.Models}/TotalSaleDetail.cs (100%) rename PointOfSale/{Pos.Ui/Pos/Service => Pos.Service}/CacheService.cs (92%) rename PointOfSale/{Pos.Ui/Pos/Service => Pos.Service}/SaleService.cs (97%) rename PointOfSale/{Pos.Ui/Pos/Service => Pos.Service}/SalesTransactionService.cs (100%) delete mode 100644 PointOfSale/Pos.Ui/Pos/json.cs diff --git a/PointOfSale/Pos.Ui/Pos/Models/AmountGridModel.cs b/PointOfSale/Pos.Models/AmountGridModel.cs similarity index 63% rename from PointOfSale/Pos.Ui/Pos/Models/AmountGridModel.cs rename to PointOfSale/Pos.Models/AmountGridModel.cs index c573212..81a3576 100644 --- a/PointOfSale/Pos.Ui/Pos/Models/AmountGridModel.cs +++ b/PointOfSale/Pos.Models/AmountGridModel.cs @@ -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; } } diff --git a/PointOfSale/Pos.Models/Class1.cs b/PointOfSale/Pos.Models/Class1.cs deleted file mode 100644 index c396053..0000000 --- a/PointOfSale/Pos.Models/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Pos.Models -{ - public class Class1 - { - - } -} diff --git a/PointOfSale/Pos.Ui/Pos/Models/Enums.cs b/PointOfSale/Pos.Models/Enums.cs similarity index 98% rename from PointOfSale/Pos.Ui/Pos/Models/Enums.cs rename to PointOfSale/Pos.Models/Enums.cs index c303042..21ca186 100644 --- a/PointOfSale/Pos.Ui/Pos/Models/Enums.cs +++ b/PointOfSale/Pos.Models/Enums.cs @@ -6,4 +6,4 @@ public enum PaymentMethod Card, GiftCard, MobilePay -} \ No newline at end of file +} diff --git a/PointOfSale/Pos.Ui/Pos/Json/BodyModel.cs b/PointOfSale/Pos.Models/Json/BodyModel.cs similarity index 60% rename from PointOfSale/Pos.Ui/Pos/Json/BodyModel.cs rename to PointOfSale/Pos.Models/Json/BodyModel.cs index 759e8fe..6c888bf 100644 --- a/PointOfSale/Pos.Ui/Pos/Json/BodyModel.cs +++ b/PointOfSale/Pos.Models/Json/BodyModel.cs @@ -8,11 +8,11 @@ namespace Pos.Json { public class BodyModel { - public ProductModel[] products { get; set; } + public ProductModel[] products { get; set; } = Array.Empty(); 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; } } diff --git a/PointOfSale/Pos.Ui/Pos/Json/FooterModel.cs b/PointOfSale/Pos.Models/Json/FooterModel.cs similarity index 68% rename from PointOfSale/Pos.Ui/Pos/Json/FooterModel.cs rename to PointOfSale/Pos.Models/Json/FooterModel.cs index f17fc20..b94b342 100644 --- a/PointOfSale/Pos.Ui/Pos/Json/FooterModel.cs +++ b/PointOfSale/Pos.Models/Json/FooterModel.cs @@ -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; } } diff --git a/PointOfSale/Pos.Ui/Pos/Json/HeaderModel.cs b/PointOfSale/Pos.Models/Json/HeaderModel.cs similarity index 68% rename from PointOfSale/Pos.Ui/Pos/Json/HeaderModel.cs rename to PointOfSale/Pos.Models/Json/HeaderModel.cs index 7b63d15..0d704a5 100644 --- a/PointOfSale/Pos.Ui/Pos/Json/HeaderModel.cs +++ b/PointOfSale/Pos.Models/Json/HeaderModel.cs @@ -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; } } diff --git a/PointOfSale/Pos.Ui/Pos/Json/PosReceipt.cs b/PointOfSale/Pos.Models/Json/PosReceipt.cs similarity index 51% rename from PointOfSale/Pos.Ui/Pos/Json/PosReceipt.cs rename to PointOfSale/Pos.Models/Json/PosReceipt.cs index bdbf31a..a5bf355 100644 --- a/PointOfSale/Pos.Ui/Pos/Json/PosReceipt.cs +++ b/PointOfSale/Pos.Models/Json/PosReceipt.cs @@ -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(); public BodyModel bodyModel { get; set; } = new(); - public FooterModel[] footer { get; set; } + public FooterModel[] footer { get; set; } = Array.Empty(); } } diff --git a/PointOfSale/Pos.Ui/Pos/Json/PrintStylesModel.cs b/PointOfSale/Pos.Models/Json/PrintStylesModel.cs similarity index 100% rename from PointOfSale/Pos.Ui/Pos/Json/PrintStylesModel.cs rename to PointOfSale/Pos.Models/Json/PrintStylesModel.cs diff --git a/PointOfSale/Pos.Ui/Pos/Json/ProductModel.cs b/PointOfSale/Pos.Models/Json/ProductModel.cs similarity index 68% rename from PointOfSale/Pos.Ui/Pos/Json/ProductModel.cs rename to PointOfSale/Pos.Models/Json/ProductModel.cs index 32a4ae8..12317fe 100644 --- a/PointOfSale/Pos.Ui/Pos/Json/ProductModel.cs +++ b/PointOfSale/Pos.Models/Json/ProductModel.cs @@ -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; } } diff --git a/PointOfSale/Pos.Ui/Pos/Json/SaleOfDayModel.cs b/PointOfSale/Pos.Models/Json/SaleOfDayModel.cs similarity index 87% rename from PointOfSale/Pos.Ui/Pos/Json/SaleOfDayModel.cs rename to PointOfSale/Pos.Models/Json/SaleOfDayModel.cs index 51d08fe..04315f7 100644 --- a/PointOfSale/Pos.Ui/Pos/Json/SaleOfDayModel.cs +++ b/PointOfSale/Pos.Models/Json/SaleOfDayModel.cs @@ -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; } } } diff --git a/PointOfSale/Pos.Ui/Pos/Models/PriceLineModel.cs b/PointOfSale/Pos.Models/PriceLineModel.cs similarity index 86% rename from PointOfSale/Pos.Ui/Pos/Models/PriceLineModel.cs rename to PointOfSale/Pos.Models/PriceLineModel.cs index ad61717..944ee79 100644 --- a/PointOfSale/Pos.Ui/Pos/Models/PriceLineModel.cs +++ b/PointOfSale/Pos.Models/PriceLineModel.cs @@ -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; } diff --git a/PointOfSale/Pos.Ui/Pos/Models/SaleGridInternalModel.cs b/PointOfSale/Pos.Models/SaleGridInternalModel.cs similarity index 100% rename from PointOfSale/Pos.Ui/Pos/Models/SaleGridInternalModel.cs rename to PointOfSale/Pos.Models/SaleGridInternalModel.cs diff --git a/PointOfSale/Pos.Ui/Pos/Models/SaleGridModel.cs b/PointOfSale/Pos.Models/SaleGridModel.cs similarity index 50% rename from PointOfSale/Pos.Ui/Pos/Models/SaleGridModel.cs rename to PointOfSale/Pos.Models/SaleGridModel.cs index 1a11c83..dd632bd 100644 --- a/PointOfSale/Pos.Ui/Pos/Models/SaleGridModel.cs +++ b/PointOfSale/Pos.Models/SaleGridModel.cs @@ -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(); } } diff --git a/PointOfSale/Pos.Ui/Pos/Models/TotalSaleCategory.cs b/PointOfSale/Pos.Models/TotalSaleCategory.cs similarity index 65% rename from PointOfSale/Pos.Ui/Pos/Models/TotalSaleCategory.cs rename to PointOfSale/Pos.Models/TotalSaleCategory.cs index 9c5e8ac..c7e60e1 100644 --- a/PointOfSale/Pos.Ui/Pos/Models/TotalSaleCategory.cs +++ b/PointOfSale/Pos.Models/TotalSaleCategory.cs @@ -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; } } diff --git a/PointOfSale/Pos.Ui/Pos/Models/TotalSaleDetail.cs b/PointOfSale/Pos.Models/TotalSaleDetail.cs similarity index 100% rename from PointOfSale/Pos.Ui/Pos/Models/TotalSaleDetail.cs rename to PointOfSale/Pos.Models/TotalSaleDetail.cs diff --git a/PointOfSale/Pos.Ui/Pos/Service/CacheService.cs b/PointOfSale/Pos.Service/CacheService.cs similarity index 92% rename from PointOfSale/Pos.Ui/Pos/Service/CacheService.cs rename to PointOfSale/Pos.Service/CacheService.cs index 55f0173..c9caa33 100644 --- a/PointOfSale/Pos.Ui/Pos/Service/CacheService.cs +++ b/PointOfSale/Pos.Service/CacheService.cs @@ -10,8 +10,8 @@ namespace Pos.Service private static bool _invalidEmployee = false; private static bool _invalidProductGroup = false; - private static List _employees; - private static List _productGroups; + private static List _employees = new(); + private static List _productGroups = new(); public static void Invalidate() diff --git a/PointOfSale/Pos.Service/Pos.Service.csproj b/PointOfSale/Pos.Service/Pos.Service.csproj index b760144..c5b3695 100644 --- a/PointOfSale/Pos.Service/Pos.Service.csproj +++ b/PointOfSale/Pos.Service/Pos.Service.csproj @@ -6,4 +6,14 @@ enable + + + + + + + + + + diff --git a/PointOfSale/Pos.Ui/Pos/Service/SaleService.cs b/PointOfSale/Pos.Service/SaleService.cs similarity index 97% rename from PointOfSale/Pos.Ui/Pos/Service/SaleService.cs rename to PointOfSale/Pos.Service/SaleService.cs index 8ac860e..0c3db6c 100644 --- a/PointOfSale/Pos.Ui/Pos/Service/SaleService.cs +++ b/PointOfSale/Pos.Service/SaleService.cs @@ -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); diff --git a/PointOfSale/Pos.Ui/Pos/Service/SalesTransactionService.cs b/PointOfSale/Pos.Service/SalesTransactionService.cs similarity index 100% rename from PointOfSale/Pos.Ui/Pos/Service/SalesTransactionService.cs rename to PointOfSale/Pos.Service/SalesTransactionService.cs diff --git a/PointOfSale/Pos.Ui/Pos/Pos.csproj b/PointOfSale/Pos.Ui/Pos/Pos.csproj index 51b23eb..fba0d34 100644 --- a/PointOfSale/Pos.Ui/Pos/Pos.csproj +++ b/PointOfSale/Pos.Ui/Pos/Pos.csproj @@ -18,12 +18,10 @@ - - - - + + diff --git a/PointOfSale/Pos.Ui/Pos/json.cs b/PointOfSale/Pos.Ui/Pos/json.cs deleted file mode 100644 index 2b8b7c1..0000000 --- a/PointOfSale/Pos.Ui/Pos/json.cs +++ /dev/null @@ -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; } -//}