public void AddEmail(string app) { var exist = db.Emails.FirstOrDefault(x => x.Application == app); var email = new Emails(); if (exist == null) { email.Email_1 = "*****@*****.**"; email.Email_2 = "*****@*****.**"; email.Enable = true; email.Application = app; db.Emails.Add(email); db.SaveChanges(); } }
public ActionResult DeleteUser(string User) { var del = db.Users.FirstOrDefault(data => data.User == User); if (del != null && User != "admin") { db.Users.Remove(del); db.SaveChanges(); return(Ok()); } else { return(BadRequest()); } }
public bool AddUser(string username, string password) { var hashedKey = Convert.ToBase64String(KeyDerivation.Pbkdf2( password: password, salt: salt, prf: KeyDerivationPrf.HMACSHA1, iterationCount: 10000, numBytesRequested: 256 / 8)); var hasUser = db.Users.Any(x => x.User.Equals(username)); if (!hasUser) { db.Users.Add(new Users { User = username, Password = hashedKey }); db.SaveChanges(); } return(false); }