Exemple #1
0
        public ICommandResult Handle(CreateUserCommand command)
        {
            if (!_profileRepository.CheckProfile(command.ProfileId))
            {
                AddNotification("ProfileId", "Perfil não existe.");
            }

            User user = new User(command.ProfileId, command.FirstName, command.LastName, command.Email, command.BirthDate);

            AddNotifications(user.Notifications);

            if (Invalid)
            {
                return(new CommandResult(
                           false,
                           "Por favor, corrija os campos abaixo",
                           Notifications));
            }

            _userRepository.Save(user);

            return(new CommandResult(true, "Usuário criado com sucesso.", new
            {
                Nome = user.ToString()
            }));
        }