示例#1
0
        /// <summary>
        /// Prepare available Education Levels
        /// </summary>
        /// <param name="items">Education Levels items</param>
        /// <param name="withSpecialDefaultItem">Whether to insert the first special item for the default value</param>
        /// <param name="defaultItemText">Default item text; pass null to use default value of the default item text</param>
        public virtual void PrepareEducationLevels(IList <SelectListItem> items, bool withSpecialDefaultItem = true, string defaultItemText = null)
        {
            if (items == null)
            {
                throw new ArgumentNullException(nameof(items));
            }

            //prepare available education levels
            var availableEducationLevels = _educationLevelService.GetAllEducationLevels();

            foreach (var educationLevel in availableEducationLevels)
            {
                items.Add(new SelectListItem {
                    Value = educationLevel.Id.ToString(), Text = educationLevel.Name
                });
            }

            //insert special item for the default value
            PrepareDefaultItem(items, withSpecialDefaultItem, defaultItemText ?? "ระบุระดับการศึกษา");
        }