Ohne Syncfusion
This commit is contained in:
38
SewerStammGen/Commands/HaltungEditSaveCommand.cs
Normal file
38
SewerStammGen/Commands/HaltungEditSaveCommand.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using SewerStammGen.Shared.Contracts;
|
||||
using SewerStammGen.WPF.ViewModel;
|
||||
using Shared.Contracts;
|
||||
using Shared.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SewerStammGen.WPF.Commands
|
||||
{
|
||||
internal class HaltungEditSaveCommand : AsyncCommandBase
|
||||
{
|
||||
private HaltungEditViewModel haltungEditViewModel;
|
||||
private IDataService<Kanal> kanalDataService;
|
||||
private ISchachtService schachtService;
|
||||
|
||||
public HaltungEditSaveCommand(HaltungEditViewModel haltungEditViewModel, IDataService<Kanal> kanalDataService, ISchachtService schachtService)
|
||||
{
|
||||
this.haltungEditViewModel = haltungEditViewModel;
|
||||
this.kanalDataService = kanalDataService;
|
||||
this.schachtService = schachtService;
|
||||
}
|
||||
|
||||
public override async Task ExecuteAsync(object? parameter)
|
||||
{
|
||||
if(haltungEditViewModel._oberePunkt != haltungEditViewModel.Model.StartSchacht.Objektbezeichnung)
|
||||
{
|
||||
Schacht s = await schachtService.FindSchachtByNameAndProjektID(haltungEditViewModel._oberePunkt, haltungEditViewModel.Model.Projekt.Id);
|
||||
haltungEditViewModel.Model.StartSchacht = s;
|
||||
}
|
||||
haltungEditViewModel.Model = await kanalDataService.Update(haltungEditViewModel.Model.Id, haltungEditViewModel.Model);
|
||||
Trace.WriteLine("Daten gespeichert");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,11 @@ namespace SewerStammGen.HostBuilders
|
||||
if (databaseToUse.Equals("default"))
|
||||
{
|
||||
connectionString = context.Configuration.GetConnectionString("default");
|
||||
configureDbContext = o => o.UseNpgsql(connectionString);
|
||||
configureDbContext = o =>
|
||||
{
|
||||
o.EnableSensitiveDataLogging();
|
||||
o.UseNpgsql(connectionString);
|
||||
};
|
||||
}
|
||||
else if (databaseToUse.Equals("sqlite"))
|
||||
{
|
||||
|
||||
@@ -72,11 +72,11 @@ namespace SewerStammGen.HostBuilders
|
||||
);
|
||||
});
|
||||
|
||||
services.AddSingleton<CreateViewModel<HaltungEditViewModel>>(services =>
|
||||
services.AddTransient<CreateViewModel<HaltungEditViewModel>>(services =>
|
||||
{
|
||||
return () => new HaltungEditViewModel(
|
||||
services.GetRequiredService<IHaltungDataService>(),
|
||||
services.GetRequiredService<ISchachtDataService>(),
|
||||
services.GetRequiredService<ISchachtService>(),
|
||||
services.GetRequiredService<IActualState>()
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using SewerStammGen.Shared.Contracts;
|
||||
using SewerStammGen.WPF.Commands;
|
||||
using SewerStammGen.WPF.ViewModel.State;
|
||||
using Shared.Contracts;
|
||||
using Shared.Domain;
|
||||
@@ -17,41 +18,48 @@ namespace SewerStammGen.WPF.ViewModel
|
||||
{
|
||||
private readonly IActualState _actualState;
|
||||
private readonly IHaltungDataService _kanalDataService;
|
||||
private readonly ISchachtService _schachtService;
|
||||
private Kanal _model;
|
||||
|
||||
private ObservableCollection<Schacht> _verfuegbareSchaechte;
|
||||
|
||||
public ObservableCollection<Schacht> VerfuegbareSchaechte
|
||||
public Kanal Model
|
||||
{
|
||||
get => _verfuegbareSchaechte;
|
||||
}
|
||||
|
||||
|
||||
public Schacht ObereSchacht
|
||||
{
|
||||
get => _model.StartSchacht;
|
||||
get => _model;
|
||||
set
|
||||
{
|
||||
if(_model.StartSchacht != value)
|
||||
_model = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string _oberePunkt { get; set; }
|
||||
public string _unterePunkt { get; set; }
|
||||
|
||||
public string ObereSchacht
|
||||
{
|
||||
get => _oberePunkt;
|
||||
|
||||
set
|
||||
{
|
||||
if (_oberePunkt != value)
|
||||
{
|
||||
_model.StartSchacht = value;
|
||||
_oberePunkt = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Schacht UntereSchacht
|
||||
public string UntereSchacht
|
||||
{
|
||||
get => _model.EndSchacht;
|
||||
get => _unterePunkt;
|
||||
set
|
||||
{
|
||||
if(_model.EndSchacht != value)
|
||||
if (_unterePunkt != value)
|
||||
{
|
||||
_model.EndSchacht = value;
|
||||
_unterePunkt = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public string Haltungsbezeichnung
|
||||
{
|
||||
@@ -104,44 +112,26 @@ namespace SewerStammGen.WPF.ViewModel
|
||||
|
||||
public ICommand Speichern { get; set; }
|
||||
|
||||
public HaltungEditViewModel(IHaltungDataService kanalDataService,
|
||||
ISchachtDataService schachtDataService,
|
||||
public HaltungEditViewModel(IHaltungDataService kanalDataService,
|
||||
ISchachtService schachtService,
|
||||
IActualState actualState)
|
||||
{
|
||||
_actualState = actualState;
|
||||
_kanalDataService = kanalDataService;
|
||||
_verfuegbareSchaechte = new ObservableCollection<Schacht>();
|
||||
_schachtService = schachtService;
|
||||
_model = new Kanal();
|
||||
Speichern = new RelayCommand((x) => SaveKanal());
|
||||
Speichern = new HaltungEditSaveCommand(this, kanalDataService, schachtService);
|
||||
|
||||
LoadModel();
|
||||
LoadSchaechte(schachtDataService);
|
||||
|
||||
}
|
||||
|
||||
private async void LoadSchaechte(ISchachtDataService schachtDataService)
|
||||
{
|
||||
var s = await schachtDataService.GetAll(_actualState.ProjektID);
|
||||
InitCollection(_verfuegbareSchaechte, s);
|
||||
|
||||
}
|
||||
|
||||
private void InitCollection(ObservableCollection<Schacht> dst, IEnumerable<Schacht> src)
|
||||
{
|
||||
dst.Clear();
|
||||
foreach (var srcItem in src) {
|
||||
dst.Add(srcItem);
|
||||
}
|
||||
OnPropertyChanged(nameof(VerfuegbareSchaechte));
|
||||
}
|
||||
|
||||
private void SaveKanal()
|
||||
{
|
||||
_kanalDataService.Update(_model.Id, _model);
|
||||
}
|
||||
|
||||
private async void LoadModel()
|
||||
{
|
||||
_model = await _kanalDataService.Get(_actualState.HaltungID);
|
||||
UntereSchacht = _model.EndSchacht.Objektbezeichnung;
|
||||
ObereSchacht = _model.StartSchacht.Objektbezeichnung;
|
||||
OnPropertyChanged(nameof(ObereSchacht));
|
||||
OnPropertyChanged(nameof(UntereSchacht));
|
||||
OnPropertyChanged(nameof(Haltungslaenge));
|
||||
|
||||
@@ -3,24 +3,10 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:behaviors="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
|
||||
xmlns:local="clr-namespace:SewerStammGen.WPF.Views"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<UserControl.Resources>
|
||||
<DataTemplate x:Key="headerTemplate">
|
||||
<TextBox x:Name="searchTextBox" Margin="4" Text="{Binding Path=DataContext.SearchText, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=syncfusion:SfMultiColumnDropDownControl}}">
|
||||
<behaviors:Interaction.Triggers>
|
||||
<behaviors:EventTrigger EventName="TextChanged">
|
||||
<local:TextBoxFilterAction TargetObject="{x:Reference Name=MultiColumnControl5}" />
|
||||
</behaviors:EventTrigger>
|
||||
|
||||
</behaviors:Interaction.Triggers>
|
||||
|
||||
</TextBox>
|
||||
</DataTemplate>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
@@ -43,51 +29,8 @@
|
||||
<Label Grid.Row="1" Grid.Column="0" Content="Untere Schacht" />
|
||||
<Label Grid.Row="2" Grid.Column="0" Content="Haltungsbezeichnung" />
|
||||
|
||||
<syncfusion:SfMultiColumnDropDownControl Grid.Column="1" Grid.Row="0"
|
||||
Width="250"
|
||||
|
||||
Margin="10,0"
|
||||
ItemsSource="{Binding VerfuegbareSchaechte}"
|
||||
SelectedItem="{Binding ObereSchacht, Mode=TwoWay}"
|
||||
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top"
|
||||
AllowAutoComplete="True"
|
||||
AllowImmediatePopup="True"
|
||||
AllowIncrementalFiltering="True"
|
||||
AutoGenerateColumns="False"
|
||||
DisplayMember="Objektbezeichnung"
|
||||
HeaderTemplate="{StaticResource headerTemplate}"
|
||||
PopupWidth="400"
|
||||
ValueMember="Cast"
|
||||
>
|
||||
<syncfusion:SfMultiColumnDropDownControl.Columns>
|
||||
<syncfusion:GridTextColumn MappingName="Objektbezeichnung" />
|
||||
</syncfusion:SfMultiColumnDropDownControl.Columns>
|
||||
|
||||
</syncfusion:SfMultiColumnDropDownControl>
|
||||
<syncfusion:SfMultiColumnDropDownControl Grid.Column="1" Grid.Row="1"
|
||||
Width="250"
|
||||
|
||||
Margin="10,0"
|
||||
ItemsSource="{Binding VerfuegbareSchaechte}"
|
||||
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top"
|
||||
AllowAutoComplete="True"
|
||||
AllowImmediatePopup="True"
|
||||
AllowIncrementalFiltering="True"
|
||||
AutoGenerateColumns="False"
|
||||
DisplayMember="Objektbezeichnung"
|
||||
HeaderTemplate="{StaticResource headerTemplate}"
|
||||
PopupWidth="400"
|
||||
ValueMember="Cast"
|
||||
SelectedItem="{Binding UntereSchacht }"
|
||||
>
|
||||
<syncfusion:SfMultiColumnDropDownControl.Columns>
|
||||
<syncfusion:GridTextColumn MappingName="Objektbezeichnung" />
|
||||
</syncfusion:SfMultiColumnDropDownControl.Columns>
|
||||
</syncfusion:SfMultiColumnDropDownControl>
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Margin="5" Text="{Binding ObereSchacht}" />
|
||||
<TextBox Grid.Row="1" Grid.Column="1" Margin="5" Text="{Binding UntereSchacht}" />
|
||||
<TextBox Grid.Row="2" Grid.Column="1" Margin="5" Text="{Binding Haltungsbezeichnung}" />
|
||||
</Grid>
|
||||
|
||||
@@ -119,7 +62,7 @@
|
||||
</Grid>
|
||||
<StackPanel Grid.Row="4">
|
||||
<Button Content="Speichern" Command="{Binding Speichern}" />
|
||||
<ListBox ItemsSource="{Binding VerfuegbareSchaechte }" />
|
||||
<!--<ListBox ItemsSource="{Binding VerfuegbareSchaechte }" />-->
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
Reference in New Issue
Block a user