Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

An Urgent Question:How We Write XXXManager In Core Layer? #648


User avatar
0
henryguo created

Dear Hikalkan: I have been blocked by this question for over 5days, I ased so many people, but none can give me an answer,I can hardly breath by this quetion anymore. The question is: In your 1.6.0Version, you started to use xxxManager in core layer, such as EditionManager, it offers CRUD functions, and there is no IRepository anymore. I am so confused right now, If I have a new class named 'BeltDevice', How could I wirte BeltDeviceManager? I read the AbpEditionManager, it was so complex, I have no idea how to start. If you have 5minues please help me, thank you so much.


4 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    Managers does exists from the beginning. They are not new (see UserManager, RoleManager... and so on). There are not replacement of repositories. Do not misunderstand it. They are domain services (what is domain service? <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Domain-Services">http://www.aspnetboilerplate.com/Pages/ ... n-Services</a>).

    So, you can use repositories in your code, no problem here.

    So, why we use domain services (managers). Because, we may need to perform some business logic. For example: we may need to check user name uniqueness while creating a user. If we encapsulate it into a manager, we can use same logic from different part of our application. Or we can have a method to check if a user is granted for a permission (see <a class="postlink" href="https://github.com/aspnetboilerplate/module-zero/blob/master/src/Abp.Zero/Authorization/Users/AbpUserManager.cs#L153">https://github.com/aspnetboilerplate/mo ... er.cs#L153</a>). Then we can create such a method to the manager and use it from different application services.

    You don't have to write a manager (domain service) for every entity. It's completely depend on your needs and architectural decisions.

    A note: you don't have to understand EditionManager, just learn how to use it (<a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Zero/Edition-Management">http://www.aspnetboilerplate.com/Pages/ ... Management</a>). That's encapsulation :)

    I hope I could help you.

  • User Avatar
    0
    henryguo created

    Thank you so much for reply me soonly, I was surprised, Hikalkan. You really pull me out of my confused mud. Now I understood the difference between a manager and a repository . Thanks again.

  • User Avatar
    0
    hikalkan created
    Support Team

    You're welcome :)

  • User Avatar
    0
    sayram created

    <cite>hikalkan: </cite> Hi,

    Managers does exists from the beginning. They are not new (see UserManager, RoleManager... and so on). There are not replacement of repositories. Do not misunderstand it. They are domain services (what is domain service? <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Domain-Services">http://www.aspnetboilerplate.com/Pages/ ... n-Services</a>).

    So, you can use repositories in your code, no problem here.

    So, why we use domain services (managers). Because, we may need to perform some business logic. For example: we may need to check user name uniqueness while creating a user. If we encapsulate it into a manager, we can use same logic from different part of our application. Or we can have a method to check if a user is granted for a permission (see <a class="postlink" href="https://github.com/aspnetboilerplate/module-zero/blob/master/src/Abp.Zero/Authorization/Users/AbpUserManager.cs#L153">https://github.com/aspnetboilerplate/mo ... er.cs#L153</a>). Then we can create such a method to the manager and use it from different application services.

    You don't have to write a manager (domain service) for every entity. It's completely depend on your needs and architectural decisions.

    A note: you don't have to understand EditionManager, just learn how to use it (<a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Zero/Edition-Management">http://www.aspnetboilerplate.com/Pages/ ... Management</a>). That's encapsulation :)

    I hope I could help you.

    Thank you bro. Come to us with those. :)