public static void Delete(Account account) { using (AuguryEntities ctx = new AuguryEntities()) { ctx.Accounts.Remove(account); ctx.SaveChanges(); } }
public static void Create(Account account) { account.Password = PasswordHelper.EncryptedPassword(account.Password); using (AuguryEntities ctx = new AuguryEntities()) { ctx.Accounts.Add(account); ctx.SaveChanges(); } }
public void PasswordEncryption() { string salt = ConfigurationManager.AppSettings["SaltString"]; var account = new Account() { Username = "******", Password = "******" }; account.Password = HashAndSalt.Encrypt(account.Password, salt); bool decrypted = HashAndSalt.CompareString("toto", account.Password, salt); Assert.IsTrue(decrypted); }
public static void Update(Account account) { using (AuguryEntities ctx = new AuguryEntities()) { Account a = ctx.Accounts.Single(x => x.Username == account.Username); account.Password = PasswordHelper.EncryptedPassword(account.Password); a.Password = account.Password; ctx.SaveChanges(); } }
public void UpdateAccount() { var account = new Account() { Username = "******", Password = HashAndSalt.Encrypt("tata", ConfigurationManager.AppSettings["SaltString"]) }; AccountManager.Update(account); }