Exemplo n.º 1
0
 private static User _IsUserPassCorrect(string username, string password)
 {
     UserDataClassesDataContext dc = new UserDataClassesDataContext();
     var queryResult = (from users in dc.GetTable<User>()
                        where (users.Username == username) &&
                        (users.Password == password)
                        select users).ToArray<User>();
     if (queryResult.Count<User>() > 0)
         return queryResult.ElementAt<User>(0);
     return null;
 }
Exemplo n.º 2
0
        private static int _IsUserCorrect(string username)
        {
            UserDataClassesDataContext dc = new UserDataClassesDataContext();
            var queryResult = (from users in dc.GetTable<User>()
                               where (users.Username == username)
                               select users).ToArray<User>();
            if (queryResult.Count<User>() > 0)

                return queryResult.ElementAt<User>(0).Role;
            return -1;
        }
Exemplo n.º 3
0
        public static bool IsUsernameTaken(string username)
        {
            UserDataClassesDataContext dc = new UserDataClassesDataContext();
            var queryResult = (from users in dc.GetTable<User>()
                               where (users.Username == username)
                               select users.Username).ToArray<string>();

            if (queryResult.Count<string>() > 0)
                return true;

            return false;
        }
Exemplo n.º 4
0
        public static Student GetStudentDataByUser(string facNumber)
        {
            UserDataClassesDataContext dc = new UserDataClassesDataContext();
            var result = (from students in dc.GetTable<Student>()
                          where (students.FacNumber == facNumber)
                          select students).ToArray<Student>();

            if (result.Count<Student>() > 0)
                return result[0] as Student;

            return null;
        }
Exemplo n.º 5
0
 public static bool _IfUserFacNumberExist(string FacuNumber)
 {
     UserDataClassesDataContext dc = new UserDataClassesDataContext();
     var queryResult = (from users in dc.GetTable<User>()
                        where (users.FacNumber == FacuNumber)
                        select users).ToArray<User>();
     if (queryResult.Count<User>() > 0)
         return true;
     else
     {
         return false;
     }
 }
Exemplo n.º 6
0
 public static bool IsUsernameBusy(string s)
 {
     UserDataClassesDataContext dc = new UserDataClassesDataContext();
     var queryResult = (from users in dc.GetTable<User>()
                        where (users.Username == s)
                        select users).ToArray<User>();
     if (queryResult.Count<User>() > 0)
     {
         return true;
     }
     else
         return false;
 }
Exemplo n.º 7
0
        public static bool HasAdminRights(string loggedUsername)
        {
            UserDataClassesDataContext dc = new UserDataClassesDataContext();

            var result = (from user in dc.GetTable<User>()
                          where (user.Username == loggedUsername)
                          select user.Role).ToArray<int>();

            if (result != null)
            {
                return ((int)result[0] == 1);
            }
            else
            {
                throw new UnauthorizedAccessException("Unauthorized access!");
            }
        }