/// <summary> /// Gets the contact. /// </summary> /// <param name="request">The request.</param> /// <returns> /// The contact. /// </returns> public async Task <Resource> GetContact(ContactGetRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } try { var configurationBuilder = this.CreateConfigurationBuilder(); var configReader = ServiceFactory.CreateConfigurationReader(configurationBuilder); var config = configReader.Read(); var service = ServiceFactory.CreateContactService( this.serviceResolver, ConnectionHelper.CreateCosmosUserConnectionInfo(config), ConnectionHelper.CreateCosmosContactConnectionInfo(config), this.logService); var contact = await service.GetContactAsync(request).ConfigureAwait(false); this.logService.LogInformation( "Successfully executed Get Contact at {Timestamp}", DateTime.UtcNow); return(contact); } catch (Exception e) { var errorMessage = $"Fatal exception during Get Contact. ErrorMessage message: {e.Message}"; this.logService.LogError(e, errorMessage); throw; } }
/// <inheritdoc /> public Task <ContactDocument> GetContactAsync(ContactGetRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } return(this.cosmosRepository.GetContactAsync(request)); }
public async Task <ActionResult> Get([FromRoute] ContactGetRequest rq) { try { ContactGetResponse rs = await(new ContactGetService(this.Context, _contactModRepo)).RunAsync(rq); return(new ApiActionResult(this.Context.Request, rs)); } catch (Exception ex) { return(new ApiActionResult(this.Context.Request, ex)); } }
/// <inheritdoc /> public async Task <ContactDocument> GetContactAsync(ContactGetRequest request) { var query = this.client.CreateDocumentQuery <ContactDocument>( this.ContactDocumentCollectionUri, new FeedOptions() { ConsistencyLevel = ConsistencyLevel.Session, MaxItemCount = MaxPerFeedRequest, PartitionKey = new PartitionKey(request.UserId) }).Where(x => x.ContactId == request.ContactId).AsDocumentQuery(); if (!query.HasMoreResults) { return(null); } var documentFeed = await query.ExecuteNextAsync <ContactDocument>().ConfigureAwait(false); return(documentFeed.FirstOrDefault()); }