[Add] MasterData Services.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user