Ejemplo n.º 1
0
 /// <summary>
 /// 收回制定角色的权限
 /// </summary>
 /// <param name="roleId">角色编号</param>
 /// <param name="Function">权限ID列表</param>
 public void RevokeFunctionForRole(int roleId, String functionId)
 {
     using (ChooseDishesEntities entities = new ChooseDishesEntities()) {
         RoleRefFunction p = entities.RoleRefFunction.Where(t => t.RoleId == roleId && t.FunctionId == functionId && t.Deleted == 0).Single();
         if (null == p)
         {
             throw new ServiceException("无法找到对应角色【" + roleId + "】的授权编号【" + functionId + "】");
         }
         int authId = SubjectUtils.GetAuthenticationId();
         p.Deleted        = 1;
         p.UpdateBy       = authId;
         p.UpdateDateTime = DateTime.Now;
         entities.SaveChanges();
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 给制定的角色赋予权限
 /// </summary>
 /// <param name="roleId">角色编号</param>
 /// <param name="Function">权限ID列表</param>
 public void GrantFunctionForRole(int roleId, String functionId)
 {
     using (ChooseDishesEntities entities = new ChooseDishesEntities())
     {
         RoleRefFunction rp     = new RoleRefFunction();
         int             authId = SubjectUtils.GetAuthenticationId();
         rp.Deleted        = 0;
         rp.RoleId         = roleId;
         rp.FunctionId     = functionId;
         rp.CreateBy       = authId;
         rp.CreateDateTime = DateTime.Now;
         entities.RoleRefFunction.Add(rp);
         entities.SaveChanges();
     }
 }