public virtual async Task <LinkPreviewModel> Preview(string url) { var openGraphObject = _openGraphService.GetOpenGraphObject(url); if (openGraphObject != null) { var localRequestEntity = Map(openGraphObject); _previewRepository.Add(localRequestEntity); return(_linkPreviewModelMapper.MapPreview(localRequestEntity)); } var result = await _linkPreviewClient.GetLinkPreview(url); if (!result.IsSuccess) { return(null); } var entity = Map(result.Preview, url); _previewRepository.Add(entity); var linkPreview = _linkPreviewModelMapper.MapPreview(entity); return(linkPreview); }
public virtual async Task <LinkPreview.LinkPreview> Preview(string url) { var result = await _linkPreviewClient.GetLinkPreview(url); if (!result.IsSuccess) { return(null); } var entity = Map(result.Preview, url); _previewRepository.Add(entity); var model = _linkPreviewModelMapper.MapPreview(entity); return(model); }