public ActionResult Create() { var managers = this.vodpointsdb.managers.ToList(); var accesscontrolparents = this.vodpointsdb.accesscontrolparents.ToList(); var accesscontrolchildren = this.vodpointsdb.accesscontrolchildrens.ToList(); var model = new CompositeAuthorityViewModel(); model.Managers = managers; model.AccessControlParent = accesscontrolparents; model.AccessControlChildren = accesscontrolchildren; return View(model); }
public ActionResult Edit(int id) { int authorityGroupId = id; var model = this.vodpointsdb.authoritygroups.Find(authorityGroupId); if (model == null) { return HttpNotFound(); } ViewBag.AuthorityGroup = model; var compositeAuthorityViewModel = new CompositeAuthorityViewModel(); //// 找出該權限群組裡被勾選的管理員們 var managerIds = this.vodpointsdb.managerauthoritygroups.Where(a => a.AuthorityGroupId == authorityGroupId).Select(b => b.ManagerId); ViewBag.ManagerIds = managerIds.ToList(); //// 找出該權限群組裡被勾選的子功能們 var accessControlChildrenIds = this.vodpointsdb.manageraccesscontrolchildrens.Where(a => a.AuthorityGroupId == authorityGroupId && a.Function == 1).Select(b => b.AccessControlChildrenId); ViewBag.AccessControlChildrenIds = accessControlChildrenIds.Distinct().ToList(); compositeAuthorityViewModel.Managers = this.vodpointsdb.managers.ToList(); compositeAuthorityViewModel.AccessControlParent = this.vodpointsdb.accesscontrolparents.ToList(); compositeAuthorityViewModel.AccessControlChildren = this.vodpointsdb.accesscontrolchildrens.ToList(); return View(compositeAuthorityViewModel); }