using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using Autofac; using Bowin.Web.Controls.Mvc; using EMIS.Utility; using EMIS.ViewModel; using EMIS.CommonLogic.UniversityManage.AdministrativeOrgan; using EMIS.CommonLogic.SystemServices; namespace EMIS.Web.Controls { public static class CheckListExtentions { /// /// /// /// /// /// /// /// public static MvcHtmlString UserCampusList(this HtmlHelper htmlHelper, ListControlOptions listControlOptions, Guid userID, System.Collections.Generic.IDictionary htmlAttributes = null) { using (var scope = AutofacHelper.Container.BeginLifetimeScope()) { ICampusServices CampusServices = scope.Resolve(); IUserServices UserServices = scope.Resolve(); var campusList = CampusServices.GetCampusListWithoutDataRange().Select(x => new ListControlItem { Text = x.Name, Value = x.CampusID }); var userCampusList = UserServices.GetUserInchargeCampus(userID); listControlOptions.ItemList = campusList.ToList(); listControlOptions.SelectedValues = userCampusList.Select(x => (object)x.CampusID).ToList(); } return MvcHtmlString.Create(Bowin.Web.Controls.Mvc.CheckList.CreateControl(listControlOptions, htmlAttributes).Render()); } /// /// /// /// /// /// /// /// public static MvcHtmlString UserCollegeList(this HtmlHelper htmlHelper, ListControlOptions listControlOptions, Guid userID, System.Collections.Generic.IDictionary htmlAttributes = null) { using (var scope = AutofacHelper.Container.BeginLifetimeScope()) { ICollegeServices CollegeServices = scope.Resolve(); IUserServices UserServices = scope.Resolve(); var collegeList = CollegeServices.GetCollegeViewListWithoutDataRange().Select(x => new ListControlItem { Text = x.Name, Value = x.CollegeID }); var userCollegeList = UserServices.GetUserInchargeCollege(userID); listControlOptions.ItemList = collegeList.ToList(); listControlOptions.SelectedValues = userCollegeList.Select(x => (object)x.CollegeID).ToList(); } return MvcHtmlString.Create(Bowin.Web.Controls.Mvc.CheckList.CreateControl(listControlOptions, htmlAttributes).Render()); } /// /// /// /// /// /// /// /// public static MvcHtmlString UserDepartmentList(this HtmlHelper htmlHelper, ListControlOptions listControlOptions, Guid userID, System.Collections.Generic.IDictionary htmlAttributes = null) { using (var scope = AutofacHelper.Container.BeginLifetimeScope()) { IDepartmentServices DepartmentServices = scope.Resolve(); IUserServices UserServices = scope.Resolve(); var departmentList = DepartmentServices.GetDepartmentList().Select(x => new ListControlItem { Text = x.Name, Value = x.DepartmentID }); var userDepartmentList = UserServices.GetUserInchargeDepartment(userID); listControlOptions.ItemList = departmentList.ToList(); listControlOptions.SelectedValues = userDepartmentList.Select(x => (object)x.DepartmentID).ToList(); } return MvcHtmlString.Create(Bowin.Web.Controls.Mvc.CheckList.CreateControl(listControlOptions, htmlAttributes).Render()); } /// /// /// /// /// /// /// /// public static MvcHtmlString UserRoleList(this HtmlHelper htmlHelper, ListControlOptions listControlOptions, Guid userID, System.Collections.Generic.IDictionary htmlAttributes = null) { using (var scope = AutofacHelper.Container.BeginLifetimeScope()) { IRoleServices RoleServices = scope.Resolve(); IUserServices UserServices = scope.Resolve(); var roleList = RoleServices.GetEnabledTeacherRoleViewList().Select(x => new ListControlItem { Text = x.RoleName, Value = x.RoleID }); var userRoleList = UserServices.GetUserRoles(userID); listControlOptions.ItemList = roleList.ToList(); listControlOptions.SelectedValues = userRoleList.Select(x => (object)x.RoleID).ToList(); } return MvcHtmlString.Create(Bowin.Web.Controls.Mvc.CheckList.CreateControl(listControlOptions, htmlAttributes).Render()); } /// /// 列出字典表的项的多选列表 /// /// /// /// /// /// public static MvcHtmlString DictionaryCheckList(this HtmlHelper htmlHelper, DictionaryItem dictionaryItem, ListControlOptions listControlOptions, System.Collections.Generic.IDictionary htmlAttributes = null) { if (listControlOptions == null) { listControlOptions = new ListControlOptions(); } listControlOptions.ItemList = DictionaryHelper.GetDictionaryValue(dictionaryItem).Where(x => x.RecordStatus == (int)SYS_STATUS.USABLE) .Select(x => new ListControlItem { Text = x.Name, Value = x.Value }).ToList(); return MvcHtmlString.Create(Bowin.Web.Controls.Mvc.CheckList.CreateControl(listControlOptions, htmlAttributes).Render()); } } }