Beispiel #1
0
        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"));
        }
Beispiel #2
0
        /// <summary>
        /// 新增学生信息
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public void AddStudents(TblStudentDto dto)
        {
            var entity = dto.ToEntity();

            XuanKeDB.TblStudent.Add(entity);
            XuanKeDB.SaveChanges();
        }
Beispiel #3
0
        public void ModifyStudent(TblStudentDto dto)
        {
            var entity = dto.ToEntity();

            XuanKeDB.TblStudent.Update(entity);
            XuanKeDB.SaveChanges();
        }
Beispiel #4
0
        /// <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);
        }