From 7db9592dff128bd26893cfd009b29fd0d9744143 Mon Sep 17 00:00:00 2001 From: Damian Wessels Date: Sun, 29 Jan 2023 13:53:50 +0100 Subject: [PATCH] Schlauchliner erweitert --- DaSaSo.Domain/Model/Impregnation.cs | 2 +- DaSaSo.Domain/Model/SewerRehabilation.cs | 2 +- .../PipeLinerServices/IPipeLinerService.cs | 14 +++++++++ .../PipeLinerServices/PipeLinerService.cs | 25 +++++++++++++++ .../SewerObjectService/SewerObjectService.cs | 3 +- DaSaSo.Wpf/App.xaml.cs | 2 +- .../Converters/StringToDateTimeConverter.cs | 31 +++++++++++++++++++ .../AddDbContextHostBuilderExtensions.cs | 12 +++++-- .../Impregnation/ImpregnationEditView.xaml | 2 +- .../Controls/SewerRehabilation.xaml | 22 ++++++++----- .../SewerObject/SewerPipeLinerView.xaml.cs | 5 +++ .../Commands/SaveSewerStammdatenCommand.cs | 1 + .../SewerRhebalationControllViewModel.cs | 14 +++++---- .../ViewModel/ImpregnierungEditViewModel.cs | 12 +++++++ 14 files changed, 127 insertions(+), 20 deletions(-) create mode 100644 DaSaSo.Domain/Services/PipeLinerServices/IPipeLinerService.cs create mode 100644 DaSaSo.Domain/Services/PipeLinerServices/PipeLinerService.cs create mode 100644 DaSaSo.Wpf/Converters/StringToDateTimeConverter.cs diff --git a/DaSaSo.Domain/Model/Impregnation.cs b/DaSaSo.Domain/Model/Impregnation.cs index 95761f5..507c949 100644 --- a/DaSaSo.Domain/Model/Impregnation.cs +++ b/DaSaSo.Domain/Model/Impregnation.cs @@ -12,7 +12,7 @@ namespace DaSaSo.Domain.Model public string Number { get; set; } public decimal Linerlength { get; set; } public bool IsAvaible { get; set; } - public DateOnly Date { get; set; } + public DateTime Date { get; set; } public string LinerNumber { get; set; } public decimal WallThickness { get; set; } } diff --git a/DaSaSo.Domain/Model/SewerRehabilation.cs b/DaSaSo.Domain/Model/SewerRehabilation.cs index 9080dcc..39632ad 100644 --- a/DaSaSo.Domain/Model/SewerRehabilation.cs +++ b/DaSaSo.Domain/Model/SewerRehabilation.cs @@ -9,7 +9,7 @@ namespace DaSaSo.Domain.Model public abstract class SewerRehabilation : DomainObject { public string Operator { get; set; } - public DateOnly Date { get; set; } + public DateTime Date { get; set; } public decimal TemperatureOutdoors { get; set; } public decimal TemperatureSewer { get; set; } public string Weather { get; set; } diff --git a/DaSaSo.Domain/Services/PipeLinerServices/IPipeLinerService.cs b/DaSaSo.Domain/Services/PipeLinerServices/IPipeLinerService.cs new file mode 100644 index 0000000..3ae79b0 --- /dev/null +++ b/DaSaSo.Domain/Services/PipeLinerServices/IPipeLinerService.cs @@ -0,0 +1,14 @@ +using DaSaSo.Domain.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DaSaSo.Domain.Services.PipeLinerServices +{ + public interface IPipeLinerService + { + Task CreatePipeLiner(SewerObject sewerObject); + } +} diff --git a/DaSaSo.Domain/Services/PipeLinerServices/PipeLinerService.cs b/DaSaSo.Domain/Services/PipeLinerServices/PipeLinerService.cs new file mode 100644 index 0000000..4cc2311 --- /dev/null +++ b/DaSaSo.Domain/Services/PipeLinerServices/PipeLinerService.cs @@ -0,0 +1,25 @@ +using DaSaSo.Domain.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DaSaSo.Domain.Services.PipeLinerServices +{ + public class PipeLinerService : IPipeLinerService + { + private readonly IDataService _sewerObjectService; + public PipeLinerService(IDataService sewerObjectService) + { + _sewerObjectService = sewerObjectService; + } + + public async Task CreatePipeLiner(SewerObject sewerObject) + { + sewerObject.PipeLiner = new PipeLiner(); + await _sewerObjectService.Update(sewerObject.Id,sewerObject); + return sewerObject.PipeLiner; + } + } +} diff --git a/DaSaSo.Domain/Services/SewerObjectService/SewerObjectService.cs b/DaSaSo.Domain/Services/SewerObjectService/SewerObjectService.cs index 8a4c05e..69c6f18 100644 --- a/DaSaSo.Domain/Services/SewerObjectService/SewerObjectService.cs +++ b/DaSaSo.Domain/Services/SewerObjectService/SewerObjectService.cs @@ -21,7 +21,8 @@ namespace DaSaSo.Domain.Services.SewerObjectService SewerObject sewerObject = new SewerObject() { BuildingSite = aktuellBaustelle, - StreetName = "Bitte aktualisieren!" + StreetName = "Bitte aktualisieren!", + //PipeLiner = new PipeLiner() }; aktuellBaustelle.SewerObjects.Add(sewerObject); await _buildingsiteService.Update(aktuellBaustelle.Id, aktuellBaustelle); diff --git a/DaSaSo.Wpf/App.xaml.cs b/DaSaSo.Wpf/App.xaml.cs index 5505667..427096f 100644 --- a/DaSaSo.Wpf/App.xaml.cs +++ b/DaSaSo.Wpf/App.xaml.cs @@ -75,7 +75,7 @@ namespace DaSaSo.Wpf try { Exception ex = (Exception)e.ExceptionObject; - string text = "An application error occured. Plrease contact the Administrator with the following information:\n\n"; + string text = "An application error occured. Please contact the Administrator with the following information:\n\n"; MessageBox.Show(text + " " + ex.Message + "\n\n" + ex.StackTrace); } catch(Exception ex2) diff --git a/DaSaSo.Wpf/Converters/StringToDateTimeConverter.cs b/DaSaSo.Wpf/Converters/StringToDateTimeConverter.cs new file mode 100644 index 0000000..412e3a1 --- /dev/null +++ b/DaSaSo.Wpf/Converters/StringToDateTimeConverter.cs @@ -0,0 +1,31 @@ +using System; +using System.Globalization; +using System.Windows.Data; + +namespace DaSaSo.Wpf.Converters +{ + [ValueConversion(typeof(DateTime), typeof(String))] + public class StringToDateTimeConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + DateTime val = (DateTime)value; + return string.Format("{0}.{1}.{2} {3}:{4}",val.Day,val.Month, val.Year, val.Hour, val.Minute); + + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + DateTime result; + if (DateTime.TryParse((value as string), out result)) + { + return result; + } + else + { + throw new Exception(); + } + + } + } +} diff --git a/DaSaSo.Wpf/HostBuilders/AddDbContextHostBuilderExtensions.cs b/DaSaSo.Wpf/HostBuilders/AddDbContextHostBuilderExtensions.cs index 984a9b2..1bd44f9 100644 --- a/DaSaSo.Wpf/HostBuilders/AddDbContextHostBuilderExtensions.cs +++ b/DaSaSo.Wpf/HostBuilders/AddDbContextHostBuilderExtensions.cs @@ -19,19 +19,27 @@ namespace DaSaSo.Wpf.HostBuilders host.ConfigureServices((context,services) => { string connectionString = ""; - Action configureDbContext = null; + Action configureDbContext; string databaseToUse = context.Configuration.GetConnectionString("databaseToUse"); Trace.WriteLine(databaseToUse); if(databaseToUse.Equals("default")) { connectionString = context.Configuration.GetConnectionString("default"); - configureDbContext = o => o.UseNpgsql(connectionString); + configureDbContext = o => + { + o.UseNpgsql(connectionString); + AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); + }; } else if(databaseToUse.Equals("sqlite")) { connectionString = context.Configuration.GetConnectionString("sqlite"); configureDbContext = o => o.UseSqlite(connectionString); } + else + { + throw new NotImplementedException("Database Type not implementent" + databaseToUse); + } services.AddDbContext(configureDbContext); diff --git a/DaSaSo.Wpf/View/Impregnation/ImpregnationEditView.xaml b/DaSaSo.Wpf/View/Impregnation/ImpregnationEditView.xaml index 53947e5..4ecdfaf 100644 --- a/DaSaSo.Wpf/View/Impregnation/ImpregnationEditView.xaml +++ b/DaSaSo.Wpf/View/Impregnation/ImpregnationEditView.xaml @@ -34,7 +34,7 @@ - +