Exemplo n.º 1
0
 /// <summary>
 /// 为部门分配用户,需要统一提交,会删除以前该部门的所有用户
 /// </summary>
 /// <param name="request"></param>
 public void AssignOrgUsers(AssignOrgUsers request)
 {
     //删除以前的所有用户
     UnitWork.Delete <Relevance>(u => u.SecondId == request.OrgId && u.Key == Define.USERORG);
     //批量分配用户角色
     UnitWork.BatchAdd((from firstId in request.UserIds
                        select new Relevance
     {
         Key = Define.USERORG,
         FirstId = firstId,
         SecondId = request.OrgId,
         OperateTime = DateTime.Now
     }).ToArray());
     UnitWork.Save();
 }
        public Response AssignOrgUsers(AssignOrgUsers request)
        {
            var result = new Response();

            try
            {
                _app.AssignOrgUsers(request);
            }
            catch (Exception ex)
            {
                result.Code    = 500;
                result.Message = ex.InnerException?.Message ?? ex.Message;
            }

            return(result);
        }
Exemplo n.º 3
0
        public string AssignOrgUsers(AssignOrgUsers request)
        {
            var result = new Response();

            try
            {
                _app.AssignOrgUsers(request);
            }
            catch (Exception ex)
            {
                result.Code    = 500;
                result.Message = ex.InnerException?.Message ?? ex.Message;
            }

            return(JsonHelper.Instance.Serialize(Result));
        }
Exemplo n.º 4
0
 /// <summary>
 /// 為部門分配使用者,需要統一提交,會刪除以前該部門的所有使用者
 /// </summary>
 /// <param name="request"></param>
 public void AssignOrgUsers(AssignOrgUsers request)
 {
     UnitWork.ExecuteWithTransaction(() =>
     {
         //刪除以前的所有使用者
         UnitWork.Delete<Relevance>(u => u.SecondId == request.OrgId && u.Key == Define.USERORG);
         //批量分配使用者角色
         UnitWork.BatchAdd((from firstId in request.UserIds
             select new Relevance
             {
                 Key = Define.USERORG,
                 FirstId = firstId,
                 SecondId = request.OrgId,
                 OperateTime = DateTime.Now
             }).ToArray());
         UnitWork.Save();
     });
 }