AddTradeNetworksViewViewModel.cs 916 B

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using System.Collections.Generic;
  3. using ReactiveUI;
  4. using Acosta.Models;
  5. using Acosta.Views;
  6. using Avalonia.Controls;
  7. namespace Acosta.ViewModels
  8. {
  9. public class AddTradeNetworksViewViewModel : ReactiveObject
  10. {
  11. SuharevaContext myConnection;
  12. TradeNetwork currentTrade;
  13. private UserControl uct = new AddTradeNetworksView();
  14. public UserControl UCT { get => uct; set => this.RaiseAndSetIfChanged(ref uct, value); }
  15. public AddTradeNetworksViewViewModel(SuharevaContext myConnection)
  16. {
  17. this.myConnection = myConnection;
  18. CurrentTrade = new TradeNetwork();
  19. myConnection.Add(CurrentTrade);
  20. }
  21. public TradeNetwork CurrentTrade { get => currentTrade; set => currentTrade = value; }
  22. public void SaveNetwork()
  23. {
  24. myConnection.SaveChanges();
  25. UCT = new TradeNetworksView();
  26. }
  27. }
  28. }