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
{
///
/// шаблон программы для вкладки мои программы
///
public class MyProgramsTemplate: ViewModelBase
{
private List subjectsList = new List();
public List 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 staticProgramsWithSubject;
public MyProgramsTemplate(string title, string code, List 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");
}
}
}
}