public ArticleWrapper Convert(ArticleResponseWrapper articleResponseWrapper) { var articleWrapper = new ArticleWrapper(); if (articleResponseWrapper.ArticleResponse.Articles.Count > 0) { var article = articleResponseWrapper.ArticleResponse.Articles[0]; articleWrapper.ArticleRef = article.ArticleRef; if (articleResponseWrapper.CompanySubscription != null) { foreach (var subscriptionPreferenceWrapper in articleResponseWrapper.CompanySubscription.SubscriptionPreferences) { if (article.MetadataCodes != null) { if (article.MetadataCodes.GetCompanyCodes().ContainsKey(subscriptionPreferenceWrapper.EntityCode.ToUpper()) || article.MetadataCodes.GetCompanyCodes() .ContainsKey(subscriptionPreferenceWrapper.EntityCode.ToLower())) { articleWrapper.Companies.Add(subscriptionPreferenceWrapper.EntityName); articleWrapper.EntityCodes.Add(subscriptionPreferenceWrapper.EntityCode.ToUpper()); } } } } } return(articleWrapper); }
/// <summary> /// Creates an article. /// </summary> /// <param name="value">The article to create.</param> /// <param name="token">The cancellation token.</param> /// <returns> /// A task that represents the asynchronous operation. /// The task result contains the new article. /// </returns> /// <exception cref="ArgumentException">Thrown when the parameter check fails.</exception> /// <exception cref="NotAuthorizedException">Thrown when not authorized to access this resource.</exception> /// <exception cref="NotFoundException">Thrown when the resource url could not be found.</exception> public async Task <Article> CreateAsync(Article value, CancellationToken token = default) { if (value == null) { throw new ArgumentNullException(nameof(value)); } if (value.Id != 0) { throw new ArgumentException("invalid article id", nameof(value)); } var wrappedModel = new ArticleWrapper { Article = value.ToApi() }; var jsonModel = await PostAsync($"/api/{EntityUrlFragment}", wrappedModel, token).ConfigureAwait(false); return(jsonModel.ToDomain()); }
internal static Article ToDomain(this ArticleWrapper value) { return(s_articleMapper.ApiToDomain(value)); }
public Article ApiToDomain(ArticleWrapper value) { return(ApiToDomain(value?.Article)); }
public void setArticleInfo(ArticleWrapper i) { ArticleInfo = i; }
public ArticleViewModel(ArticleWrapper articleWrapper) : base(articleWrapper.Title) { Article = articleWrapper; }
internal static Article ToDomain(this ArticleWrapper value) { return(value?.Article.ToDomain()); }