using Avalonia.Controls; using AvaloniaExample.Models; using AvaloniaExample.Views; using Microsoft.EntityFrameworkCore; using ReactiveUI; using System; using System.Linq; using Tmds.DBus.Protocol; namespace AvaloniaExample.ViewModels { public class MainWindowViewModel : ViewModelBase { UserControl uc = new Page1(); Page1ViewModel page1VM = new Page1ViewModel(); public Page1ViewModel Page1VM { get => page1VM; set => page1VM = value; } public UserControl UC { get => uc; set => this.RaiseAndSetIfChanged(ref uc, value); } public static UsersContext connection = new UsersContext(); UserProfileViewModel page3VM; public UserProfileViewModel Page3VM { get => page3VM; set => page3VM = value; } public void LoadPage2() { Login? curUser = connection.Logins.FirstOrDefault(x => x.Value == Page1VM.Login && x.Password == Page1VM.Password); if (curUser == null) { Page1VM.Message = "Error. Try again"; Page1VM.Login = ""; Page1VM.Password = ""; } else { switch (curUser.Role) { case "администратор": UC = new Page2(); break; default: Page3VM = new UserProfileViewModel(connection, curUser.Value); UC = new Page3(); break; } } var u = connection.UsersInfos.FirstOrDefault(); var l = connection.Logins.FirstOrDefault(); } public void SaveChanges() => connection.SaveChanges(); } }