private async Task MembershipsFeePaid(Guid orderId) { var userAccount = await _userAccountDataRepository.GetAsync(orderId); if (userAccount is null) { throw new ValidationException($"Cannot find the UserAccountData from PaymentHistory with OrderId: {orderId}"); } userAccount.PaidMembershipFee(); await _userAccountDataRepository.UpdateAsync(userAccount); }
public async Task <Unit> Handle(ChangeAvatarCommand request, CancellationToken cancellationToken = default(CancellationToken)) { var user = await _userAccountDataRepository.GetAsync(request.UserAccountDataId); if (user is null) { throw new AccountNotFoundException($"User with given ID cannot be found - {request.UserAccountDataId}"); } user.ChangeAvatar(request.AvatarPath); await _userAccountDataRepository.UpdateAsync(user); return(Unit.Value); }
public async Task <Unit> Handle(UpdateUserCommand command, CancellationToken cancellationToken = default(CancellationToken)) { var userToUpdate = await _userAccountDataRepository.GetAsync(command.UserId); ValidatePermission(userToUpdate, command.RequestedUser, command.Role); var userWithEmail = await _userAccountDataRepository.GetAsync(command.Email); if (userWithEmail != null && userWithEmail.Id != userToUpdate.Id) { throw new ValidationException("Email does already exists."); } userToUpdate.UpdateInformation(command.Email, command.FirstName, command.LastName, command.Street, command.City, command.ZipCode, command.Country, command.BtcWalletAddress, command.InitiativeDescription); userToUpdate.UpdateRole(command.Role); await _userAccountDataRepository.UpdateAsync(userToUpdate); return(Unit.Value); }