예제 #1
0
        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();
            }
        }
예제 #2
0
        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());
            }
        }
예제 #3
0
        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);
        }