Example #1
0
        }                       //End public PromisedDS

        public List <PromisedlistitemVM> getDatalist(PromisedVM poViewModel = null)
        {
            List <PromisedlistitemVM> vReturn;


            using (var db = new DBMAINContext())
            {
                var oQRY = from tb in db.Promised_infos
                           select new PromisedlistitemVM
                {
                    YEAR_ID      = tb.YEAR_ID,
                    SEMESTER_ID  = tb.SEMESTER_ID,
                    CLASSTYPE_ID = tb.CLASSTYPE_ID,
                    ID           = tb.ID,
                    WEEKNUM      = tb.WEEKNUM,
                    DATEFROM     = tb.DATEFROM,
                    THEME_ID     = tb.THEME_ID,
                    THEME_DESC   = tb.THEME_DESC,
                    SUBTHEME     = tb.SUBTHEME
                };
                if (poViewModel != null)
                {
                    if (poViewModel.FILTER_YEAR_ID != null)
                    {
                        oQRY = oQRY.Where(fld => fld.YEAR_ID == poViewModel.FILTER_YEAR_ID);
                    } //End if (poViewModel.YEAR_ID != null)
                    if (poViewModel.FILTER_SEMESTER_ID != null)
                    {
                        oQRY = oQRY.Where(fld => fld.SEMESTER_ID == poViewModel.FILTER_SEMESTER_ID);
                    } //End if (poViewModel.SEMESTER_ID != null)
                    if (poViewModel.FILTER_CLASSTYPE_ID != null)
                    {
                        oQRY = oQRY.Where(fld => fld.CLASSTYPE_ID == poViewModel.FILTER_CLASSTYPE_ID);
                    } //End if (poViewModel.CLASSTYPE_ID != null)

                    if (poViewModel.FILTER_WEEKNUM != null)
                    {
                        oQRY = oQRY.Where(fld => fld.WEEKNUM == poViewModel.FILTER_WEEKNUM);
                    } //End if (poViewModel.CLASSTYPE_ID != null)
                    if (poViewModel.FILTER_DATEFROM != null)
                    {
                        oQRY = oQRY.Where(fld => fld.DATEFROM == poViewModel.FILTER_DATEFROM);
                    } //End if (poViewModel.CLASSTYPE_ID != null)
                }     //End if (poViewModel != null)

                vReturn = oQRY.ToList();
            } //End using (var = new DbContext())
            return(vReturn);
        }     //End public List<PromisedlistVM> getDatalist()
        } //End public Promised_Validation()

        //Constructor 2
        public Promised_Validation(PromisedVM poViewModel)
        {
            oViewModelfilter = poViewModel;
        } //End public Promised_Validation()