Ejemplo n.º 1
0
 public UpdateAUserValidationContext(UpdateAUserCommand command, IUserRepository repository)
 {
     Command = command;
     RepositoryValidationContext = new CommonUserRepositoryValidationContext(repository)
     {
         Id    = Command.UserId,
         Email = Command.Email
     };
 }
Ejemplo n.º 2
0
        public async Task <User> Handle(UpdateAUserCommand command, CancellationToken cancellationToken = default)
        {
            var validationContext = new UpdateAUserValidationContext(command, _repository);

            _updateValidator.Validate(validationContext);

            var user = _repository.Get(command.UserId);

            user.Update(command);

            _dbContext.Users.Update(user);
            await _dbContext.SaveChangesAsync();

            return(user);
        }
        public void Setup()
        {
            var acceptedNotifiers     = new[] { NotifierType.InApp, NotifierType.Mail };
            var acceptedNotifications = new[] { NotificationType.CreatedSuggestion, NotificationType.NewCommentOnYourSuggestion };
            var validCommand          = new UpdateAUserCommand
            {
                UserId = "any user id",
                Email  = "*****@*****.**",
                AcceptedNotifications = EnumerationFlagsHelpers.ToInteger(acceptedNotifications),
                AcceptedNotifiers     = EnumerationFlagsHelpers.ToInteger(acceptedNotifiers)
            };

            _repository        = new UserRepository(_dbContext);
            _validationContext = new UpdateAUserValidationContext(validCommand, _repository);

            CreateTheUser();
        }
 public void Update(UpdateAUserCommand command)
 {
     Email = command.Email;
     NotificationSetting.AcceptedNotifications = command.AcceptedNotifications;
     NotificationSetting.AcceptedNotifiers     = command.AcceptedNotifiers;
 }