/// <summary> /// Creates an article tag. /// </summary> /// <param name="value">The article tag 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 tag. /// </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 <ArticleTag> CreateTagAsync(ArticleTag value, CancellationToken token = default) { if (value == null || value.ArticleId == 0 || value.Name == null) { throw new ArgumentException("article tag or a value of the article tag is null", nameof(value)); } if (value.Id != 0) { throw new ArgumentException("invalid article tag id", nameof(value)); } var wrappedModel = new ArticleTagWrapper { ArticleTag = value.ToApi() }; var jsonModel = await PostAsync($"/api/{EntityTagsUrlFragment}", wrappedModel, token); return(jsonModel.ToDomain()); }
public ArticleTag ApiToDomain(ArticleTagWrapper value) { return(ApiToDomain(value?.ArticleTag)); }
internal static ArticleTag ToDomain(this ArticleTagWrapper value) { return(s_articleTagMapper.ApiToDomain(value)); }
internal static ArticleTag ToDomain(this ArticleTagWrapper value) { return(value?.ArticleTag.ToDomain()); }