File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,21 +7,21 @@ namespace Desktop.Tasks;
77
88public partial class TaskEditing : Window
99{
10+ private readonly TaskEditingViewModel viewModel ;
11+
1012 public TaskEditing ( Task original )
1113 {
1214 InitializeComponent ( ) ;
1315
14- this . original = original ;
16+ viewModel = new TaskEditingViewModel ( original ) ;
17+
1518 Name . Text = original . Name ;
1619 Description . Text = original . Description ;
1720 }
1821
19- private readonly Task original ;
20-
2122 private void SaveTask ( object sender , RoutedEventArgs e )
2223 {
23- original . Name = Name . Text ;
24- original . Description = Description . Text ;
24+ viewModel . Save . Execute ( ( Name . Text , Description . Text ) ) ;
2525
2626 Close ( ) ;
2727 }
Original file line number Diff line number Diff line change 1+ using System . Windows . Input ;
2+ using CommunityToolkit . Mvvm . Input ;
3+ using Desktop . Common ;
4+ using Task = Desktop . Domain . Task ;
5+
6+ namespace Desktop . Tasks ;
7+
8+ public class TaskEditingViewModel : ViewModelBase
9+ {
10+ private readonly Task taskBeingEdited ;
11+
12+ public TaskEditingViewModel ( Task taskBeingEdited )
13+ {
14+ this . taskBeingEdited = taskBeingEdited ;
15+
16+ Save = new RelayCommand < ( string , string ) > ( args =>
17+ {
18+ var ( name , description ) = args ;
19+
20+ taskBeingEdited . Name = name ;
21+ taskBeingEdited . Description = description ;
22+ } ) ;
23+ }
24+
25+ public ICommand Save { get ; }
26+ }
You can’t perform that action at this time.
0 commit comments