public IActionResult Register(string userName, string pwd, string phone, string value) { int i = 0; if (value == "1") { EntityTeacher teacher = new EntityTeacher(); teacher.TeacherName = userName; teacher.TeacherPassword = pwd; teacher.PhoneNumber = phone; var list = SqlSugarHelper.Instance.Insertable <EntityTeacher>(teacher).ExecuteCommand(); if (list > 0) { i += 1; } } if (value == "2") { EntityStudent student = new EntityStudent(); student.StudentName = userName; student.StudentPassword = pwd; student.PhoneNumber = phone; var list = SqlSugarHelper.Instance.Insertable <EntityStudent>(student).ExecuteCommand(); if (list > 0) { i += 1; } } if (value == "3") { EntityAdmin admin = new EntityAdmin(); admin.AdminName = userName; admin.AdminPassword = pwd; admin.PhoneNumber = phone; var list = SqlSugarHelper.Instance.Insertable <EntityAdmin>(admin).ExecuteCommand(); if (list > 0) { i += 1; } } if (i != 0) { return(Ok(new { Message = "注册成功", Code = 1 })); } else { return(Ok(new { Message = "注册失败", Code = 0 })); } }
public IActionResult Forget(string userName, string pwd, string value) { int i = 0; if (value == "1") { EntityTeacher teacher = SqlSugarHelper.Instance.Queryable <EntityTeacher>().First(it => it.TeacherName == userName); teacher.TeacherPassword = pwd; var list = SqlSugarHelper.Instance.Updateable(teacher).WhereColumns(it => new { it.TeacherName }).ExecuteCommand(); if (list > 0) { i += 1; } } if (value == "2") { EntityStudent student = SqlSugarHelper.Instance.Queryable <EntityStudent>().First(it => it.StudentName == userName); student.StudentPassword = pwd; var list = SqlSugarHelper.Instance.Updateable(student).WhereColumns(it => new { it.StudentName }).ExecuteCommand(); if (list > 0) { i += 1; } } if (value == "3") { EntityAdmin admin = SqlSugarHelper.Instance.Queryable <EntityAdmin>().First(it => it.AdminName == userName); admin.AdminPassword = pwd; var list = SqlSugarHelper.Instance.Updateable(admin).WhereColumns(it => new { it.AdminName }).ExecuteCommand(); if (list > 0) { i += 1; } } if (i != 0) { return(Ok(new { Message = "密码重置成功", Code = 1 })); } else { return(Ok(new { Message = "密码重置失败", Code = 0 })); } }