locked
UnitOfWork and Repository Pattern Challenge RRS feed

  • Question

  • User2036045661 posted

    I use UnitOfWork and Repository pattern for my Enterprise application. Due to I'm new to this patter I get confused what should I do to use Bussines Service Calss. In many example, they use UnitOfWork injection directly to MVC controller. But I wana to extract every bussines logics to other class called bussines service. What should I do? plz with example! 

    Monday, December 24, 2012 1:48 PM

Answers

  • User1292461583 posted

    I am not sure if I understand you correctly. We seldom put unitOfWork in controllers.  As you said, the logic inside a method of a business service class should be inside a single transaction. For example.

     using(UnitOfWork uw = new UnitOfWork())

     {

          decimal oldBalance = new AccountRep(uw).Retrieve(id);

          new InterestRep(uw).Increase(Id, oldBalance * 0.04);

          uw.Commit();

     }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 31, 2012 10:51 AM