Example #1
0
        public FilterDataViewModel()
        {
            MyTitle       = "Filter Data Analisa";
            CancelCommand = new CommandHandler {
                CanExecuteAction = x => true, ExecuteAction = CancelAction
            };
            SaveCommand = new CommandHandler {
                CanExecuteAction = SaveValidate, ExecuteAction = SaveAction
            };
            Fakultases = context.GetFakultas();

            using (var db = new DbContext())
            {
                int number = 1;
                var items  = (from m in db.Mahasiswa.Select()
                              join p in db.Progdi.Select() on m.IdProgdi equals p.Id
                              join f in db.Fakultas.Select() on p.ParentId equals f.Id
                              select new Mahasiswa
                {
                    Gelombang = m.Gelombang,
                    HasilTest = m.HasilTest,
                    IdJurusan = m.IdJurusan,
                    IDMahasiswa = m.IDMahasiswa,
                    IdProgdi = m.IdProgdi,
                    IPK = m.IPK,
                    MasaStudi = m.MasaStudi,
                    Nama = m.Nama,
                    NPM = m.NPM,
                    Suku = m.Suku,
                    FakultasId = f.Id
                }).ToList();
                foreach (var item in items)
                {
                    item.Jurusan        = db.Jurusan.Where(x => x.Id == item.IdJurusan).FirstOrDefault();
                    item.SukuModel      = DataHelpers.DataSuku.Where(x => x.Nilai == item.Suku).FirstOrDefault();
                    item.GelombangModel = DataHelpers.DataGelombang.Where(x => x.Nilai == item.Gelombang).FirstOrDefault();
                    DataSource.Add(item);
                    number++;
                }
                DataSourceView        = (CollectionView)CollectionViewSource.GetDefaultView(DataSource);
                DataSourceView.Filter = filterData;

                SliderMaximum   = DateTime.Now.Year;
                SliderMinimum   = SliderMaximum - 10;
                AngkatanMinimum = SliderMinimum;
                AngkatanMaximum = SliderMaximum;
                DataSourceView.Refresh();
            }
        }