12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Threading.Tasks;
- using Avalonia;
- using Avalonia.Controls.ApplicationLifetimes;
- using Avalonia.Media.Imaging;
- using Avalonia.Platform.Storage;
- using AvaloniaHomeTry.Models;
- using Microsoft.EntityFrameworkCore;
- using Microsoft.EntityFrameworkCore.Infrastructure.Internal;
- using ReactiveUI;
- using Tmds.DBus.Protocol;
- namespace AvaloniaHomeTry.ViewModels
- {
- public partial class AdminPageViewModel : ViewModelBase
- {
- UsersTable myUsers = new UsersTable();
- List<Gender> genderList;
- List<UsersTable> usersTables;
-
- List<UsersTable> usersTables0;
- Gender filterGender;
- string find;
-
- public List<Gender> GenderList { get => genderList; set => this.RaiseAndSetIfChanged(ref genderList, value); }
- public List<UsersTable> UsersTables { get => usersTables; set => this.RaiseAndSetIfChanged(ref usersTables, value); }
- public List<UsersTable> UsersTables0 { get => usersTables0; set => this.RaiseAndSetIfChanged(ref usersTables0, value); }
- public Gender FilterGender { get => filterGender; set { filterGender = value; AllFilters(); } }
- public string Find { get => find; set { find = value; AllFilters(); } }
- public AdminPageViewModel()
- {
- usersTables = db.UsersTable.ToList();
- genderList = db.Genders.ToList();
- genderList.Add(new Gender() { Id = 0, GenderName = "Ñáðîñèòü ôèëüòðû"});
- usersTables0 = usersTables;
- filterGender = genderList.FirstOrDefault(x => x.Id == 0);
- }
- public void DateSort(int id)
- {
- switch (id)
- {
- case 1:
- UsersTables = UsersTables.OrderBy(x => x.Dataofbirth).ToList();
- break;
- case 2:
- UsersTables = UsersTables.OrderByDescending(x => x.Dataofbirth).ToList();
- break;
-
- }
- }
- void AllFilters()
- {
- UsersTables = UsersTables0;
- if(!string.IsNullOrEmpty(Find)) UsersTables = UsersTables.Where(x => x.Surname.Contains(Find)).ToList();
- if (filterGender != null && filterGender.Id != 0)UsersTables = UsersTables.Where(x=>x.GenderNavigation == FilterGender).ToList();
- }
- public void MyProfile() => MainWindowViewModel.Self.UC = new UserPage(MainWindowViewModel.Self.ID);
- public void Exit() => MainWindowViewModel.Self.UC = new AuthPage();
- }
- }
|