[Add] MasterData Services.

This commit is contained in:
Thanakarn Klangkasame
2025-11-26 10:29:56 +07:00
parent d4ab1cb592
commit 1e636aa3d5
205 changed files with 7814 additions and 69 deletions

View File

@@ -0,0 +1,30 @@
using AMREZ.EOP.Abstractions.Applications.Tenancy;
using AMREZ.EOP.Abstractions.Applications.UseCases.MasterData.Allergen;
using AMREZ.EOP.Abstractions.Infrastructures.Repositories;
using Microsoft.AspNetCore.Http;
namespace AMREZ.EOP.Application.UseCases.MasterData.Allergen;
public class DeleteAllergenUseCase : IDeleteAllergenUseCase
{
private readonly IAllergenRepository _repo;
private readonly ITenantResolver _tenantResolver;
private readonly IHttpContextAccessor _http;
public DeleteAllergenUseCase(IAllergenRepository repo, ITenantResolver tr, IHttpContextAccessor http)
{
_repo = repo;
_tenantResolver = tr;
_http = http;
}
public async Task<bool> ExecuteAsync(Guid id, CancellationToken ct = default)
{
var http = _http.HttpContext ?? throw new InvalidOperationException("No HttpContext");
var tc = _tenantResolver.Resolve(http) ?? throw new InvalidOperationException("No tenant");
var tid = Guid.Parse(tc.Id);
var n = await _repo.SoftDeleteAsync(id, tid, ct);
return n > 0;
}
}