public Task <AsyncTaskResult> HandleAsync(UserLockedEvent evnt)
 {
     return(TryUpdateRecordAsync(connection =>
     {
         return connection.UpdateAsync(new
         {
             IsLocked = (int)UserLock.Locked,
             Version = evnt.Version,
             EventSequence = evnt.Sequence
         }, new
         {
             Id = evnt.AggregateRootId,
             //Version = evnt.Version - 1
         }, ConfigSettings.UserTable);
     }));
 }
Beispiel #2
0
        public async Task AllowUserToLoginAsync(User user, bool allow)
        {
            var identityResult = await _userManager.SetLockoutEnabledAsync(user, !allow);

            if (!identityResult.Succeeded)
            {
                throw new LocalException(identityResult.Errors.First().Description);
            }

            IEvent @event;

            if (allow)
            {
                user = await FindByIdAsync(user.Id);

                @event = new UserUnlockedEvent {
                    User = user
                };
            }
            else
            {
                identityResult = await _userManager.SetLockoutEndDateAsync(user, DateTimeOffset.MaxValue);

                if (!identityResult.Succeeded)
                {
                    throw new LocalException(identityResult.Errors.First().Description);
                }

                user = await FindByIdAsync(user.Id);

                @event = new UserLockedEvent {
                    User = user
                };
            }
            await _domainEvents.RaiseAsync(@event);
        }
Beispiel #3
0
 private void Handle(UserLockedEvent evnt)
 {
     _isLocked = true;
 }
Beispiel #4
0
 public async Task HandleAsync(UserLockedEvent args)
 {
     await SendNotificationAsync <Guid?, User, UserDto>(args, args.User, args.User.FullName);
 }