MainViewModel.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using ReactiveUI;
  5. namespace RegAuth.ViewModels
  6. {
  7. internal class MainViewModel : ViewModelBase
  8. {
  9. public void ToAuth()
  10. {
  11. MainWindowViewModel.Instance.Uc = new Auth();
  12. }
  13. public void ToReg()
  14. {
  15. MainWindowViewModel.Instance.Uc = new Reg();
  16. }
  17. validViewModel _valid = new validViewModel();
  18. public validViewModel Valid
  19. {
  20. get => _valid;
  21. set => _valid = value;
  22. }
  23. // Ìåòîä äëÿ áûñòðîãî óäàëåíèÿ àäìèíà èç áàçû(÷òîáû íå óäàëÿòü ïî 10 ðàç åãî èç ñàìîé áàçû)
  24. // ìåòîä íàïèñàí â öåëÿõ áîëåå áûñòðîé ïðîâåðêè ðàáîòû äðóãèõ ìåòîäîâ
  25. public void RemoveAdmin()
  26. {
  27. var admin = MainWindowViewModel.myConnection.Users.Where(u => u.Roleid == 1).ToList();
  28. if (admin.Any())
  29. {
  30. MainWindowViewModel.myConnection.Users.RemoveRange(admin);
  31. MainWindowViewModel.myConnection.SaveChanges();
  32. MainWindowViewModel.Instance.Uc = new Adminadd();
  33. }
  34. }
  35. }
  36. }