public async Task Handle(CustomerSavedNotification notification, CancellationToken cancellationToken) { var characters = _characterHashService.GetCharacters(notification.SavedCustomer.FirstName); characters = characters.Append(_characterHashService.GetCharacters(notification.SavedCustomer.MiddleName)); characters = characters.Append(_characterHashService.GetCharacters(notification.SavedCustomer.LastName)); var customer = await _customerService.GetCustomerById(notification.SavedCustomer.Id, cancellationToken); if (customer == null || customer.LastIndexed.HasValue) { return; } BackgroundJob.Enqueue <IMediatorService>((mediator) => mediator.Send(new SaveCustomerHashesRequest { Characters = characters.ToArray(), CustomerId = notification.SavedCustomer.Id }, cancellationToken)); customer.LastIndexed = _clockProvider.DateTimeOffset; await _customerService.SaveCustomer(customer, true, true, cancellationToken); }
public override async Task <SearchCustomersByKeywordResponse> Handle(SearchCustomersByKeywordRequest request, CancellationToken cancellationToken) { var characters = _characterHashService.GetCharacters(request.Keyword).Distinct(); var characterHashes = _characterHashService.GetHashes(_hashes, characters); var customers = await _customerHashService .GetCustomersByHash(characterHashes, cancellationToken, configure => { configure.PageNumber = request.PageNumber; configure.MaximumRowsPerPage = request.MaximumRowsPerPage; configure.UseAsync = true; }); var decryptedCustomers = await Encryption.Decrypt <Customer, CustomerDto>(customers); return(Response.Success <SearchCustomersByKeywordResponse>(decryptedCustomers)); }