public IActionResult LoginSubmit() { string xuehao = Request.Form["username"].ToString(); string password = Request.Form["password"].ToString(); if (string.IsNullOrEmpty(xuehao) || string.IsNullOrEmpty(password) || string.IsNullOrWhiteSpace(xuehao) || string.IsNullOrWhiteSpace(password)) { return(Redirect("../Login/LoginResult")); } TblStudentDto dto = new TblStudentDto { StudentNum = xuehao, StudentPassword = password }; StudentDa da = new StudentDa { XuanKeDB = XuanKeDB }; var flag = da.StudentLogin(dto); if (flag) { HttpContext.Session.SetString(SessionCode.username, xuehao); return(Redirect("../Home/StudentResult")); } return(Redirect("../Login/LoginResult")); }
/// <summary> /// 新增学生信息 /// </summary> /// <param name="dto"></param> /// <returns></returns> public void AddStudents(TblStudentDto dto) { var entity = dto.ToEntity(); XuanKeDB.TblStudent.Add(entity); XuanKeDB.SaveChanges(); }
public void ModifyStudent(TblStudentDto dto) { var entity = dto.ToEntity(); XuanKeDB.TblStudent.Update(entity); XuanKeDB.SaveChanges(); }
/// <summary> /// 学生登录 /// </summary> /// <param name="dto"></param> /// <returns></returns> public bool StudentLogin(TblStudentDto dto) { var student = XuanKeDB.TblStudent.FirstOrDefault(s => s.StudentNum == dto.StudentNum && s.StudentPassword == dto.StudentPassword); if (student == null) { return(false); } return(true); }