Beispiel #1
0
 public static bool IsUserExist(int userID)
 {
     using (var context = new ImageDataEntities())
     {
         if (context.Users.Where(u => u.Id == userID).Count() > 0)
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #2
0
 public static bool IsUserExist(string userName)
 {
     using (var context = new ImageDataEntities())
     {
         if (context.Users.Where(u => u.Name == userName).Count() > 0)
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #3
0
 public static bool IsLoginDataValid(string userName, string password)
 {
     using (var context = new ImageDataEntities())
     {
         if (context.Users.Where(u => u.Password == Algorithms.HashAlgorithm.GetHashCode(password) &&
                                 u.Name == userName).Count() > 0)
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #4
0
 public static bool RegisterUser(string userName, string password)
 {
     if (Accounts.IsUserExist(userName))
     {
         return(false);
     }
     using (var context = new ImageDataEntities())
     {
         User userEntity = new User()
         {
             Name     = userName,
             Password = Algorithms.HashAlgorithm.GetHashCode(password),
             Role     = 2
         };
         context.Users.Add(userEntity);
         context.SaveChanges();
     }
     return(true);
 }