Imprägnierungen können gespeichert werden
This commit is contained in:
28
DaSaSo.ViewModel/Commands/SaveImpregnationCommand.cs
Normal file
28
DaSaSo.ViewModel/Commands/SaveImpregnationCommand.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using DaSaSo.Domain.Model;
|
||||
using DaSaSo.Domain.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DaSaSo.ViewModel.Commands
|
||||
{
|
||||
internal class SaveImpregnationCommand : AsyncCommandBase
|
||||
{
|
||||
private IDataService<Impregnation> _impregnationService;
|
||||
private ImpregnierungEditViewModel _impregnationEditViewModel;
|
||||
|
||||
public SaveImpregnationCommand(ImpregnierungEditViewModel impregnierungEditViewModel, IDataService<Impregnation> dataService)
|
||||
{
|
||||
_impregnationService = dataService;
|
||||
_impregnationEditViewModel = impregnierungEditViewModel;
|
||||
}
|
||||
public override async Task ExecuteAsync(object? parameter)
|
||||
{
|
||||
_impregnationEditViewModel.Model = await _impregnationService.Update(_impregnationEditViewModel.Model.Id, _impregnationEditViewModel.Model);
|
||||
Trace.WriteLine("Daten gespeichert");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,21 @@
|
||||
using DaSaSo.Domain.Model;
|
||||
using DaSaSo.Domain.Services;
|
||||
using DaSaSo.ViewModel.Commands;
|
||||
using DaSaSo.ViewModel.Interface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace DaSaSo.ViewModel
|
||||
{
|
||||
public class ImpregnierungEditViewModel : BaseViewModel
|
||||
{
|
||||
private Impregnation _model;
|
||||
public ICommand SaveImpregnation { get; set; }
|
||||
public Impregnation Model { get => _model; set => _model = value; }
|
||||
|
||||
public int DN
|
||||
{
|
||||
@@ -53,9 +58,10 @@ namespace DaSaSo.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public ImpregnierungEditViewModel(IActualProject actualProject)
|
||||
public ImpregnierungEditViewModel(IActualProject actualProject, IDataService<Impregnation> dataservice)
|
||||
{
|
||||
_model = actualProject.AktuellImpregnation;
|
||||
SaveImpregnation = new SaveImpregnationCommand(this,dataservice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,8 @@ namespace DaSaSo.Wpf.HostBuilders
|
||||
services.AddTransient<CreateViewModel<ImpregnierungEditViewModel>>(services =>
|
||||
{
|
||||
return () => new ImpregnierungEditViewModel(
|
||||
services.GetRequiredService<IActualProject>()
|
||||
services.GetRequiredService<IActualProject>(),
|
||||
services.GetRequiredService<IDataService<Impregnation>>()
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -37,6 +37,6 @@
|
||||
<TextBox Grid.Column="1" Grid.Row="5" Text="" />
|
||||
<CheckBox Grid.Column="1" Grid.Row="6" Content="Ja" Style="{StaticResource checkBoxCircleSmall}"/>
|
||||
|
||||
<Button Grid.Row="7" Grid.ColumnSpan="2" Content="Speichern" />
|
||||
<Button Grid.Row="7" Grid.ColumnSpan="2" Content="Speichern" Command="{Binding SaveImpregnation}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
Reference in New Issue
Block a user