123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- using Avalonia.Controls;
- using AvaloniaApplication1.Models;
- using ReactiveUI;
- using System.Linq;
- using System.Net;
- namespace AvaloniaApplication1.ViewModels
- {
- public class MainWindowViewModel : ViewModelBase
- {
- public static ScoolContext DB = new ScoolContext();
- UserControl us = new Authorization();
- public UserControl US
- {
- get => us;
- set => this.RaiseAndSetIfChanged(ref us, value);
- }
- AuthorizationViewModel authorizationvm = new AuthorizationViewModel();
- PersonalPageViewModel personalpagevm;
- CoursesListViewModel coursesvm = new CoursesListViewModel();
- public AuthorizationViewModel AuthorizationVM
- {
- get => authorizationvm;
- set => authorizationvm = value;
- }
- public PersonalPageViewModel PPVM
- {
- get => personalpagevm;
- set => personalpagevm = value;
- }
- public CoursesListViewModel CourseVM
- {
- get => coursesvm;
- set => coursesvm = value;
- }
- public void GoAuth()
- {
- int index = AuthorizationVM.Auth();
- if (index != 0)
- {
- if(DB.Users.Where(x=>x.IdUser == index).Select(x=>x.IdRole).FirstOrDefault()==2)
- {
- PPVM = new PersonalPageViewModel(index);
- US = new PersonalPage();
- }
- else
- {
- US = new CoursesList();
- }
- }
- }
- }
- }
|