Lofn 0.4.11
dotnet add package Lofn --version 0.4.11
NuGet\Install-Package Lofn -Version 0.4.11
<PackageReference Include="Lofn" Version="0.4.11" />
<PackageVersion Include="Lofn" Version="0.4.11" />
<PackageReference Include="Lofn" />
paket add Lofn --version 0.4.11
#r "nuget: Lofn, 0.4.11"
#:package Lofn@0.4.11
#addin nuget:?package=Lofn&version=0.4.11
#tool nuget:?package=Lofn&version=0.4.11
Lofn - Client SDK for the Lofn Sales Platform API
Overview
Lofn is a .NET 8 client SDK (Anti-Corruption Layer) that provides typed HTTP clients and DTOs for consuming the Lofn Sales Platform REST API. It allows external applications to integrate with the Lofn backend for managing stores, products, categories, images, store users, and shopping carts without coupling to internal API details.
Part of the Lofn ecosystem — this package is consumed by frontend applications and other services that need to interact with the Lofn API.
🚀 Features
- 🛒 Product Management — Search, list, create, and update products with pagination support
- 🏪 Store Operations — Full CRUD for stores with slug-based lookups
- 📂 Category Management — Create, update, delete, and list categories per store
- 🖼️ Image Upload — Stream-based image upload with sort order support
- 👥 Store User Management — Add, list, and remove store team members
- 🛍️ Shopping Cart — Create and manage shopping carts
- 🔐 Multi-Tenant Support — Automatic
X-Tenant-Idheader propagation viaTenantHeaderHandler - 📦 Typed DTOs — Strongly-typed request/response objects with enums for status and product types
🛠️ Technologies Used
Core Framework
- .NET 8.0 — Target framework
Dependencies
- NAuth 0.5.5 — Authentication integration
- Newtonsoft.Json 13.0.3 — JSON serialization/deserialization
- Microsoft.AspNetCore.Authentication 2.3.0 — Authentication abstractions
- Microsoft.Extensions.Configuration.Abstractions 9.0.8 — Configuration support
📁 Project Structure
Lofn/
├── ACL/ # Anti-Corruption Layer (HTTP clients)
│ ├── Core/
│ │ └── BaseClient.cs # Abstract base with HttpClient setup
│ ├── Handlers/
│ │ └── TenantHeaderHandler.cs # DelegatingHandler for X-Tenant-Id
│ ├── Interfaces/
│ │ ├── ICategoryClient.cs # Category operations contract
│ │ ├── IImageClient.cs # Image operations contract
│ │ ├── IProductClient.cs # Product operations contract
│ │ ├── IStoreClient.cs # Store operations contract
│ │ └── IStoreUserClient.cs # Store user operations contract
│ ├── CategoryClient.cs # Category API client
│ ├── ImageClient.cs # Image API client
│ ├── ProductClient.cs # Product API client
│ ├── StoreClient.cs # Store API client
│ └── StoreUserClient.cs # Store user API client
├── DTO/ # Data Transfer Objects
│ ├── Category/
│ │ ├── CategoryInfo.cs
│ │ ├── CategoryInsertInfo.cs
│ │ └── CategoryUpdateInfo.cs
│ ├── Product/
│ │ ├── ProductInfo.cs
│ │ ├── ProductInsertInfo.cs
│ │ ├── ProductUpdateInfo.cs
│ │ ├── ProductImageInfo.cs
│ │ ├── ProductListPagedInfo.cs
│ │ ├── ProductListPagedResult.cs
│ │ ├── ProductSearchParam.cs
│ │ ├── ProductSearchInternalParam.cs
│ │ ├── ProductStatusEnum.cs
│ │ └── ProductTypeEnum.cs
│ ├── Settings/
│ │ └── LofnSetting.cs # API URL + Bucket configuration
│ ├── ShopCart/
│ │ └── ShopCartInfo.cs
│ └── Store/
│ ├── StoreInfo.cs
│ ├── StoreInsertInfo.cs
│ ├── StoreUpdateInfo.cs
│ ├── StoreStatusEnum.cs
│ ├── StoreUserInfo.cs
│ └── StoreUserInsertInfo.cs
├── Lofn.csproj
└── README.md
Ecosystem
| Project | Type | Description |
|---|---|---|
| Lofn.API | Backend | REST API + GraphQL endpoints |
| Lofn.Domain | Backend | Business logic and domain services |
| Lofn.Infra | Backend | EF Core repositories and database context |
| Lofn | NuGet Package | Client SDK (this package) |
📦 Installation
NuGet Package
dotnet add package Lofn
Build from Source
dotnet build Lofn.csproj
⚙️ Configuration
Add the Lofn settings to your appsettings.json:
{
"LofnSetting": {
"ApiUrl": "https://your-lofn-api-url",
"BucketName": "your-bucket-name"
},
"Tenant": {
"DefaultTenantId": "your-tenant-id"
}
}
Register in your DI container:
services.Configure<LofnSetting>(configuration.GetSection("LofnSetting"));
// Register clients
services.AddScoped<IProductClient, ProductClient>();
services.AddScoped<IStoreClient, StoreClient>();
services.AddScoped<ICategoryClient, CategoryClient>();
services.AddScoped<IImageClient, ImageClient>();
services.AddScoped<IStoreUserClient, StoreUserClient>();
// Optional: register TenantHeaderHandler for automatic tenant propagation
services.AddTransient<TenantHeaderHandler>();
📚 Usage
Product Client
// Search products with pagination
var results = await productClient.SearchAsync(new ProductSearchParam
{
Keyword = "premium",
StoreId = 1,
OnlyActive = true,
PageNum = 1
});
// Get product by slug
var product = await productClient.GetBySlugAsync("my-product");
// Create a product
var newProduct = await productClient.InsertAsync("my-store", new ProductInsertInfo
{
Name = "New Product",
Price = 29.90,
Status = ProductStatusEnum.Active,
ProductType = ProductTypeEnum.Physical
});
// List featured products
var featured = await productClient.ListFeaturedAsync("my-store", limit: 5);
Store Client
// List active stores
var stores = await storeClient.ListActiveAsync();
// Get store by slug
var store = await storeClient.GetBySlugAsync("my-store");
// Create a store
var newStore = await storeClient.InsertAsync(new StoreInsertInfo
{
Name = "My Store"
});
Category Client
// List categories for a store
var categories = await categoryClient.ListActiveAsync("my-store");
// Create a category
var category = await categoryClient.InsertAsync("my-store", new CategoryInsertInfo
{
Name = "Electronics"
});
Image Client
// Upload product image
using var stream = File.OpenRead("photo.jpg");
var image = await imageClient.UploadAsync(productId: 1, stream, "photo.jpg", sortOrder: 0);
// List images for a product
var images = await imageClient.ListAsync(productId: 1);
// Delete an image
await imageClient.DeleteAsync(imageId: 5);
📋 Available Clients
| Client | Interface | Operations |
|---|---|---|
ProductClient |
IProductClient |
Search, GetById, GetBySlug, ListActive, ListFeatured, Insert, Update |
StoreClient |
IStoreClient |
List, ListActive, GetBySlug, GetById, Insert, Update, Delete |
CategoryClient |
ICategoryClient |
List, ListActive, GetBySlug, GetById, Insert, Update, Delete |
ImageClient |
IImageClient |
List, Upload (stream), Delete |
StoreUserClient |
IStoreUserClient |
List, Insert, Delete |
📊 DTOs Reference
Enums
| Enum | Values |
|---|---|
ProductStatusEnum |
Active (1), Inactive (2), Expired (3) |
ProductTypeEnum |
Physical (1), InfoProduct (2), Donation (3) |
DonationModeEnum |
Fixed (1), Free (2) |
StoreStatusEnum |
Inactive (0), Active (1), Suspended (2) |
🤝 Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Make your changes
- Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
👨💻 Author
Developed by emagine
📞 Support
- Issues: GitHub Issues
⭐ If you find this project useful, please consider giving it a star!
| 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. |
-
net8.0
- Microsoft.AspNetCore.Authentication (>= 2.3.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.8)
- NAuth (>= 0.5.5)
- Newtonsoft.Json (>= 13.0.3)
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.4.11 | 152 | 5/11/2026 |
| 0.4.10 | 110 | 5/7/2026 |
| 0.4.9 | 105 | 5/4/2026 |
| 0.4.8 | 112 | 5/4/2026 |
| 0.4.7 | 111 | 4/30/2026 |
| 0.4.6 | 111 | 4/30/2026 |
| 0.4.5 | 114 | 4/30/2026 |
| 0.4.4 | 115 | 4/29/2026 |
| 0.4.3 | 125 | 4/28/2026 |
| 0.4.2 | 127 | 3/23/2026 |
| 0.4.1 | 112 | 3/23/2026 |
| 0.4.0 | 115 | 3/23/2026 |
| 0.3.15 | 112 | 3/23/2026 |
| 0.3.14 | 118 | 3/23/2026 |
| 0.3.13 | 116 | 3/23/2026 |
| 0.3.12 | 112 | 3/23/2026 |
| 0.3.11 | 109 | 3/23/2026 |
| 0.3.10 | 119 | 3/23/2026 |
| 0.3.9 | 111 | 3/21/2026 |
| 0.3.8 | 113 | 3/21/2026 |