Beispiel #1
0
        // Create User
        public ValidationResult CreateUser(UserDTO userDTO)
        {
            var user = new User
            {
                FirstName   = userDTO.Firstname,
                LastFourSSN = userDTO.LastFourSSN,
                LastName    = userDTO.Lastname,
                AccessCode  = GenerateAccessCode(userDTO.Firstname, userDTO.Lastname, userDTO.LastFourSSN)
            };


            var validatedUserResult = UserSpecs.ValidateUser(user);

            if (validatedUserResult.IsValid)
            {
                _dbContext.Users.Add(user);
                _dbContext.SaveChanges();
            }

            return(validatedUserResult);
        }