public User CreateUser(string Firstname, string Lastname, string Email, string Password) { if (!Validator.ValidateFirstname(Firstname)) { throw new ArgumentException("Der skal indtastes fornavn"); } if (!Validator.ValidateLastname(Lastname)) { throw new ArgumentException("Der skal indtastes efternavn"); } if (!Validator.ValidateEmail(Email)) { throw new ArgumentException("Der skal indtastes en gyldig email"); } if (!Validator.ValidatePassword(Password)) { throw new ArgumentException(string.Format("Der skal indtastes et password på mindst {0} karakterer", Validator.MinPasswordLength)); } string salt = HashingHelper.GenerateSalt(); string hashedPassword = HashingHelper.HashPassword(Password, salt); User user = new User { Firstname = Firstname, Lastname = Lastname, Email = Email, Password = hashedPassword, Salt = salt }; var enduser = uDB.Create(user); if (enduser == null) { throw new DublicateUserException(); } return(enduser); }