Skip to content

Commit 4da23e3

Browse files
committed
upgrade to ASP.NET 9.0
1 parent 0d104dc commit 4da23e3

File tree

2,657 files changed

+860701
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,657 files changed

+860701
-0
lines changed

Core/Application/Application.csproj

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<ProjectReference Include="..\Domain\Domain.csproj" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="AutoMapper" Version="13.0.1" />
15+
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.11.0" />
16+
<PackageReference Include="MediatR" Version="12.4.1" />
17+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
18+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />
19+
</ItemGroup>
20+
21+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using MediatR;
2+
using Microsoft.Extensions.Logging;
3+
4+
namespace Application.Common.Behaviors;
5+
6+
public class LoggingBehaviour<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse> where TRequest : notnull
7+
{
8+
private readonly ILogger<TRequest> _logger;
9+
10+
public LoggingBehaviour(ILogger<TRequest> logger)
11+
{
12+
_logger = logger;
13+
}
14+
15+
public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next, CancellationToken cancellationToken)
16+
{
17+
var requestName = typeof(TRequest).Name;
18+
19+
try
20+
{
21+
_logger.LogInformation($"Try executing {requestName} at {DateTime.UtcNow.ToString()}");
22+
23+
return await next();
24+
}
25+
catch (Exception ex)
26+
{
27+
28+
_logger.LogError(ex, $"Error executing {requestName} at {DateTime.UtcNow.ToString()}");
29+
30+
throw;
31+
}
32+
}
33+
}
34+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using FluentValidation;
2+
using MediatR;
3+
4+
namespace Application.Common.Behaviors;
5+
6+
public class ValidationBehaviour<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
7+
where TRequest : notnull
8+
{
9+
private readonly IEnumerable<IValidator<TRequest>> _validators;
10+
11+
public ValidationBehaviour(IEnumerable<IValidator<TRequest>> validators)
12+
{
13+
_validators = validators;
14+
}
15+
16+
public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next, CancellationToken cancellationToken)
17+
{
18+
if (_validators.Any())
19+
{
20+
var context = new ValidationContext<TRequest>(request);
21+
22+
var validationResults = await Task.WhenAll(
23+
_validators.Select(v =>
24+
v.ValidateAsync(context, cancellationToken)));
25+
26+
var failures = validationResults
27+
.Where(r => r.Errors.Any())
28+
.SelectMany(r => r.Errors)
29+
.ToList();
30+
31+
if (failures.Any())
32+
throw new ValidationException(failures);
33+
}
34+
return await next();
35+
}
36+
}
37+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
namespace Application.Common.CQS.Commands;
2+
3+
public interface ICommandContext
4+
{
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using Application.Common.Repositories;
2+
3+
namespace Application.Common.CQS.Queries;
4+
5+
public interface IQueryContext : IEntityDbSet
6+
{
7+
IQueryable<T> Set<T>() where T : class;
8+
}
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System.ComponentModel;
2+
using System.Reflection;
3+
4+
namespace Application.Common.Extensions;
5+
6+
public static class EnumExtensions
7+
{
8+
public static string ToFriendlyName<TEnum>(this TEnum value) where TEnum : Enum
9+
{
10+
var memberInfo = typeof(TEnum).GetMember(value.ToString());
11+
var descriptionAttribute = memberInfo[0]
12+
.GetCustomAttribute<DescriptionAttribute>();
13+
14+
return descriptionAttribute?.Description ?? value.ToString();
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Domain.Common;
2+
3+
namespace Application.Common.Extensions;
4+
5+
6+
public static class QueryableExtensions
7+
{
8+
public static IQueryable<T> ApplyIsDeletedFilter<T>(this IQueryable<T> query, bool isDeleted = false) where T : class
9+
{
10+
if (typeof(IHasIsDeleted).IsAssignableFrom(typeof(T)))
11+
{
12+
query = query.Where(x => (x as IHasIsDeleted)!.IsDeleted == isDeleted);
13+
}
14+
15+
return query;
16+
}
17+
18+
}
19+
20+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Domain.Common;
2+
3+
namespace Application.Common.Repositories;
4+
5+
6+
public interface ICommandRepository<T> where T : BaseEntity
7+
{
8+
Task CreateAsync(T entity, CancellationToken cancellationToken = default);
9+
10+
void Create(T entity);
11+
12+
void Update(T entity);
13+
14+
void Delete(T entity);
15+
16+
void Purge(T entity);
17+
18+
Task<T?> GetAsync(string id, CancellationToken cancellationToken = default);
19+
20+
T? Get(string id);
21+
22+
IQueryable<T> GetQuery();
23+
}
24+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using Domain.Entities;
2+
using Microsoft.EntityFrameworkCore;
3+
4+
namespace Application.Common.Repositories;
5+
6+
7+
public interface IEntityDbSet
8+
{
9+
public DbSet<Token> Token { get; set; }
10+
public DbSet<Todo> Todo { get; set; }
11+
public DbSet<TodoItem> TodoItem { get; set; }
12+
public DbSet<Company> Company { get; set; }
13+
public DbSet<FileImage> FileImage { get; set; }
14+
public DbSet<FileDocument> FileDocument { get; set; }
15+
16+
public DbSet<NumberSequence> NumberSequence { get; set; }
17+
public DbSet<CustomerGroup> CustomerGroup { get; set; }
18+
public DbSet<CustomerCategory> CustomerCategory { get; set; }
19+
public DbSet<VendorGroup> VendorGroup { get; set; }
20+
public DbSet<VendorCategory> VendorCategory { get; set; }
21+
public DbSet<Warehouse> Warehouse { get; set; }
22+
public DbSet<Customer> Customer { get; set; }
23+
public DbSet<Vendor> Vendor { get; set; }
24+
public DbSet<UnitMeasure> UnitMeasure { get; set; }
25+
public DbSet<ProductGroup> ProductGroup { get; set; }
26+
public DbSet<Product> Product { get; set; }
27+
public DbSet<CustomerContact> CustomerContact { get; set; }
28+
public DbSet<VendorContact> VendorContact { get; set; }
29+
public DbSet<Tax> Tax { get; set; }
30+
public DbSet<SalesOrder> SalesOrder { get; set; }
31+
public DbSet<SalesOrderItem> SalesOrderItem { get; set; }
32+
public DbSet<PurchaseOrder> PurchaseOrder { get; set; }
33+
public DbSet<PurchaseOrderItem> PurchaseOrderItem { get; set; }
34+
public DbSet<InventoryTransaction> InventoryTransaction { get; set; }
35+
public DbSet<DeliveryOrder> DeliveryOrder { get; set; }
36+
public DbSet<GoodsReceive> GoodsReceive { get; set; }
37+
public DbSet<SalesReturn> SalesReturn { get; set; }
38+
public DbSet<PurchaseReturn> PurchaseReturn { get; set; }
39+
public DbSet<TransferIn> TransferIn { get; set; }
40+
public DbSet<TransferOut> TransferOut { get; set; }
41+
public DbSet<StockCount> StockCount { get; set; }
42+
public DbSet<NegativeAdjustment> NegativeAdjustment { get; set; }
43+
public DbSet<PositiveAdjustment> PositiveAdjustment { get; set; }
44+
public DbSet<Scrapping> Scrapping { get; set; }
45+
}
46+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Application.Common.Repositories;
2+
3+
public interface IUnitOfWork
4+
{
5+
Task SaveAsync(CancellationToken cancellationToken = default);
6+
void Save();
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Application.Common.Services.EmailManager;
2+
3+
public interface IEmailService
4+
{
5+
Task SendEmailAsync(string email, string subject, string htmlMessage);
6+
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace Application.Common.Services.FileDocumentManager;
2+
public interface IFileDocumentService
3+
{
4+
Task<string> UploadAsync(
5+
string? originalFileName,
6+
string? docExtension,
7+
byte[]? fileData,
8+
long? size,
9+
string? description = "",
10+
string? createdById = "",
11+
CancellationToken cancellationToken = default);
12+
13+
Task<byte[]> GetFileAsync(string fileName, CancellationToken cancellationToken = default);
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace Application.Common.Services.FileImageManager;
2+
public interface IFileImageService
3+
{
4+
Task<string> UploadAsync(
5+
string? originalFileName,
6+
string? docExtension,
7+
byte[]? fileData,
8+
long? size,
9+
string? description = "",
10+
string? createdById = "",
11+
CancellationToken cancellationToken = default);
12+
Task<byte[]> GetFileAsync(string fileName, CancellationToken cancellationToken = default);
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace Application.Common.Services.SecurityManager;
2+
3+
public record CreateUserResultDto
4+
{
5+
public string? UserId { get; init; }
6+
public string? Email { get; init; }
7+
public string? FirstName { get; init; }
8+
public string? LastName { get; init; }
9+
public bool? EmailConfirmed { get; init; }
10+
public bool? IsBlocked { get; init; }
11+
public bool? IsDeleted { get; init; }
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace Application.Common.Services.SecurityManager;
2+
3+
public record DeleteUserResultDto
4+
{
5+
public string? UserId { get; init; }
6+
public string? Email { get; init; }
7+
public string? FirstName { get; init; }
8+
public string? LastName { get; init; }
9+
public bool? EmailConfirmed { get; init; }
10+
public bool? IsBlocked { get; init; }
11+
public bool? IsDeleted { get; init; }
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Application.Common.Services.SecurityManager;
2+
3+
public record GetMyProfileListResultDto
4+
{
5+
public string? Id { get; init; }
6+
public string? FirstName { get; init; }
7+
public string? LastName { get; init; }
8+
public string? CompanyName { get; init; }
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace Application.Common.Services.SecurityManager;
2+
public record GetRoleListResultDto
3+
{
4+
public string? Id { get; init; }
5+
public string? Name { get; init; }
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace Application.Common.Services.SecurityManager;
2+
public record GetUserListResultDto
3+
{
4+
public string? Id { get; init; }
5+
public string? FirstName { get; init; }
6+
public string? LastName { get; init; }
7+
public string? Email { get; init; }
8+
public bool? EmailConfirmed { get; init; }
9+
public bool? IsBlocked { get; init; }
10+
public bool? IsDeleted { get; init; }
11+
public DateTime? CreatedAt { get; init; }
12+
}
13+

0 commit comments

Comments
 (0)