Im using MediatR in .Net Core and kind of confused if injecting multiple repositories to handle a business logics is an acceptable/clean way of doing it?
My sample Code:
public class MyRequestHandler: IRequestHandler<...>
{
public IHeaderRepository _headerRepository;
public IChildRepository _childRepository;
///constructor dependency injection happening here
public async Task<...>Handle(.....request,..... cancellationToken)
{
var header = await _headerRepository.GetHeader(..headerId);
if(header != null) await _headerRepository.Insert(...):
await _childRepository.Insert(..., ...headerId)
}
}
Aucun commentaire:
Enregistrer un commentaire