private bool DoAdd() { var adminEntity = GetAdminInfo(); bool result = false; var model = new ManagerRoleInfo(); model.AgentId = adminEntity.Id; model.RoleName = txtRoleName.Text.Trim(); //model.role_type = int.Parse(ddlRoleType.SelectedValue); model.RoleType = 2; //管理权限 var ls = new List <ManagerRoleValueInfo>(); for (int i = 0; i < rptList.Items.Count; i++) { string navName = ((HiddenField)rptList.Items[i].FindControl("hidName")).Value; CheckBoxList cblActionType = (CheckBoxList)rptList.Items[i].FindControl("cblActionType"); for (int n = 0; n < cblActionType.Items.Count; n++) { if (cblActionType.Items[n].Selected == true) { ls.Add(new ManagerRoleValueInfo { NavName = navName, ActionType = cblActionType.Items[n].Value }); } } } model.ManagerRoleValues = ls; if (rBll.Add(model) > 0) { AddAdminLog(MXEnums.ActionEnum.Add.ToString(), "添加角色:" + model.RoleName); //记录日志 result = true; } return(result); }
public void Add() { var managerRoleInfo = new ManagerRoleInfo(); managerRoleInfo.AgentId = 1; managerRoleInfo.RoleName = "测试角色"; managerRoleInfo.IsSys = 1; managerRoleInfo.RoleType = 1; managerRoleInfo.ManagerRoleValues = new List <ManagerRoleValueInfo>() { new ManagerRoleValueInfo() { RoleId = 1, NavName = "测试角色值1", ActionType = "testActionType1" }, new ManagerRoleValueInfo() { RoleId = 2, NavName = "测试角色值2", ActionType = "testActionType2" } }; var result = _service.Add(managerRoleInfo); Assert.IsTrue(result > 0); }