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); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(ManagerRoleInfo model) { return this._repository.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(ManagerRoleInfo model) { return this._repository.Add(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(ManagerRoleInfo model) { //先删除旧数据,再插入操作 return false; }
/// <summary> /// 增加一条数据 /// </summary> public int Add(ManagerRoleInfo model) { _efRepository.Add(model); return model.Id; }
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; }