I am developing an app in DDD manner. And I have a little problem with it.
I have a Fare (airline fare) and FareRepository objects. And at some point I should load additional fare information (from a server, call server api) and setup this information to existing Fare.
I guess that I need to create an Application Service (FareAdditionalInformationService) that will deal with obtaining data from the server and than update existing Fare or put the business logic in Fare object. However, some people said me that it is necessary to use FareRepository for this problem.
I don't know wich place is better for my problem Service or Repository.
After researching, I came to the conclusion, that the better place for fetching additional Fare information is a service like (AdditionalFareService).
The code would look something like this:
//create service for fetching fare information AdditionalFareService service = new AdditionalFareService(); //get a fare by Id Fare fare = fareRepository.GetById(myFareId); //Obtain information from service var fareInformation=service.getAdditionalInformation(fare) //Add it to the fare. fare.AddInformation(fareInformation); //save it to the repository. fareRepository.Save(fare);