示例#1
0
        public static List <SelectListItem> PopulateAllProgrammeSelectListItem()
        {
            try
            {
                ProgrammeLogic   programmeLogic = new ProgrammeLogic();
                List <PROGRAMME> programmes     = programmeLogic.GetEntitiesBy(p => p.Active);

                if (programmes == null || programmes.Count <= 0)
                {
                    return(new List <SelectListItem>());
                }

                List <SelectListItem> selectItemList = new List <SelectListItem>();

                SelectListItem list = new SelectListItem();
                list.Value = "";
                list.Text  = SelectProgramme;
                selectItemList.Add(list);

                foreach (PROGRAMME programme in programmes)
                {
                    SelectListItem selectList = new SelectListItem();
                    selectList.Value = programme.Id.ToString();
                    selectList.Text  = programme.Name;

                    selectItemList.Add(selectList);
                }

                return(selectItemList);
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#2
0
        public static List <PROGRAMME> GetAllProgrammes()
        {
            try
            {
                ProgrammeLogic   programmeLogic = new ProgrammeLogic();
                List <PROGRAMME> programmes     = programmeLogic.GetAll();

                if (programmes != null && programmes.Count > 0)
                {
                    //programmes.Add(new Programme() { Id = -100, Name = "All" });
                    programmes.Insert(0, new PROGRAMME()
                    {
                        Id = 0, Name = SelectProgramme
                    });
                }

                return(programmes);
            }
            catch (Exception)
            {
                throw;
            }
        }