NNews 0.5.1
dotnet add package NNews --version 0.5.1
NuGet\Install-Package NNews -Version 0.5.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NNews" Version="0.5.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NNews" Version="0.5.1" />
<PackageReference Include="NNews" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NNews --version 0.5.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: NNews, 0.5.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NNews@0.5.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NNews&version=0.5.1
#tool nuget:?package=NNews&version=0.5.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
NNews
Unified package for the NNews content management system. Contains Data Transfer Objects (DTOs) and Anti-Corruption Layer (ACL) HTTP clients for consuming the NNews API, including support for articles, categories, tags, images, and AI-powered content generation.
Installation
dotnet add package NNews
Or via Package Manager Console:
Install-Package NNews
Features
DTOs (NNews.DTO)
- Article DTOs: Complete models for article creation, updates, and retrieval
- AI Integration DTOs: Support for AI-powered content generation with ChatGPT and DALL-E 3
- Category & Tag DTOs: Hierarchical category and tag management
- Pagination Support: Built-in paged result models
- Settings DTOs: Configuration models for NNews API integration
- JSON Serialization: Optimized for System.Text.Json with proper property naming
Clients (NNews.ACL)
- Article Management: Complete CRUD operations with filtering, search, and deletion
- AI Content Generation: Create and update articles using ChatGPT and DALL-E 3
- Category Management: Hierarchical category operations with role-based filtering
- Tag Management: Tag CRUD with merging capabilities
- Image Management: Upload and retrieve images from storage
- Type-Safe: Strongly-typed clients with full IntelliSense support
- Async/Await: Modern async API for all operations
- Cancellation Support: CancellationToken support for all async operations
- Dependency Injection Ready: Easy integration with .NET DI container
Core DTOs
ArticleInfo
public class ArticleInfo
{
public long ArticleId { get; set; }
public string Title { get; set; }
public string Content { get; set; } // HTML content
public long CategoryId { get; set; }
public CategoryInfo? Category { get; set; }
public IList<TagInfo>? Tags { get; set; }
public int Status { get; set; } // 0=Draft, 1=Published, 2=Archived, 3=Scheduled
public DateTime DateAt { get; set; }
public string? ImageName { get; set; }
public IList<RoleInfo>? Roles { get; set; }
}
ArticleInsertedInfo
public class ArticleInsertedInfo
{
public string Title { get; set; }
public string Content { get; set; }
public long CategoryId { get; set; }
public string? TagList { get; set; } // Comma-separated tags
public int Status { get; set; }
public DateTime DateAt { get; set; }
public string? ImageName { get; set; }
public List<string>? Roles { get; set; }
}
AI DTOs
// Request for AI-powered article creation/updates
public class AIArticleRequest
{
public long? ArticleId { get; set; }
public string Prompt { get; set; }
public bool GenerateImage { get; set; } = false;
}
// AI-generated article response
public class AIArticleResponse
{
public string Title { get; set; }
public string Content { get; set; }
public long CategoryId { get; set; }
public string TagList { get; set; }
public string? ImagePrompt { get; set; } // Portuguese description for DALL-E 3
}
PagedResult<T>
public class PagedResult<T>
{
public IList<T> Items { get; set; }
public int Page { get; set; }
public int PageSize { get; set; }
public int TotalCount { get; set; }
public int TotalPages { get; set; }
}
ACL Clients - Quick Start
Setup with Dependency Injection
using Microsoft.Extensions.DependencyInjection;
using NNews.ACL;
using NNews.ACL.Interfaces;
using NNews.DTO.Settings;
var services = new ServiceCollection();
// Configure NNews API settings
services.Configure<NNewsSetting>(options =>
{
options.ApiUrl = "https://api.nnews.example.com";
});
// Register HTTP clients
services.AddHttpClient<IArticleClient, ArticleClient>();
services.AddHttpClient<IArticleAIClient, ArticleAIClient>();
services.AddHttpClient<ICategoryClient, CategoryClient>();
services.AddHttpClient<ITagClient, TagClient>();
services.AddHttpClient<IImageClient, ImageClient>();
ArticleClient Usage
using NNews.ACL.Interfaces;
using NNews.DTO;
// List articles with pagination
var articles = await articleClient.GetAllAsync(categoryId: 1, page: 1, pageSize: 10);
// Filter by status (0=Draft, 1=Published, 2=Archived, 3=Scheduled)
var published = await articleClient.GetAllAsync(status: 1, page: 1, pageSize: 10);
// Search articles
var results = await articleClient.SearchAsync("AI technology", page: 1, pageSize: 10);
// Create article
var newArticle = new ArticleInsertedInfo
{
Title = "Getting Started with AI",
Content = "<h2>Introduction</h2><p>...</p>",
CategoryId = 1,
TagList = "AI, Technology, Innovation",
Status = 0, // Draft
DateAt = DateTime.UtcNow
};
var created = await articleClient.CreateAsync(newArticle);
// Delete article
await articleClient.DeleteAsync(articleId: 42);
AI Content Generation
using NNews.ACL.Interfaces;
// Create article with AI
var article = await aiClient.CreateWithAIAsync(
prompt: "Write an article about the future of AI in healthcare",
generateImage: true // Generate image with DALL-E 3
);
// Update article with AI
var updated = await aiClient.UpdateWithAIAsync(
articleId: 123,
prompt: "Add a section about recent breakthroughs",
generateImage: false
);
Category & Tag Management
// Categories
var categories = await categoryClient.GetAllAsync();
var category = await categoryClient.CreateAsync(new CategoryInfo { Title = "Technology" });
await categoryClient.DeleteAsync(id: 5);
// Tags
var tags = await tagClient.GetAllAsync();
await tagClient.MergeTagsAsync(sourceTagId: 10, targetTagId: 20);
Article Status Codes
| Code | Status | Description |
|---|---|---|
| 0 | Draft | Article is being written |
| 1 | Published | Article is live and visible |
| 2 | Archived | Article is archived |
| 3 | Scheduled | Article scheduled for future publication |
Interface Summary
public interface IArticleClient
{
Task<PagedResult<ArticleInfo>> GetAllAsync(long? categoryId, int? status, int page, int pageSize, CancellationToken ct);
Task<PagedResult<ArticleInfo>> ListByCategoryAsync(long categoryId, int page, int pageSize, CancellationToken ct);
Task<PagedResult<ArticleInfo>> ListByRolesAsync(int page, int pageSize, CancellationToken ct);
Task<PagedResult<ArticleInfo>> ListByTagAsync(string tagSlug, int page, int pageSize, CancellationToken ct);
Task<PagedResult<ArticleInfo>> SearchAsync(string keyword, int page, int pageSize, CancellationToken ct);
Task<ArticleInfo> GetByIdAsync(int id, CancellationToken ct);
Task<ArticleInfo> CreateAsync(ArticleInsertedInfo article, CancellationToken ct);
Task<ArticleInfo> UpdateAsync(ArticleUpdatedInfo article, CancellationToken ct);
Task DeleteAsync(int id, CancellationToken ct);
}
public interface IArticleAIClient
{
Task<ArticleInfo> CreateWithAIAsync(string prompt, bool generateImage, CancellationToken ct);
Task<ArticleInfo> UpdateWithAIAsync(int articleId, string prompt, bool generateImage, CancellationToken ct);
}
public interface ICategoryClient
{
Task<IList<CategoryInfo>> GetAllAsync(CancellationToken ct);
Task<IList<CategoryInfo>> ListByParentAsync(long? parentId, CancellationToken ct);
Task<CategoryInfo> GetByIdAsync(int id, CancellationToken ct);
Task<CategoryInfo> CreateAsync(CategoryInfo category, CancellationToken ct);
Task<CategoryInfo> UpdateAsync(CategoryInfo category, CancellationToken ct);
Task DeleteAsync(int id, CancellationToken ct);
}
public interface ITagClient
{
Task<IList<TagInfo>> GetAllAsync(CancellationToken ct);
Task<IList<TagInfo>> ListByRolesAsync(CancellationToken ct);
Task<TagInfo> GetByIdAsync(int id, CancellationToken ct);
Task<TagInfo> CreateAsync(TagInfo tag, CancellationToken ct);
Task<TagInfo> UpdateAsync(TagInfo tag, CancellationToken ct);
Task DeleteAsync(int id, CancellationToken ct);
Task MergeTagsAsync(long sourceTagId, long targetTagId, CancellationToken ct);
}
public interface IImageClient
{
Task<string> UploadImageAsync(IFormFile file, CancellationToken ct);
}
Supported Frameworks
- .NET 8.0+
- Compatible with: ASP.NET Core, Blazor, Console apps, Azure Functions, AWS Lambda
Dependencies
Microsoft.AspNetCore.Http.Features(>= 5.0.17)Microsoft.Extensions.Configuration.Abstractions(>= 9.0.0)Microsoft.Extensions.Options(>= 10.0.0)Microsoft.IdentityModel.Tokens(>= 8.15.0)
License
This project is licensed under the MIT License - see the LICENSE file for details.
Made with love for the .NET community
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.AspNetCore.Http.Features (>= 5.0.17)
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
- Microsoft.IdentityModel.Tokens (>= 8.15.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.5.1 | 247 | 3/15/2026 |
| 0.5.0 | 178 | 3/15/2026 |
| 0.4.9 | 182 | 3/14/2026 |
| 0.4.8 | 182 | 3/14/2026 |
| 0.4.7 | 184 | 3/14/2026 |
| 0.4.6 | 187 | 3/14/2026 |
| 0.4.5 | 190 | 3/14/2026 |
| 0.4.4 | 180 | 3/14/2026 |
| 0.4.3 | 189 | 3/14/2026 |
| 0.4.2 | 190 | 3/11/2026 |
| 0.4.1 | 179 | 3/11/2026 |
| 0.4.0 | 165 | 3/11/2026 |
| 0.3.9 | 177 | 3/11/2026 |
| 0.3.8 | 174 | 3/11/2026 |
| 0.3.7 | 177 | 3/11/2026 |
| 0.3.6 | 145 | 2/22/2026 |
| 0.3.5 | 144 | 2/19/2026 |
| 0.3.4 | 130 | 2/19/2026 |
| 0.3.3 | 133 | 2/18/2026 |