AstreCode.Backend.Shared.Application 9.0.0.2

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

AstreCode.Backend.Shared.Application

Application layer components for AstreCode microservices.

Description

The AstreCode.Backend.Shared.Application package provides essential application layer components for building robust and scalable .NET 8.0 backend services. This package includes application services, business logic, validation attributes, and integration utilities.

Installation

To install this package, use the .NET CLI:

dotnet add package AstreCode.Backend.Shared.Application

Or via Package Manager Console:

Install-Package AstreCode.Backend.Shared.Application

Features

🔧 Application Services

  • Base application service classes with common functionality
  • Service locator pattern for dependency injection
  • Unit of Work pattern implementation
  • Common services access utilities

🛡️ Validation Attributes

  • Email Validator: Comprehensive email validation with regex patterns
  • Password Validator: Strong password validation with configurable rules
  • Phone Number Validator: International phone number validation
  • Saudi Phone Number Validator: Saudi Arabia specific phone validation
  • Custom Validation Attributes: Extensible validation framework

📁 File Management

  • Azure Blob Storage: Public and private blob storage management
  • File Type Checking: Secure file type validation
  • File Upload Utilities: Streamlined file upload handling
  • Blob Configuration: Flexible storage configuration options

🔐 Security & Encryption

  • BCrypt Integration: Secure password hashing
  • Encryption Services: Data encryption and decryption utilities
  • Security Extensions: Authentication and authorization helpers

📨 Message Queuing

  • RabbitMQ Integration: Message queuing and event handling
  • Queue Management: Producer and consumer utilities
  • Event Publishing: Domain event publishing capabilities

Caching

  • Redis Integration: Distributed caching support
  • Cache Management: Flexible caching strategies
  • Cache Expiration: Configurable cache expiration policies

🔄 Background Jobs

  • Hangfire Integration: Background job processing
  • Job Scheduling: Recurring and one-time job scheduling
  • Job Management: Job monitoring and control

🌐 Localization

  • Multi-language Support: JSON-based resource files
  • Culture Management: Dynamic language switching
  • Localized Validation: Culture-specific validation messages

Example Usage

Application Service Setup

using Shared.Application;

public class UserService : ApplicationService
{
    public UserService(IMapper mapper, IStringLocalizer localizer, 
                      IEncryptionService encryptionService, 
                      IUnitOfWork unitOfWork, ICurrentUser currentUser)
    {
    }

    public async Task<UserDto> CreateUserAsync(CreateUserDto dto)
    {
        // Your business logic here
        var user = _mapper.Map<User>(dto);
        await UnitOfWork.GetRepository<User>().AddAsync(user);
        await UnitOfWork.SaveChangesAsync();
        return _mapper.Map<UserDto>(user);
    }
}

Validation Attributes

public class CreateUserDto
{
    [EmailValidator]
    public string Email { get; set; }

    [PasswordValidator]
    public string Password { get; set; }

    [SaudiPhoneNumber]
    public string PhoneNumber { get; set; }
}

File Management

using Shared.Application.FileManagment;

public class FileService
{
    private readonly IBlobPublicFileManagement _blobPublic;
    private readonly IBlobPrivateFileManagement _blobPrivate;

    public async Task<string> UploadFileAsync(Stream fileStream, string fileName)
    {
        return await _blobPublic.UploadFileAsync(fileStream, fileName);
    }
}

Unit of Work Pattern

public class OrderService
{
    private readonly IUnitOfWork _unitOfWork;

    public async Task<OrderDto> CreateOrderAsync(CreateOrderDto dto)
    {
        await _unitOfWork.BeginTransaction();
        try
        {
            var order = new Order();
            await _unitOfWork.GetRepository<Order>().AddAsync(order);
            await _unitOfWork.SaveChangesAsync();
            await _unitOfWork.CommitTransaction();
            return _mapper.Map<OrderDto>(order);
        }
        catch
        {
            await _unitOfWork.RollbackTransaction();
            throw;
        }
    }
}

Configuration

Application Services Registration

// In Program.cs or Startup.cs
builder.Services.ApplicationConfiguration(builder.Configuration);

Hangfire Configuration

// In Program.cs or Startup.cs
builder.Services.HangFireConfigureation(builder.Configuration);

File Management Configuration

// In appsettings.json
{
  "BlobStorage": {
    "ConnectionString": "your-connection-string",
    "PublicContainerName": "public-files",
    "PrivateContainerName": "private-files"
  }
}

Redis Configuration

// In appsettings.json
{
  "Redis": {
    "ConnectionString": "localhost:6379",
    "Database": 0
  }
}

RabbitMQ Configuration

// In appsettings.json
{
  "RabbitMQ": {
    "HostName": "localhost",
    "Port": 5672,
    "UserName": "guest",
    "Password": "guest"
  }
}

Dependencies

This package depends on the following NuGet packages:

  • AutoMapper (13.0.1) - Object-to-object mapping
  • Azure.Storage.Blobs (12.24.0) - Cloud storage
  • BCrypt.Net-Next (4.0.3) - Password hashing
  • Hangfire.AspNetCore (1.8.20) - Background job processing
  • RabbitMQ.Client (6.8.1) - Message queuing
  • StackExchange.Redis (2.8.16) - Caching
  • Microsoft.Extensions.Caching.StackExchangeRedis (8.0.8) - Redis caching

Requirements

  • .NET 8.0 or later
  • ASP.NET Core 8.0 or later

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE.txt file for details.

Support

For support and questions, please contact the AstreCode development team.

Changelog

See CHANGELOG.md for version history and changes.


AstreCode.Backend.Shared.Application - Version 8.0.0

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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 (2)

Showing the top 2 NuGet packages that depend on AstreCode.Backend.Shared.Application:

Package Downloads
AstreCode.Backend.Shared.API

The shared API project for AstreCode backend

AstreCode.Backend.Shared.UnitTest

The shared UnitTest project for AstreCode backend

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.0.0.2 354 9/11/2025
9.0.0.1 407 9/8/2025
9.0.0 153 9/8/2025
8.0.0 161 9/8/2025