コード例 #1
0
 // Register Control And Update Student
 public string RegisterControl(StudentLoginDTO studentLogin)
 {
     using (GraduateStudentContext context = new GraduateStudentContext())
     {
         var result = context.Students.SingleOrDefault(x => x.SchoolNumber == studentLogin.SchoolNumber);
         if (result != null)
         {
             if (result.IsGraduate)
             {
                 if (string.IsNullOrEmpty(result.Password))
                 {
                     result.Password         = studentLogin.Password;
                     result.RegistrationDate = DateTime.Now;
                     context.Students.Update(result);
                     context.SaveChanges();
                     return(Messages.SuccessRecord);
                 }
                 else
                 {
                     return(Messages.HasRecord);
                 }
             }
             else
             {
                 return(Messages.NotYetGraduated);
             }
         }
         return(Messages.NoRecord);
     }
 }
コード例 #2
0
 public IActionResult Register(StudentLoginDTO studentLoginDTO)
 {
     if (studentLoginDTO != null)
     {
         TempData["RegisterControl"] = _studentService.RegisterControl(studentLoginDTO);
     }
     return(View());
 }
コード例 #3
0
 public bool LoginControl(StudentLoginDTO studentLogin)
 {
     using (GraduateStudentContext context = new GraduateStudentContext())
     {
         var result = context.Students.SingleOrDefault(x => x.SchoolNumber == studentLogin.SchoolNumber && x.Password == studentLogin.Password);
         if (result != null)
         {
             return(true);
         }
         return(false);
     }
 }
        public async Task <IActionResult> LoginStudent(StudentLoginDTO st)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new { message = "Fill all fields" }));
            }
            var student = await CreateIdentity(st.Email, st.Password);

            if (student == null)
            {
                return(Unauthorized(new { message = "Username or password is incorrect" }));
            }
            string token = TokenCreatingService.CreateToken(student, out string identityName, Configuration);

            HttpContext.Session.SetString("Token", token);
            HttpContext.Session.SetInt32("Id", int.Parse(student.Claims.SingleOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value));
            HttpContext.Session.SetString("Name", student.Claims.SingleOrDefault(c => c.Type == ClaimTypes.Name).Value);
            HttpContext.Session.SetString("Role", student.Claims.SingleOrDefault(c => c.Type == ClaimTypes.Role).Value);
            return(Ok(new { token = token, name = identityName }));
        }
コード例 #5
0
        public IActionResult Login(StudentLoginDTO studentLoginDTO)
        {
            var isLogin = _studentService.LoginControl(studentLoginDTO);

            if (isLogin)
            {
                var student = _studentService.GetDetail(studentLoginDTO.SchoolNumber);
                HttpContext.Session.SetString("id", student.Id.ToString());
                HttpContext.Session.SetString("fullname", student.FullName);
                HttpContext.Session.SetString("department", student.Department.Name);
                HttpContext.Session.SetString("schoolNumber", student.SchoolNumber);
                HttpContext.Session.SetString("TcNo", student.TC);
                HttpContext.Session.SetString("telephoneNumber", student.TelephoneNumber);
                HttpContext.Session.SetString("birthdayDate", Convert.ToDateTime(student.BirthdayDate).ToShortDateString());
                HttpContext.Session.SetString("email", student.Email);
                HttpContext.Session.SetString("graduateYear", student.GraduateYear.ToString());
                HttpContext.Session.SetString("registrationDate", Convert.ToDateTime(student.RegistrationDate).ToShortDateString());

                return(RedirectToAction("Index", "Student"));
            }
            TempData["Failed"] = "Giriş Başarısız";
            return(View());
        }
コード例 #6
0
 public bool LoginControl(StudentLoginDTO studentLogin)
 {
     return(_studentDal.LoginControl(studentLogin));
 }
コード例 #7
0
 public string RegisterControl(StudentLoginDTO studentLogin)
 {
     return(_studentDal.RegisterControl(studentLogin));
 }