Exemplo n.º 1
0
        private void EnsureUsernameNotExists(AuthUsername username)
        {
            var authRepository = new SQLServerAuthUserRepository();
            var match          = authRepository.Search(username);

            if (!(match is null))
            {
                throw new InvalidUsernameException(username.GetValue());
            }
        }
Exemplo n.º 2
0
        public void Create(AuthUsername username, AuthPassword password
                           , string firtName, string lastName)
        {
            EnsureUsernameNotExists(username);

            int userRoleId = (int)Roles.Customer;

            userRoleId++;

            User user = new User
            {
                Purchases  = new List <Purchase>(),
                UserRoleId = userRoleId,
                Username   = username.GetValue(),
                Password   = password.GetValue(),
                FirstName  = firtName,
                LastName   = lastName
            };

            Repository.Save(user);
        }