12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using Avalonia.Controls.ApplicationLifetimes;
- using reactivepril.Models;
- using Microsoft.EntityFrameworkCore;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using Avalonia;
- using Avalonia.Platform.Storage;
- using Avalonia.Media.Imaging;
- using System.IO;
- using ReactiveUI;
- using Avalonia.Media.TextFormatting;
- using Avalonia.Controls;
- namespace reactivepril.ViewModels
- {
- public class Page2ViewModel : ReactiveObject
- {
- public Galochkin41pContext db = new Galochkin41pContext();
- List<User> users;
- List<User> users0;
- User editedUser;
- List<Gender> genderList;
- string textFind;
- Gender filteredGender;
- Bitmap imageUser;
- UserControl page;
- MainWindowViewModel MainVM;
- int id;
- public User EditedUser { get => editedUser; set => this.RaiseAndSetIfChanged(ref editedUser, value); }
- public List<User> Users0 { get => users0; set => this.RaiseAndSetIfChanged(ref users0, value); }
- public List<User> Users { get => users; set => this.RaiseAndSetIfChanged(ref users, value); }
- public List<Gender> GenderList { get => genderList; set => this.RaiseAndSetIfChanged(ref genderList, value); }
- public string TextFind { get => textFind; set { textFind = value; AllFilters(); } }
- public Gender FilteredGender { get => filteredGender; set { filteredGender = value; AllFilters(); } }
- public Bitmap ImageUser { get => imageUser; set => this.RaiseAndSetIfChanged(ref imageUser, value); }
- public UserControl Page { get => page; set => this.RaiseAndSetIfChanged(ref page, value); }
- public MainWindowViewModel MainVM1 { get => MainVM; set => this.RaiseAndSetIfChanged(ref MainVM, value); }
- public int Id { get => id; set => this.RaiseAndSetIfChanged(ref id, value); }
- public Page2ViewModel()
- {
- users = db.Users.ToList();
- GenderList = db.Genders.ToList();
- genderList.Add(new Gender() {IdGender = 0, NameGender = "ñáðîñèòü ôèëüòðû" });
- users0 =users;
- filteredGender = genderList.FirstOrDefault(x => x.IdGender == 0);
- }
- public void OnTextFindChanged(string value) => AllFilters();
- void AllFilters()
- {
- Users = Users0;
- if (!string.IsNullOrEmpty(TextFind)) Users = Users.Where(x => x.Name.Contains(TextFind)).ToList();
- if (filteredGender != null && filteredGender.IdGender != 0) Users = Users.Where(x => x.GendersNavigation == filteredGender).ToList();
-
- }
- public void GoBack()
- {
- MainWindowViewModel.Self.Page = new Page1();
- }
- public void GoToProf(int id)
- {
- MainWindowViewModel.Self.Page = new Page2Next(id);
- }
- }
- }
|