12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- using AvaloniaApplication4.Models;
- using AvaloniaApplication4.ViewModels;
- using DynamicData;
- using ReactiveUI;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace AvaloniaApplication4.AdditionalModels
- {
- /// <summary>
- /// шаблон программы для вкладки мои программы
- /// </summary>
- public class MyProgramsTemplate: ViewModelBase
- {
- private List<ProgramsWithSubject> subjectsList = new List<ProgramsWithSubject>();
- public List<ProgramsWithSubject> SubjectsList
- {
- get { return subjectsList; }
- set
- {
- if (subjectsList == value)
- return;
- subjectsList = value;
- OnPropertyChanged("SubjectsList");
- }
- }
- public string Title { get; set; }
- public string Code { get; set; }
- public string searchQuery = string.Empty;
- List<ProgramsWithSubject> staticProgramsWithSubject;
- public MyProgramsTemplate(string title, string code, List<ProgramsWithSubject> subjectsList)
- {
- Title = title;
- Code = code;
- SubjectsList = subjectsList;
- staticProgramsWithSubject = subjectsList;
- }
- public void SearchSubjects()
- {
- if (searchQuery != null && searchQuery != string.Empty && searchQuery != "")
- {
- SubjectsList = staticProgramsWithSubject.Where(x=>x.IdSubjectNavigation.IdCodeAcademicSubject.ToLower().StartsWith(searchQuery.ToLower()) || x.IdSubjectNavigation.NameSubject.ToLower().StartsWith(searchQuery.ToLower())).ToList();
- }
- else SubjectsList = staticProgramsWithSubject;
- }
- public string SearchQuery
- {
- get
- {
- return searchQuery;
- }
- set
- {
- if (searchQuery == value) return;
- searchQuery = value;
- SearchSubjects();
- OnPropertyChanged("SearchQuery");
- }
- }
- }
- }
|