|
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
+using AvaloniaApplication2.Views;
|
|
|
using Avalonia.Controls;
|
|
|
using Avalonia.Media.TextFormatting;
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
@@ -13,8 +14,6 @@ namespace AvaloniaApplication2.ViewModels
|
|
|
{
|
|
|
public partial class PageForAdminViewModel:ViewModelBase
|
|
|
{
|
|
|
- ChernoshchekovaContext db = new ChernoshchekovaContext();
|
|
|
-
|
|
|
[ObservableProperty] List<User> users;
|
|
|
[ObservableProperty] List<User> users0;
|
|
|
[ObservableProperty] string textFind;
|
|
@@ -23,9 +22,9 @@ namespace AvaloniaApplication2.ViewModels
|
|
|
|
|
|
[ObservableProperty] List<Gender> gendersList;
|
|
|
|
|
|
- public PageForAdminViewModel(List<User> users)
|
|
|
+ public PageForAdminViewModel()
|
|
|
{
|
|
|
- users = db.Users.Include(x => x.Logined.IdRole).ToList();
|
|
|
+ users = db.Users.Include(x=>x.GenderNavigation).ToList();
|
|
|
genders =
|
|
|
[
|
|
|
new Gender() {NameGender = "Сбросить фильтр", IdGender = 0},
|
|
@@ -33,16 +32,17 @@ namespace AvaloniaApplication2.ViewModels
|
|
|
];
|
|
|
users0 = users;
|
|
|
}
|
|
|
+ partial void OnTextFindChanged(string value) => AllFilters();
|
|
|
|
|
|
public void DateSort(int idCB)
|
|
|
{
|
|
|
switch (idCB)
|
|
|
{
|
|
|
case 1:
|
|
|
- users = users.OrderBy(x => x.BirthDate).ToList();
|
|
|
+ Users = Users.OrderBy(x => x.BirthDate).ToList();
|
|
|
break;
|
|
|
case 2:
|
|
|
- users = users.OrderByDescending(x => x.BirthDate).ToList();
|
|
|
+ Users = Users.OrderByDescending(x => x.BirthDate).ToList();
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -51,9 +51,11 @@ namespace AvaloniaApplication2.ViewModels
|
|
|
|
|
|
void AllFilters()
|
|
|
{
|
|
|
- users = users0;
|
|
|
- if (!string.IsNullOrEmpty(textFind)) users = users.Where(x => x.UserName.Contains(textFind)).ToList();
|
|
|
- if (filteredGender != null && filteredGender.IdGender != 0) users = users.Where(x => x.GenderNavigation == filteredGender).ToList();
|
|
|
+ Users = Users0;
|
|
|
+ if (!string.IsNullOrEmpty(textFind)) Users = Users.Where(x => x.UserName.Contains(textFind)).ToList();
|
|
|
+ if (filteredGender != null && filteredGender.IdGender != 0) Users = Users.Where(x => x.GenderNavigation == filteredGender).ToList();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|