Exemplo n.º 1
0
 /// <summary>
 /// 保存角色组与角色关联信息
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public async Task <ApiResult <string> > SaveRoleGroupRoleAsync(SaveRoleGroupRoleRequest request)
 {
     return(await ExecuteResultAsync(async query =>
     {
         var rsp = new ApiResult <string>();
         // 先把已有的权限数据删除
         // 读取关联信息
         var roleGroupRoles = await Query <RoleGroupRole>()
                              .Where(p => p.RoleId == request.RoleId)// 只读取操作的
                              .ToListAsync();
         // 如果找到
         if (roleGroupRoles.Count > 0)
         {
             // 删除
             RegisterDeleteRange(roleGroupRoles);
         }
         var entities = request.RoleGroupIds.Select(groupId => new RoleGroupRole
         {
             RoleId = request.RoleId,
             RoleGroupId = groupId
         }).ToList();
         await RegisterNewRangeAsync(entities);
         // 提交
         var flag = await CommitAsync();
         rsp.Message = flag ? "保存成功" : "保存失败";
         rsp.Success = flag;
         return rsp;
     }));
 }
Exemplo n.º 2
0
 public async Task <ApiResult <string> > SaveRoleGroupRole([FromBody] SaveRoleGroupRoleRequest request)
 {
     return(await _roleService.SaveRoleGroupRoleAsync(request));
 }