Lofn 0.4.11

dotnet add package Lofn --version 0.4.11
                    
NuGet\Install-Package Lofn -Version 0.4.11
                    
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="Lofn" Version="0.4.11" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Lofn" Version="0.4.11" />
                    
Directory.Packages.props
<PackageReference Include="Lofn" />
                    
Project file
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 Lofn --version 0.4.11
                    
#r "nuget: Lofn, 0.4.11"
                    
#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 Lofn@0.4.11
                    
#: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=Lofn&version=0.4.11
                    
Install as a Cake Addin
#tool nuget:?package=Lofn&version=0.4.11
                    
Install as a Cake Tool

Lofn - Client SDK for the Lofn Sales Platform API

.NET NuGet License

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-Id header propagation via TenantHeaderHandler
  • 📦 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

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Make your changes
  4. Commit your changes (git commit -m 'Add some AmazingFeature')
  5. Push to the branch (git push origin feature/AmazingFeature)
  6. Open a Pull Request

👨‍💻 Author

Developed by emagine


📞 Support


⭐ If you find this project useful, please consider giving it a star!

Product 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.

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
Loading failed