public Task <IdResp <string> > Create([FromBody] AddAdminReq req) { if (!ModelState.IsValid) { return(Task.FromResult(new IdResp <string>().WithResp(RespTypes.ParaError, GetInvalidMsg()))); } return(_service.AddAdmin(req.MapToAdminInfo())); }
public void CheckLoggingInRemovedAdmin(IUser anotherAdmin) { logger.Info("Checking logging removed admin in started."); adminService.AddAdmin(anotherAdmin); adminService.RemoveUser(anotherAdmin); Assert.Throws <Exception>(() => adminService.SuccessfulAdminLogin(anotherAdmin)); logger.Info("Expected exception is thrown."); logger.Info("Checking logging removed admin in done."); }
public void SetUp() { IUser adminUser = UserRepository.Get().Admin(); GuestService guestService = new GuestService(); adminService = guestService .SuccessfulAdminLogin(adminUser); adminForTest = UserRepository.Get().AdminForTest(); adminService.AddAdmin(adminForTest); }
/// <summary> /// 添加管理员 /// </summary> /// <param name="loginID">管理员登录(账号)ID</param> /// <param name="roleID">用户角色ID</param> /// <returns></returns> public int AddAdmin(string loginID, int roleID) { return(adminService.AddAdmin(loginID, roleID)); }
private void tsbSave_Click(object sender, EventArgs e) { if (bAdd == true)//新增数据 { #region 数据验证 #endregion #region 封装对象 Admin objAdmin = new Admin() { deptid = Convert.ToInt32(this.txtDeptId.Text.Trim()), dept = this.txtDept.Text.Trim(), userid = this.txtUserId.Text.Trim(), username = this.txtUserName.Text.Trim(), pwd = "SAP123", Attendance = this.ckbAttendance.Checked ? true : false, Overtime = this.ckbOvertime.Checked ? true : false, Evaluation = this.ckbEvaluation.Checked ? true : false, Assessment = this.ckbAssessment.Checked ? true : false, 开始日期 = Convert.ToDateTime(this.txtStartDate.Text.Trim()), 结束日期 = Convert.ToDateTime(this.txtEndDate.Text.Trim()), 备注 = this.txtBeiZhu.Text.Trim(), 更改者 = Program.currentAdmin.username, 更改日期 = DateTime.Now }; #endregion #region 数据验证 try { if (objAdminService.AddAdmin(objAdmin) == 1) { DialogResult result = MessageBox.Show("添加成功,是否继续添加?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { //maxDeptID += 1; //this.txtJiGouID.Text = maxDeptID.ToString(); //this.txtJiGouFullName.Focus(); } else { bAdd = false; } LoadDeptList(); objControlService.init_GroupBox(groupBox); } else { MessageBox.Show("添加失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message); } #endregion } else//修改数据 { #region 数据验证 #endregion #region 封装对象 Admin objAdmin = new Admin() { id = id, deptid = Convert.ToInt32(this.txtDeptId.Text.Trim()), dept = this.txtDept.Text.Trim(), userid = this.txtUserId.Text.Trim(), username = this.txtUserName.Text.Trim(), Attendance = this.ckbAttendance.Checked ? true : false, Overtime = this.ckbOvertime.Checked ? true : false, Evaluation = this.ckbEvaluation.Checked ? true : false, Assessment = this.ckbAssessment.Checked ? true : false, 开始日期 = Convert.ToDateTime(this.txtStartDate.Text.Trim()), 结束日期 = Convert.ToDateTime(this.txtEndDate.Text.Trim()), 备注 = this.txtBeiZhu.Text.Trim(), 更改者 = Program.currentAdmin.username, 更改日期 = DateTime.Now }; #endregion #region 调用后台数据访问对象添加数据 try { if (objAdminService.ModifyAdminbyId(objAdmin) == 1) { LoadDeptList(); objControlService.init_GroupBox(groupBox); MessageBox.Show("修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK;//返回修改成功的信息 } else { MessageBox.Show("修改失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message); } #endregion } }
//添加超级管理员---待添加 public static bool AddAdmin(string admin, string adminPwd) { return(AdminService.AddAdmin(admin, adminPwd)); }