Exemplo n.º 1
0
        public static List <SelectListItem> PopulateLevelSelectListItem()
        {
            try
            {
                LevelLogic   levelLogic = new LevelLogic();
                List <LEVEL> levels     = levelLogic.GetEntitiesBy(p => p.Active);

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

                List <SelectListItem> levelList = new List <SelectListItem>();
                if (levels != null && levels.Count > 0)
                {
                    SelectListItem list = new SelectListItem();
                    list.Value = "";
                    list.Text  = Select;
                    levelList.Add(list);

                    foreach (LEVEL level in levels)
                    {
                        SelectListItem selectList = new SelectListItem();
                        selectList.Value = level.Id.ToString();
                        selectList.Text  = level.Name;
                        levelList.Add(selectList);
                    }
                }

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