|
@@ -15,6 +15,7 @@ using System.Runtime.CompilerServices;
|
|
|
using System.Windows.Input;
|
|
|
using System.Collections.ObjectModel;
|
|
|
using Avalonia.Threading;
|
|
|
+using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
namespace AvaloniaApplication1.ViewModels
|
|
|
{
|
|
@@ -38,7 +39,7 @@ namespace AvaloniaApplication1.ViewModels
|
|
|
public string Animal { get => animal; set => this.RaiseAndSetIfChanged(ref animal, value); }
|
|
|
public List<Gender> Genders { get => genders; set => this.RaiseAndSetIfChanged(ref genders, value); }
|
|
|
public List<Property> Property { get => property; set => this.RaiseAndSetIfChanged(ref property, value); }
|
|
|
- public List<Property> Property2 { get => property; set => this.RaiseAndSetIfChanged(ref property, value); }
|
|
|
+ public List<Property> Property2 { get => property2; set => this.RaiseAndSetIfChanged(ref property2, value); }
|
|
|
public List<Property> SmeshProperty { get => smeshProperty; set => this.RaiseAndSetIfChanged(ref smeshProperty, value); }
|
|
|
public Gender SelectedGender { get => selectedGender; set => this.RaiseAndSetIfChanged(ref selectedGender, value); }
|
|
|
public Property SelectedProperty { get => selectedProperty; set { selectedProperty = value; AddNewItem(); } }
|
|
@@ -51,7 +52,7 @@ namespace AvaloniaApplication1.ViewModels
|
|
|
public AddSmeshViewModel()
|
|
|
{
|
|
|
property = myConnection.Properties.ToList();
|
|
|
- property2 = property.ToList();
|
|
|
+ property2 = myConnection.Properties.ToList();
|
|
|
selectedProperty = property.FirstOrDefault();
|
|
|
genders = myConnection.Genders.ToList();
|
|
|
}
|
|
@@ -103,6 +104,20 @@ namespace AvaloniaApplication1.ViewModels
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+ public async void DeleteItem(int id)
|
|
|
+ {
|
|
|
+ var newItem = await myConnection.Properties.FirstOrDefaultAsync(x=> x.Id ==id);
|
|
|
+ await Dispatcher.UIThread.InvokeAsync(() =>
|
|
|
+ {
|
|
|
+ if (newItem != null)
|
|
|
+ {
|
|
|
+ Items.Remove(newItem);
|
|
|
+ Property = Property2;
|
|
|
+ Property = Property.Except(Items).ToList();
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
protected void OnPropertyChanged([CallerMemberName] string propertyName = "")
|
|
|
{
|