public Response <string> SetRoleDepartment([FromBody] QueryDepartmentRole roleDepartments)
        {
            var result = new Response <string>();

            try
            {
                _app.SetRoleDepartment(roleDepartments);
            }
            catch (Exception e)
            {
                result.Code    = 500;
                result.Message = e.InnerException?.Message ?? e.Message;
            }
            return(result);
        }
示例#2
0
 /// <summary>
 /// 通过角色设置部门
 /// </summary>
 /// <param name="roles"></param>
 public void SetRoleDepartment(QueryDepartmentRole roles)
 {
     UnitWork.Delete <DepartmentRole>(d =>
                                      roles.DepartmentRoles.Where(w => w.RoleId == d.RoleId).Count() > 0);
     foreach (var r in roles.DepartmentRoles)
     {
         if (!string.IsNullOrEmpty(r.DepartmentId))
         {
             UnitWork.Add(new DepartmentRole()
             {
                 DepartmentId = r.DepartmentId,
                 RoleId       = r.RoleId
             });
         }
     }
     UnitWork.Save();
 }
示例#3
0
 /// <summary>
 /// 通过部门设置角色
 /// </summary>
 /// <param name="departments"></param>
 public void SetDepartRole(QueryDepartmentRole departments)
 {
     UnitWork.Delete <DepartmentRole>(d =>
                                      departments.DepartmentRoles.Where(w => w.DepartmentId == d.DepartmentId).Count() > 0);
     foreach (var dept in departments.DepartmentRoles)
     {
         if (!string.IsNullOrEmpty(dept.RoleId))
         {
             UnitWork.Add(new DepartmentRole()
             {
                 DepartmentId = dept.DepartmentId,
                 RoleId       = dept.RoleId
             });
         }
     }
     UnitWork.Save();
 }