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
<PackageReference Include="AstreCode.Backend.Shared.Application" Version="9.0.0.2" />
<PackageVersion Include="AstreCode.Backend.Shared.Application" Version="9.0.0.2" />
<PackageReference Include="AstreCode.Backend.Shared.Application" />
paket add AstreCode.Backend.Shared.Application --version 9.0.0.2
#r "nuget: AstreCode.Backend.Shared.Application, 9.0.0.2"
#:package AstreCode.Backend.Shared.Application@9.0.0.2
#addin nuget:?package=AstreCode.Backend.Shared.Application&version=9.0.0.2
#tool nuget:?package=AstreCode.Backend.Shared.Application&version=9.0.0.2
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 | Versions 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. |
-
net9.0
- Aliyun.OSS.SDK.NetCore (>= 2.14.1)
- AstreCode.Backend.Shared.Domain (>= 9.0.0.3)
- AutoMapper (>= 13.0.1)
- Azure.Storage.Blobs (>= 12.24.0)
- BCrypt.Net-Next (>= 4.0.3)
- File.TypeChecker (>= 4.1.1)
- Hangfire.AspNetCore (>= 1.8.20)
- Hangfire.Core (>= 1.8.20)
- Hangfire.PostgreSql (>= 1.20.12)
- JetBrains.Annotations (>= 2024.2.0)
- Microsoft.AspNetCore.Http (>= 2.2.2)
- Microsoft.AspNetCore.Mvc.Core (>= 2.2.5)
- Microsoft.AspNetCore.StaticFiles (>= 2.2.0)
- Microsoft.AspNetCore.WebUtilities (>= 9.0.8)
- Microsoft.EntityFrameworkCore (>= 9.0.8)
- Microsoft.Extensions.Caching.StackExchangeRedis (>= 9.0.8)
- Microsoft.Extensions.Localization (>= 9.0.8)
- Microsoft.IdentityModel.JsonWebTokens (>= 8.0.1)
- Microsoft.IdentityModel.Tokens (>= 8.0.1)
- OCI.DotNetSDK.Common (>= 119.0.0)
- OCI.DotNetSDK.Objectstorage (>= 119.0.0)
- RabbitMQ.Client (>= 6.8.1)
- Scrutor (>= 4.2.2)
- StackExchange.Redis (>= 2.8.16)
- System.Linq.Dynamic.Core (>= 1.4.6)
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.