Exemple #1
0
 public bool checkKey(string key)
 {
     key = CryptoSHA.GenerateSHA512String(key);
     if (dbContext.KeyMonitors.Where(x => x.Key == key).Count() > 0)
     {
         return(true);
     }
     return(false);
 }
Exemple #2
0
        public bool CheckKey(string key)
        {
            ProjectDbContext dbContext = new ProjectDbContext();

            if (CryptoSHA.GenerateSHA512String(key) == dbContext.KeyMonitors.SingleOrDefault(x => x.ID == 1).Key)
            {
                return(true);
            }
            return(false);
        }
Exemple #3
0
 public int AddAccount(Account account)
 {
     try
     {
         account.Pass = CryptoSHA.GenerateSHA512String(account.Pass);
         dbContext.Accounts.Add(account);
         dbContext.SaveChanges();
         return(0);
     }
     catch
     {
         return(2);
     }
 }
Exemple #4
0
 public int EditAccount(string user, Account account)
 {
     try
     {
         var acc = GetAccount(user);
         if (acc == null)
         {
             return(1);
         }
         acc.Pass = CryptoSHA.GenerateSHA512String(account.Pass);
         dbContext.SaveChanges();
         return(0);
     }
     catch
     {
         return(2);
     }
 }
Exemple #5
0
 public bool CheckLogin(string user, string pass)
 {
     try
     {
         Account account = accountService.GetAccount(user);
         if (CryptoSHA.GenerateSHA512String(pass) == account.Pass)
         {
             if (account.Status == 1)
             {
                 return(true);
             }
         }
         return(false);
     }
     catch
     {
         return(false);
     }
 }
Exemple #6
0
 public int AddStudent(Student student)
 {
     try
     {
         var acc = new Account();
         acc.User   = student.User;
         acc.Pass   = CryptoSHA.GenerateSHA512String(student.User);
         acc.Level  = 2;
         acc.Status = 1;
         dbContext.Accounts.Add(acc);
         dbContext.Students.Add(student);
         dbContext.SaveChanges();
         return(0);
     }
     catch
     {
         return(2);
     }
 }
Exemple #7
0
 public bool ChangePass(string user, string passOld, string passNew)
 {
     try
     {
         var acc = dbContext.Accounts.SingleOrDefault(x => x.User == user);
         passOld = CryptoSHA.GenerateSHA512String(passOld);
         if (acc.Pass != passOld)
         {
             return(false);
         }
         passNew  = CryptoSHA.GenerateSHA512String(passNew);
         acc.Pass = passNew;
         dbContext.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }