[#11] Tests: Add DeliveryServiceTest
All checks were successful
Test / Run tests (push) Successful in 1m56s
All checks were successful
Test / Run tests (push) Successful in 1m56s
This commit is contained in:
@ -7,9 +7,6 @@ using Elwig.Helpers;
|
||||
using Elwig.Helpers.Weighing;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Threading;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
using System.Windows.Markup;
|
||||
using System.Reflection;
|
||||
using Elwig.Helpers.Printing;
|
||||
using Elwig.Windows;
|
||||
@ -62,7 +59,7 @@ namespace Elwig {
|
||||
MainDispatcher = Dispatcher;
|
||||
Scales = [];
|
||||
CurrentApp = this;
|
||||
OverrideCulture();
|
||||
Utils.OverrideCulture();
|
||||
|
||||
var args = Environment.GetCommandLineArgs();
|
||||
if (args.Length >= 2) {
|
||||
@ -82,23 +79,6 @@ namespace Elwig {
|
||||
MainDispatcher.BeginInvoke(HintContextChange);
|
||||
}
|
||||
|
||||
private static void OverrideCulture() {
|
||||
var locale = new CultureInfo("de-AT", false);
|
||||
locale.NumberFormat.CurrencyGroupSeparator = Utils.GroupSeparator;
|
||||
locale.NumberFormat.NumberGroupSeparator = Utils.GroupSeparator;
|
||||
locale.NumberFormat.PercentGroupSeparator = Utils.GroupSeparator;
|
||||
CultureInfo.CurrentCulture = locale;
|
||||
CultureInfo.CurrentUICulture = locale;
|
||||
Thread.CurrentThread.CurrentCulture = locale;
|
||||
Thread.CurrentThread.CurrentUICulture = locale;
|
||||
CultureInfo.DefaultThreadCurrentCulture = locale;
|
||||
CultureInfo.DefaultThreadCurrentUICulture = locale;
|
||||
FrameworkElement.LanguageProperty.OverrideMetadata(
|
||||
typeof(FrameworkElement),
|
||||
new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.Name))
|
||||
);
|
||||
}
|
||||
|
||||
protected override async void OnStartup(StartupEventArgs evt) {
|
||||
Version = new Version(typeof(App).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion.Split('+')[0] ?? "0.0.0");
|
||||
|
||||
|
@ -28,6 +28,9 @@ using LinqKit;
|
||||
using System.Linq.Expressions;
|
||||
using Elwig.Models;
|
||||
using Microsoft.Win32;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace Elwig.Helpers {
|
||||
public static partial class Utils {
|
||||
@ -118,6 +121,23 @@ namespace Elwig.Helpers {
|
||||
0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040,
|
||||
];
|
||||
|
||||
public static void OverrideCulture() {
|
||||
var locale = new CultureInfo("de-AT", false);
|
||||
locale.NumberFormat.CurrencyGroupSeparator = Utils.GroupSeparator;
|
||||
locale.NumberFormat.NumberGroupSeparator = Utils.GroupSeparator;
|
||||
locale.NumberFormat.PercentGroupSeparator = Utils.GroupSeparator;
|
||||
CultureInfo.CurrentCulture = locale;
|
||||
CultureInfo.CurrentUICulture = locale;
|
||||
Thread.CurrentThread.CurrentCulture = locale;
|
||||
Thread.CurrentThread.CurrentUICulture = locale;
|
||||
CultureInfo.DefaultThreadCurrentCulture = locale;
|
||||
CultureInfo.DefaultThreadCurrentUICulture = locale;
|
||||
FrameworkElement.LanguageProperty.OverrideMetadata(
|
||||
typeof(FrameworkElement),
|
||||
new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.Name))
|
||||
);
|
||||
}
|
||||
|
||||
public static SerialPort OpenSerialConnection(string connection) {
|
||||
var m = SerialRegex.Match(connection);
|
||||
if (!m.Success)
|
||||
|
@ -462,7 +462,7 @@ namespace Elwig.Services {
|
||||
LNr = newLnr ?? oldDelivery!.LNr,
|
||||
ZwstId = vm.Branch!.ZwstId,
|
||||
LsNr = newLsNr ?? vm.LsNr!,
|
||||
MgNr = (int)vm.MgNr!,
|
||||
MgNr = vm.MgNr!.Value,
|
||||
Comment = string.IsNullOrEmpty(vm.Comment) ? null : vm.Comment,
|
||||
};
|
||||
|
||||
@ -474,7 +474,7 @@ namespace Elwig.Services {
|
||||
SortId = vm.WineVar!.SortId,
|
||||
AttrId = vm.WineAttr?.AttrId,
|
||||
CultId = vm.WineCult?.CultId,
|
||||
Kmw = (double)vm.GradationKmw!,
|
||||
Kmw = vm.GradationKmw!.Value,
|
||||
QualId = vm.WineQualityLevel!.QualId,
|
||||
HkId = vm.WineOrigin!.HkId,
|
||||
KgNr = vm.WineKg?.KgNr,
|
||||
@ -488,7 +488,7 @@ namespace Elwig.Services {
|
||||
Acid = vm.Acid,
|
||||
Comment = string.IsNullOrEmpty(vm.PartComment) ? null : vm.PartComment,
|
||||
|
||||
Weight = (int)vm.Weight!,
|
||||
Weight = vm.Weight!.Value,
|
||||
IsManualWeighing = vm.IsManualWeighing,
|
||||
ScaleId = vm.ScaleId,
|
||||
WeighingData = vm.WeighingData,
|
||||
@ -971,5 +971,13 @@ namespace Elwig.Services {
|
||||
|
||||
return (wGrid, gGrid);
|
||||
}
|
||||
|
||||
public static async Task DeleteDelivery(string lsnr) {
|
||||
using (var ctx = new AppDbContext()) {
|
||||
await ctx.Deliveries.Where(d => d.LsNr == lsnr).ExecuteDeleteAsync();
|
||||
await ctx.SaveChangesAsync();
|
||||
}
|
||||
App.HintContextChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -96,10 +96,16 @@ namespace Elwig.ViewModels {
|
||||
private IEnumerable<object> _wineCultSource = [];
|
||||
[ObservableProperty]
|
||||
private string? _gradationOeString;
|
||||
public double? GradationOe => double.TryParse(GradationOeString, out var oe) ? oe : null;
|
||||
public double? GradationOe {
|
||||
get => double.TryParse(GradationOeString, out var oe) ? oe : null;
|
||||
set => GradationOeString = $"{value:0}";
|
||||
}
|
||||
[ObservableProperty]
|
||||
private string? _gradationKmwString;
|
||||
public double? GradationKmw => double.TryParse(GradationKmwString, out var kmw) ? kmw : null;
|
||||
public double? GradationKmw {
|
||||
get => double.TryParse(GradationKmwString, out var kmw) ? kmw : null;
|
||||
set => GradationKmwString = $"{value:0.0}";
|
||||
}
|
||||
[ObservableProperty]
|
||||
private WineQualLevel? _wineQualityLevel;
|
||||
[ObservableProperty]
|
||||
@ -152,10 +158,16 @@ namespace Elwig.ViewModels {
|
||||
private string? _partComment;
|
||||
[ObservableProperty]
|
||||
private string? _temperatureString;
|
||||
public double? Temperature => double.TryParse(TemperatureString, out var t) ? t : null;
|
||||
public double? Temperature {
|
||||
get => double.TryParse(TemperatureString, out var t) ? t : null;
|
||||
set => TemperatureString = $"{value:0.0}";
|
||||
}
|
||||
[ObservableProperty]
|
||||
private string? _acidString;
|
||||
public double? Acid => double.TryParse(AcidString, out var a) ? a : null;
|
||||
public double? Acid {
|
||||
get => double.TryParse(AcidString, out var a) ? a : null;
|
||||
set => AcidString = $"{value:0.0}";
|
||||
}
|
||||
[ObservableProperty]
|
||||
private bool _isLesewagen;
|
||||
[ObservableProperty]
|
||||
|
@ -172,9 +172,11 @@ namespace Elwig.Windows {
|
||||
Title = $"Traubentransportscheinliste (BKI) speichern unter - Elwig"
|
||||
};
|
||||
if (d.ShowDialog() == true) {
|
||||
Mouse.OverrideCursor = Cursors.AppStarting;
|
||||
using var file = new Bki(d.FileName);
|
||||
await file.ExportAsync(year);
|
||||
Mouse.OverrideCursor = Cursors.Wait;
|
||||
await Task.Run(async () => {
|
||||
using var file = new Bki(d.FileName);
|
||||
await file.ExportAsync(year);
|
||||
});
|
||||
Mouse.OverrideCursor = null;
|
||||
}
|
||||
}
|
||||
@ -933,12 +935,13 @@ namespace Elwig.Windows {
|
||||
"Lieferung löschen", MessageBoxButton.OKCancel, MessageBoxImage.Warning, MessageBoxResult.Cancel);
|
||||
if (r == MessageBoxResult.OK) {
|
||||
Mouse.OverrideCursor = Cursors.AppStarting;
|
||||
using (var ctx = new AppDbContext()) {
|
||||
ctx.Remove(d);
|
||||
await ctx.SaveChangesAsync();
|
||||
try {
|
||||
await DeliveryService.DeleteDelivery(d.LsNr);
|
||||
} catch (Exception exc) {
|
||||
var str = "Der Eintrag konnte nicht in der Datenbank aktualisiert werden!\n\n" + exc.Message;
|
||||
if (exc.InnerException != null) str += "\n\n" + exc.InnerException.Message;
|
||||
MessageBox.Show(str, "Lieferung löschen", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
await RefreshList();
|
||||
await RefreshDeliveryParts();
|
||||
Mouse.OverrideCursor = null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user