public async Task Query_UserId_SingleMatch() { var queryResult = await evacueeRepository.Query(new EvacueeQuery { UserId = TestEvacueeUserId }); queryResult.Items.ShouldNotBeEmpty(); queryResult.Items.ShouldHaveSingleItem().UserId.ShouldBe(TestEvacueeUserId); }
public async System.Threading.Tasks.Task Load(Shared.Contracts.Events.Support support, CancellationToken ct) { if (!string.IsNullOrEmpty(support.CreatedBy?.Id)) { var teamMember = (await teamRepository.GetMembers(userId: support.CreatedBy.Id)).SingleOrDefault(); if (teamMember != null) { support.CreatedBy.DisplayName = $"{teamMember.FirstName}, {teamMember.LastName.Substring(0, 1)}"; support.CreatedBy.TeamId = teamMember.TeamId; support.CreatedBy.TeamName = teamMember.TeamName; if (support.IssuedBy == null) { support.IssuedBy = support.CreatedBy; } } } if (support.SupportDelivery is Shared.Contracts.Events.Referral referral && !string.IsNullOrEmpty(referral.SupplierDetails?.Id)) { var supplier = (await supplierRepository.QuerySupplier(new SupplierSearchQuery { SupplierId = referral.SupplierDetails.Id, ActiveOnly = false })).Items.SingleOrDefault(); if (supplier != null) { referral.SupplierDetails.Name = supplier.LegalName; referral.SupplierDetails.Address = mapper.Map <Shared.Contracts.Events.Address>(supplier.Address); referral.SupplierDetails.TeamId = supplier.Team?.Id; referral.SupplierDetails.TeamName = supplier.Team?.Name; referral.SupplierDetails.Phone = supplier.Contact.Phone; } } if (support.SupportDelivery is Shared.Contracts.Events.Interac interac && !string.IsNullOrEmpty(interac.ReceivingRegistrantId)) { var recipient = (await evacueesRepository.Query(new EvacueeQuery { EvacueeId = interac.ReceivingRegistrantId })).Items.SingleOrDefault(); if (recipient != null) { interac.RecipientFirstName = recipient.FirstName; interac.RecipientLastName = recipient.LastName; } var payment = ((SearchPaymentResponse)await paymentRepository.Query(new SearchPaymentRequest { ByLinkedSupportId = support.Id })).Items.Where(p => p.Status != PaymentStatus.Cancelled).Cast <InteracSupportPayment>().OrderByDescending(p => p.CreatedOn).FirstOrDefault(); if (payment != null && payment is InteracSupportPayment interacPayment) { interac.SecurityAnswer = interacPayment.SecurityAnswer; interac.SecurityQuestion = interacPayment.SecurityAnswer; interac.RelatedPaymentId = interacPayment.Id; } } }