|
@@ -12,83 +12,16 @@ namespace AvaloniaApplication5.ViewModels
|
|
{
|
|
{
|
|
public class MainWindowViewModel : ViewModelBase
|
|
public class MainWindowViewModel : ViewModelBase
|
|
{
|
|
{
|
|
- _1234Context DBConnect = new _1234Context();
|
|
|
|
|
|
+ static _1234Context DBConnect = new _1234Context();
|
|
|
|
|
|
private UserControl uc = new PageLogin();
|
|
private UserControl uc = new PageLogin();
|
|
- public UserControl UC { get => uc;
|
|
|
|
- set => this.RaiseAndSetIfChanged(ref uc, value); }
|
|
|
|
|
|
+ public UserControl UC { get => uc; set => this.RaiseAndSetIfChanged(ref uc, value); }
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ #region VMLogin
|
|
|
|
|
|
PageLoginViewModel pageLoginVM = new PageLoginViewModel();
|
|
PageLoginViewModel pageLoginVM = new PageLoginViewModel();
|
|
public PageLoginViewModel PageLoginVM { get => pageLoginVM; set => pageLoginVM = value; }
|
|
public PageLoginViewModel PageLoginVM { get => pageLoginVM; set => pageLoginVM = value; }
|
|
- public PageUserCabinetViewModel PageUCabinetVM { get => pageUCabinetVM; set => pageUCabinetVM = value; }
|
|
|
|
-
|
|
|
|
- private PageUserCabinetViewModel pageUCabinetVM;
|
|
|
|
- #region VMadmin
|
|
|
|
-
|
|
|
|
- UserControl ucAdmin;
|
|
|
|
- public UserControl UCAdmin
|
|
|
|
- {
|
|
|
|
- get => ucAdmin;
|
|
|
|
- set => this.RaiseAndSetIfChanged(ref ucAdmin, value);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public MainWindowViewModel()
|
|
|
|
- {
|
|
|
|
- userList = DBConnect.Logintables.Include(x => x.IdRoleNavigation).Include(x => x.User.IdGenderNavigation).ToList();
|
|
|
|
- }
|
|
|
|
- List<Logintable> userList;
|
|
|
|
- public List<Logintable> UserList { get => userList; set =>this.RaiseAndSetIfChanged(ref userList,value); }
|
|
|
|
- public void EditUser(int id)
|
|
|
|
- {
|
|
|
|
- PageUCabinetVM = id==0? new PageUserCabinetViewModel(DBConnect):new PageUserCabinetViewModel(DBConnect, id);
|
|
|
|
- UCAdmin = new PageUserCabinet();
|
|
|
|
- }
|
|
|
|
- public List<string> OrdersName => new List<string>() { "По возрастанию", "По убыванию" };
|
|
|
|
- string orderByName = "По возрастанию";
|
|
|
|
- public string OrderByName {
|
|
|
|
- get => orderByName;
|
|
|
|
- set
|
|
|
|
- {
|
|
|
|
- orderByName = value;
|
|
|
|
- switch (value)
|
|
|
|
- {
|
|
|
|
- case "По возрастанию":
|
|
|
|
- UserList = UserList.OrderBy(x => x.User.Name).ToList();
|
|
|
|
- break;
|
|
|
|
- case "По убыванию":
|
|
|
|
- UserList = UserList.OrderByDescending(x => x.User.Name).ToList();
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public List<string> Genders//список полов для фильтра
|
|
|
|
- {
|
|
|
|
- get
|
|
|
|
- {
|
|
|
|
- List<string> newlist = new List<string>() {"Любой"};
|
|
|
|
- newlist.AddRange(DBConnect.Genders.Select(x => x.Gender1).ToList());
|
|
|
|
- return newlist;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public string FilterByGender { get => filterByGender;
|
|
|
|
- set
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
- if (!(value =="Любой" || value == null))
|
|
|
|
- UserList = UserList.Where(x => x.User.IdGenderNavigation.Gender1 == value).ToList();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- string filterByGender = "Любой";
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- #endregion
|
|
|
|
-
|
|
|
|
public void LoadPageList()
|
|
public void LoadPageList()
|
|
{
|
|
{
|
|
Logintable? currentUser = DBConnect.Logintables.FirstOrDefault(x => x.Login == PageLoginVM.Login && x.Password == PageLoginVM.Password);
|
|
Logintable? currentUser = DBConnect.Logintables.FirstOrDefault(x => x.Login == PageLoginVM.Login && x.Password == PageLoginVM.Password);
|
|
@@ -100,12 +33,41 @@ namespace AvaloniaApplication5.ViewModels
|
|
UC = new PageUserList();
|
|
UC = new PageUserList();
|
|
break;
|
|
break;
|
|
case 2:
|
|
case 2:
|
|
- PageUCabinetVM = new PageUserCabinetViewModel(DBConnect,currentUser.Id);
|
|
|
|
|
|
+ PageUCabinetVM = new PageUserCabinetViewModel(DBConnect, currentUser.Id);
|
|
UC = new PageUserCabinet();
|
|
UC = new PageUserCabinet();
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else PageLoginVM.Message = "Пользователь отсутствует в системе, либо указанные данные введены неверно";
|
|
else PageLoginVM.Message = "Пользователь отсутствует в системе, либо указанные данные введены неверно";
|
|
}
|
|
}
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ #region VMUserCabinet
|
|
|
|
+
|
|
|
|
+ private PageUserCabinetViewModel pageUCabinetVM;
|
|
|
|
+ public PageUserCabinetViewModel PageUCabinetVM { get => pageUCabinetVM; set => pageUCabinetVM = value; }
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ #region VMadmin
|
|
|
|
+ private PageUserListViewModel pageUserListViewVM = new PageUserListViewModel(DBConnect);
|
|
|
|
+ public PageUserListViewModel PageUserListViewVM { get => pageUserListViewVM; set => pageUserListViewVM = value; }
|
|
|
|
+
|
|
|
|
+ UserControl ucAdmin;
|
|
|
|
+ public UserControl UCAdmin
|
|
|
|
+ {
|
|
|
|
+ get => ucAdmin;
|
|
|
|
+ set => this.RaiseAndSetIfChanged(ref ucAdmin, value);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void EditUser(int id)
|
|
|
|
+ {
|
|
|
|
+ PageUCabinetVM = id == 0 ? new PageUserCabinetViewModel(DBConnect) : new PageUserCabinetViewModel(DBConnect, id);
|
|
|
|
+ UCAdmin = new PageUserCabinet();
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|