OO Design for Business Logic

I have one Sell Operation object and two Buy Operation objects, I want to implement such a behavior that one Sell operation performs two Buy operations, it looks like this:

sellOperation.Discharge (oneBuyOperation);
sellOperation.Discharge (twoBuyOperation);


so I want to ask if I should call the repository function in the "discharge" method, or should I call the method of saving the repository outside the "Unload" method. as:

opRepository.Save (sellOpertion);

So, can anyone give me some advice on what you are going to implement in this scenario? using a service class or something better?

+3
source share
2 answers

- - .

, , oneBuyOperation , BuyOperation. , , .

, "", sellOperation "", , .

using(UnitOfWork.Start())
{
    sellOperation.Discharge(oneBuyOperation);
    sellOperation.Discharge(twoBuyOperation);  

    UnitOfWork.CurrentSession.Save(sellOperation);
}

.

+4

Source: https://habr.com/ru/post/1743448/


All Articles