1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using ReactiveUI;
- namespace RegAuth.ViewModels
- {
- internal class MainViewModel : ViewModelBase
- {
- public void ToAuth()
- {
- MainWindowViewModel.Instance.Uc = new Auth();
- }
- public void ToReg()
- {
- MainWindowViewModel.Instance.Uc = new Reg();
- }
- validViewModel _valid = new validViewModel();
- public validViewModel Valid
- {
- get => _valid;
- set => _valid = value;
- }
- // Ìåòîä äëÿ áûñòðîãî óäàëåíèÿ àäìèíà èç áàçû(÷òîáû íå óäàëÿòü ïî 10 ðàç åãî èç ñàìîé áàçû)
- // ìåòîä íàïèñàí â öåëÿõ áîëåå áûñòðîé ïðîâåðêè ðàáîòû äðóãèõ ìåòîäîâ
-
- public void RemoveAdmin()
- {
- var admin = MainWindowViewModel.myConnection.Users.Where(u => u.Roleid == 1).ToList();
- if (admin.Any())
- {
- MainWindowViewModel.myConnection.Users.RemoveRange(admin);
- MainWindowViewModel.myConnection.SaveChanges();
- MainWindowViewModel.Instance.Uc = new Adminadd();
- }
-
- }
- }
- }
|