示例#1
0
        /// <summary>
        /// 获取编辑页面下拉列表
        /// </summary>
        /// <param name="webModel">编辑页视图Model</param>
        /// <param name="context">数据库连接上下文</param>
        /// <returns></returns>
        public async Task <StudentEditViewModel> GetDropDownListAsync(StudentEditViewModel webModel, ApplicationDbContext context)
        {
            //Get Source Data
            //
            var departmentList = await BasicRepository.GetDepartmentList(context);

            var majorclassList = await BasicRepository.GetMajorClassList(context);

            if (departmentList != null && departmentList.Any())
            {
                webModel.DepartmentList = departmentList.Select(item => new DepartmentDropDown
                {
                    Id   = item.Id.ToString(),
                    Name = item.Name
                }).ToList();
            }

            if (majorclassList != null && majorclassList.Any())
            {
                webModel.MajorClassList = majorclassList.Select(item => new MajorClassDropDown
                {
                    Id   = item.Id.ToString(),
                    Name = item.Name
                }).ToList();
            }

            return(webModel);
        }