Exemple #1
0
        /// <summary>
        /// Prepare available facuties
        /// </summary>
        /// <param name="items">Faculty 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 PrepareFacuties(IList <SelectListItem> items, bool withSpecialDefaultItem = true, string defaultItemText = null)
        {
            if (items == null)
            {
                throw new ArgumentNullException(nameof(items));
            }

            //prepare available facuties
            var availableFaculties = _facultyService.GetAllFaculties();

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

            //insert special item for the default value
            PrepareDefaultItem(items, withSpecialDefaultItem, defaultItemText ?? "ระบุคณะ");
        }
        public async Task <IActionResult> GetAll(string query)
        {
            var faculties = await facultyService.GetAllFaculties(query);

            return(Ok(faculties));
        }
 public IEnumerable <FacultyDTO> GetFacultyDTO()
 {
     return(_facultyService.GetAllFaculties());
 }
 public async Task <IActionResult> GetAll()
 {
     return(Ok(await _facultyService.GetAllFaculties()));
 }