public User Create(User user, string password)
        {
            if (string.IsNullOrWhiteSpace(password))
            {
                throw new AppException("Password is required");
            }

            if (_context.Users.Any(x => x.UserName == user.UserName))
            {
                throw new AppException("Username \"" + user.UserName + "\" is already taken");
            }

            byte[] passwordHash, passwordSalt;
            CreatePasswordHash(password, out passwordHash, out passwordSalt);

            user.PasswordHash = passwordHash;
            user.PasswordSalt = passwordSalt;

            _context.Users.Add(user);
            _context.SaveChanges();

            return(user);
        }
Пример #2
0
 public void Post([FromBody] StatePark statePark)
 {
     _db.StateParks.Add(statePark);
     _db.SaveChanges();
 }
Пример #3
0
 public void Post([FromBody] NationalPark nationalPark)
 {
     _db.NationalParks.Add(nationalPark);
     _db.SaveChanges();
 }