Exemple #1
0
 private static void CreateAdmin()
 {
     using (var db = new InsideDBEntities())
     {
         db.Users.Add(new User
         {
             Login          = "******",
             Password       = PassHashing.GetPasswordHashWithSalt("admin"),
             Role           = "admin",
             LicenseExpDate = DateTime.Parse("01.01.2050"),
         });
         db.SaveChanges();
     }
 }
Exemple #2
0
 public void EditUser(string login, string password, string role, string license, string email)
 {
     using (var db = new InsideDBEntities())
     {
         var user = db.Users.Find(login);
         //keep old pass if parameter is empty
         if (password != "")
         {
             user.Password = PassHashing.GetPasswordHashWithSalt(password);
         }
         user.Role           = role;
         user.Email          = email;
         user.LicenseExpDate = DateTime.Parse(license);
         db.SaveChanges();
     }
     GetUsers();
 }
Exemple #3
0
 public void AddUser(string login, string password, string role, string license, string email)
 {
     using (var db = new InsideDBEntities())
     {
         var user = new User
         {
             Login    = login,
             Password = PassHashing.GetPasswordHashWithSalt(password),
             Role     = role,
             Email    = email
         };
         if (role != "demo")
         {
             user.LicenseExpDate = DateTime.Parse(license);
         }
         db.Users.Add(user);
         db.SaveChanges();
     }
     GetUsers();
 }