示例#1
0
        public int LoginValidation(string email, string password)
        {
            // Hash the password
            var hashedPassword = SHA512ComputeHash(password);

            // Check if is an admin
            var adminDetails = _loginRepository.CheckAdminDetails(email);

            if (adminDetails.Count > 0)
            {
                return(DetailsChecker(email, hashedPassword, adminDetails) == true ? 1 : 0);
            }

            else
            {
                // Check if is a teacher
                var teacherDetails = _loginRepository.CheckTeacherDetails(email);
                if (teacherDetails.Count > 0)
                {
                    return(DetailsChecker(email, hashedPassword, teacherDetails) == true ? 2 : 0);
                }

                else
                {
                    // Check if is a student
                    var studentDetails = _studentRepository.GetStudentLoginDetailsByEmail(email);
                    if (studentDetails.Count > 0)
                    {
                        return(DetailsChecker(email, hashedPassword, studentDetails) == true ? 3 : 0);
                    }
                }
            }

            return(0);
        }