Haltungedit erweitert

This commit is contained in:
2023-04-11 15:57:22 +02:00
parent 7999b7ffd0
commit d9e3fdb793
7 changed files with 108 additions and 10 deletions

View File

@@ -62,9 +62,9 @@ namespace SewerStammGen.EntityFramework.Services
throw new NotImplementedException();
}
public Task<Kanal> Update(int id, Kanal entity)
public async Task<Kanal> Update(int id, Kanal entity)
{
throw new NotImplementedException();
return await _nonQueryDataService.Update(id, entity);
}
}
}

View File

@@ -76,6 +76,7 @@ namespace SewerStammGen.HostBuilders
{
return () => new HaltungEditViewModel(
services.GetRequiredService<IHaltungDataService>(),
services.GetRequiredService<ISchachtDataService>(),
services.GetRequiredService<IActualState>()
);
});

View File

@@ -14,6 +14,7 @@
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
<PackageReference Include="Syncfusion.SfGrid.WPF" Version="20.4.0.54" />
</ItemGroup>

View File

@@ -4,6 +4,7 @@ using Shared.Contracts;
using Shared.Domain;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -18,6 +19,40 @@ namespace SewerStammGen.WPF.ViewModel
private readonly IHaltungDataService _kanalDataService;
private Kanal _model;
private ObservableCollection<Schacht> _verfuegbareSchaechte;
public ObservableCollection<Schacht> VerfuegbareSchaechte
{
get => _verfuegbareSchaechte;
}
public Schacht ObereSchacht
{
get => _model.StartSchacht;
set
{
if(_model.StartSchacht != value)
{
_model.StartSchacht = value;
OnPropertyChanged();
}
}
}
public Schacht UntereSchacht
{
get => _model.EndSchacht;
set
{
if(_model.EndSchacht != value)
{
_model.EndSchacht = value;
OnPropertyChanged();
}
}
}
public string Haltungsbezeichnung
{
get => _model.Objektbezeichnung;
@@ -69,14 +104,34 @@ namespace SewerStammGen.WPF.ViewModel
public ICommand Speichern { get; set; }
public HaltungEditViewModel(IHaltungDataService kanalDataService, IActualState actualState)
public HaltungEditViewModel(IHaltungDataService kanalDataService,
ISchachtDataService schachtDataService,
IActualState actualState)
{
_actualState = actualState;
_kanalDataService = kanalDataService;
_verfuegbareSchaechte = new ObservableCollection<Schacht>();
_model = new Kanal();
Speichern = new RelayCommand((x) => SaveKanal());
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()
@@ -87,10 +142,12 @@ namespace SewerStammGen.WPF.ViewModel
private async void LoadModel()
{
_model = await _kanalDataService.Get(_actualState.HaltungID);
OnPropertyChanged(nameof(ObereSchacht));
OnPropertyChanged(nameof(UntereSchacht));
OnPropertyChanged(nameof(Haltungslaenge));
OnPropertyChanged(nameof(Haltungsbezeichnung));
OnPropertyChanged(nameof(Material));
OnPropertyChanged(nameof(Haltungslaenge));
OnPropertyChanged(nameof(Durchmesser));
}
}
}

View File

@@ -0,0 +1,18 @@
using Microsoft.Xaml.Behaviors;
using Syncfusion.UI.Xaml.Grid;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SewerStammGen.WPF.Views
{
public class TextBoxFilterAction : TargetedTriggerAction<SfMultiColumnDropDownControl>
{
protected override void Invoke(object parameter)
{
throw new NotImplementedException();
}
}
}

View File

@@ -3,13 +3,22 @@
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></TextBox>
<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>
@@ -38,6 +47,8 @@
Width="250"
Margin="10,0"
ItemsSource="{Binding VerfuegbareSchaechte}"
SelectedItem="{Binding ObereSchacht, Mode=TwoWay}"
HorizontalAlignment="Left"
VerticalAlignment="Top"
@@ -45,17 +56,21 @@
AllowImmediatePopup="True"
AllowIncrementalFiltering="True"
AutoGenerateColumns="False"
DisplayMember="Title"
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"
@@ -63,11 +78,16 @@
AllowImmediatePopup="True"
AllowIncrementalFiltering="True"
AutoGenerateColumns="False"
DisplayMember="Title"
DisplayMember="Objektbezeichnung"
HeaderTemplate="{StaticResource headerTemplate}"
PopupWidth="400"
ValueMember="Cast"
></syncfusion:SfMultiColumnDropDownControl>
SelectedItem="{Binding UntereSchacht }"
>
<syncfusion:SfMultiColumnDropDownControl.Columns>
<syncfusion:GridTextColumn MappingName="Objektbezeichnung" />
</syncfusion:SfMultiColumnDropDownControl.Columns>
</syncfusion:SfMultiColumnDropDownControl>
<TextBox Grid.Row="2" Grid.Column="1" Margin="5" Text="{Binding Haltungsbezeichnung}" />
</Grid>
@@ -98,7 +118,8 @@
</DockPanel>
</Grid>
<StackPanel Grid.Row="4">
<Button Content="Speichern" />
<Button Content="Speichern" Command="{Binding Speichern}" />
<ListBox ItemsSource="{Binding VerfuegbareSchaechte }" />
</StackPanel>
</Grid>
</Grid>

View File

@@ -8,7 +8,7 @@
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<StackPanel>
<DataGrid ItemsSource="{Binding Haltungen}" SelectedItem="{Binding SelectedHaltung}">
<DataGrid ItemsSource="{Binding Haltungen}" SelectedItem="{Binding SelectedHaltung}" IsReadOnly="False">
</DataGrid>
<Button Content="Hinzufügen" Command="{Binding AddCommand}" />