public Result EditRoleByEmployee(EmployeePowerRoleSubmitDto modelDto) { try { if (modelDto.EmployeeId <= 0) { return(Result.Fail("请先填写个人信息")); } using (TransactionScope ts = new TransactionScope()) { //先删除用户对应角色 _relevanceBusiness.Delete(p => p.FirstId == modelDto.EmployeeId); //多对多关系集中映射表 var lsRelevance = new List <PowerRelevance>(); foreach (var item in modelDto.RoleIds) { lsRelevance.Add(new PowerRelevance() { Id = 0, FirstId = modelDto.EmployeeId, SecondId = item, Identifiers = PowerIdentifiers.UserByRole, Remarks = PowerIdentifiers.UserByRole.GetDescription() }); } if (modelDto.RoleIds.Count() > 0) { _relevanceBusiness.AddRange(lsRelevance); } ts.Complete(); return(Result.Success()); } } catch (Exception ex) { return(Result.Fail("操作失败:" + ex.Message)); } }
public Result EditRoleByEmployee([FromForm] EmployeePowerRoleSubmitDto modelDto) { return(_wrappers.EditRoleByEmployee(modelDto)); }