What about if we need to obtain all registers from a entity (GetAllEntityXBySomeProperty) to load a DropDownList ? We need to create a UseCase for it, right? Or we just call to the EntityXRepository (GetAllEntityXBySomeProperty method) from the UI ...
Let me shared a personal code:
public class GetAllPropertyTypesByPropertyAgencyUseCase :
IGetAllPropertyTypesByPropertyAgencyUseCase
{
private readonly IPropertyTypeRepository _propertyTypeRepository;
public GetAllPropertyTypesByPropertyAgencyUseCase(IPropertyTypeRepository
propertyTypeRepository)
{
_propertyTypeRepository = propertyTypeRepository;
}
public void Execute(GetAllPropertyTypesByPropertyAgencyUseCaseRequest useCaseRequest,
IOutputPort<GetAllPropertyTypesByPropertyAgencyUseCaseResponse> outputPort)
{
IEnumerable<PropertyType> propertyTypes =
_propertyTypeRepository.GetAllByPropertyAgency(useCaseRequest.PropertyAgency);
if (propertyTypes == default(IEnumerable<PropertyType>))
{
outputPort.HandleError(new List<UseCaseError> { new UseCaseError(1, $"
{nameof(_propertyTypeRepository.GetAllByPropertyAgency)} Not Found") });
}
var getAllByPropertyAgencyPropertyTypeUseCaseResponse = new
GetAllPropertyTypesByPropertyAgencyUseCaseResponse(propertyTypes);
outputPort.HandleSuccess(getAllByPropertyAgencyPropertyTypeUseCaseResponse);
}
}
Yes, for each interaction you need to create an use case. I implemented an use case similar to yours on Manga Project github.com/ivanpaulovich/clean-arc.... Checkout the branch "React" for the most up to date code.
BTW your use case implementation is missing a return after outputPort.HandleError. Let me know if you have more questions :)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi Ivan, Thanks for share.
What about if we need to obtain all registers from a entity (GetAllEntityXBySomeProperty) to load a DropDownList ? We need to create a UseCase for it, right? Or we just call to the EntityXRepository (GetAllEntityXBySomeProperty method) from the UI ...
Let me shared a personal code:
Hey Darian,
Yes, for each interaction you need to create an use case. I implemented an use case similar to yours on Manga Project github.com/ivanpaulovich/clean-arc.... Checkout the branch "React" for the most up to date code.
BTW your use case implementation is missing a return after
outputPort.HandleError
. Let me know if you have more questions :)