using System; using System.Collections.Generic; using System.Linq; using System.Text; using DK_Project.Model; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Collections.ObjectModel; using System.Windows.Input; using System.Windows.Data; using System.Collections; using System.ComponentModel; namespace DK_Project.ViewModels { internal class EmployeeViewModel1:INotifyPropertyChanged {
public EmployeeModel Employee { get; set; } ObservableCollection<EmployeeModel> Employees = new ObservableCollection<EmployeeModel>(); public EmployeeViewModel1() { Employees.Add(new EmployeeModel() { CompanyName="Digital Kitchen", Location="Eden Prairie", FirstName="Becky", LastName="Friedman", ContactTitle="LineCook", EmpImage="/Resources/EmployeImages/Becky.jpg", StDate="November 5, 2003", EmpId= 1011, Rating= 5, WorkGroup="Broiler Cook"}); Employees.Add(new EmployeeModel() { CompanyName="Digital Kitchen", Location="Eden Prairie", FirstName="Bob", LastName="Broderick", ContactTitle="LineCook", EmpImage="/Resources/EmployeImages/Bob.jpg", StDate="November 4, 2003", EmpId= 1012, Rating= 5, WorkGroup="Broiler Cook"}); Employees.Add(new EmployeeModel() { CompanyName="Digital Kitchen", Location="Eden Prairie", FirstName="Eric", LastName="Clapton", ContactTitle="Manager", EmpImage="/Resources/EmployeImages/Bubba.jpg", StDate="November4, 2003", EmpId= 1013, Rating= 5, WorkGroup="Saute Cook" }); Employees.Add(new EmployeeModel() { CompanyName="Digital Kitchen", Location="Eden Prairie", FirstName="Jesus", LastName="Weinman", ContactTitle="LineCook", EmpImage="/Resources/EmployeImages/Jesus.jpg", StDate="November 9, 2003", EmpId= 1014, Rating= 5, WorkGroup="Saute Cook" }); Employees.Add(new EmployeeModel() { CompanyName="Digital Kitchen", Location="Eden Prairie", FirstName="Steve", LastName="Vai", ContactTitle="LineCook", EmpImage="/Resources/EmployeImages/FOH1.jpg", StDate="November 9, 2003", EmpId= 1015, Rating= 5, WorkGroup="Manager" }); Employees.Add(new EmployeeModel() { CompanyName="Digital Kitchen", Location="Eden Prairie", FirstName="Jeff", LastName="Bonamassa", ContactTitle="LineCook", EmpImage="/Resources/EmployeImages/SousChef1.jpg", StDate="November 5, 2003", EmpId= 1016, Rating= 5, WorkGroup="Manager" }); Employees.Add(new EmployeeModel() { CompanyName="Digital Kitchen", Location="Eden Prairie", FirstName="Chef ", LastName="Gates", ContactTitle="Chef", EmpImage="/Resources/EmployeImages/Chef1.jpg", StDate="November 5, 2003", EmpId= 1017, Rating= 5, WorkGroup="Manager"}); Employees.Add(new EmployeeModel() { CompanyName="Digital Kitchen", Location="Eden Prairie", FirstName="Mike", LastName="Anastasio", ContactTitle="SousChef", EmpImage="/Resources/EmployeImages/Mike.jpg", StDate="November 5, 2003", EmpId= 1018, Rating= 5, WorkGroup="Saute Cook"}); Employees.Add(new EmployeeModel() { CompanyName="Digital Kitchen", Location="Eden Prairie", FirstName="Markus", LastName="Lommis", ContactTitle="SousChef", EmpImage="/Resources/EmployeImages/Markus.jpg", StDate="November 5, 2003", EmpId= 1019, Rating= 5, WorkGroup="Pantry Cook" }); Employees.Add(new EmployeeModel() { CompanyName="Digital Kitchen", Location="Eden Prairie", FirstName="Bubba", LastName="Paisly", ContactTitle="AM Supervisor", EmpImage="/Resources/EmployeImages/Bubba.jpg", StDate="November 5, 2003", EmpId= 1020, Rating= 5, WorkGroup="Pantry Cook" }); Employees.Add(new EmployeeModel() { CompanyName="Digital Kitchen", Location="Eden Prairie", FirstName="Sara", LastName="Gilbert", ContactTitle="PM Supervisor", EmpImage="/Resources/EmployeImages/Sara.jpg", StDate="November 5, 2003", EmpId= 1021, Rating= 5, WorkGroup=" Cook" }); Employees.Add(new EmployeeModel() { CompanyName="Digital Kitchen", Location="Eden Prairie", FirstName="Samuel", LastName="Vaughn", ContactTitle="PrepCook", EmpImage="/Resources/EmployeImages/Samuel.jpg", StDate="November 5, 2003", EmpId= 1031, Rating= 5, WorkGroup="Broiler Cook" }); Employees.Add(new EmployeeModel() { CompanyName="Digital Kitchen", Location="Eden Prairie", FirstName="Sara", LastName="Malmsteen", ContactTitle="PrepCook", EmpImage="/Resources/EmployeImages/sara.jpg", StDate="November 5, 2003", EmpId= 1041, Rating= 5, WorkGroup="Broiler Cook"}); Employees.Add(new EmployeeModel() { CompanyName="Digital Kitchen", Location="Eden Prairie", FirstName="Zakk", LastName="Satriani", ContactTitle="PrepCook", EmpImage="/Resources/EmployeImages/SousChef2.jpg", StDate="November 5, 2003", EmpId= 1051, Rating= 5, WorkGroup="Manager"}); Employees.Add(new EmployeeModel() { CompanyName="Digital Kitchen", Location="Eden Prairie", FirstName="Clara", LastName="Rhoads", ContactTitle="PrepCook", EmpImage="/Resources/EmployeImages/Clara.jpg", StDate="November 5, 2003", EmpId= 1061, Rating= 5, WorkGroup="Fry Cook" }); Employees.Add(new EmployeeModel() { CompanyName="Digital Kitchen", Location="Eden Prairie", FirstName="Susie", LastName="Meola", ContactTitle="LineCook", EmpImage="/Resources/EmployeImages/Susie.jpg", StDate="November 5, 2003", EmpId= 1071, Rating= 5, WorkGroup="Fry Cook" }); Employees.Add(new EmployeeModel() { CompanyName="Digital Kitchen", Location="Eden Prairie", FirstName="Ted", LastName="Hendrix", ContactTitle="LineCook", EmpImage="/Resources/EmployeImages/Ted.jpg", StDate="November 5, 2003", EmpId= 1081, Rating= 5, WorkGroup="Prep Cook" }); Employees.Add(new EmployeeModel() { CompanyName="Digital Kitchen", Location="Eden Prairie", FirstName="Ron", LastName="Lee", ContactTitle="DishWasher", EmpImage="/Resources/EmployeImages/Ron.jpg", StDate="November 5, 2003", EmpId= 1091, Rating= 5, WorkGroup="Prep Cook" }); Employees.Add(new EmployeeModel() { CompanyName="Digital Kitchen", Location="Eden Prairie", FirstName="Linda", LastName="Johnson", ContactTitle="DishWasher", EmpImage="/Resources/EmployeImages/Linda.jpg", StDate="November 5, 2003", EmpId= 1101, Rating= 5, WorkGroup="Prep Cook" }); } public ObservableCollection<EmployeeModel> EmployeeList { get { return Employees; }
} private MyCommand _filterCommand; public MyCommand FilterCommand { get { return _filterCommand; } set { _filterCommand = value; OnPropertyChanged("FilterCommand"); } }
private void InitializeCommands() { FilterCommand = new MyCommand(FilterWorkGroup); } private void FilterWorkGroup() { this.GetListCollectionView().Filter = this.FilterWG; } private bool FilterWG(object obj) { if (obj as EmployeeModel != null && (obj as EmployeeModel).WorkGroup == "Broiler Cook") { return true; } return false; }
private ListCollectionView GetListCollectionView() { return (ListCollectionView)CollectionViewSource.GetDefaultView(this.EmployeeList); } #region INotifyPropertyChanged Members public event PropertyChangedEventHandler PropertyChanged; public void OnPropertyChanged(string propertyName) { if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } #endregion } public class MyCommand : ICommand { Action _action; public MyCommand(Action action) { _action = action; } #region ICommand Members public bool CanExecute(object parameter) { return true; } public event EventHandler CanExecuteChanged; public void Execute(object parameter) { _action.Invoke(); } #endregion } }
|