Base solution for your next web application
Open Closed

Skip .Application layer #1206


User avatar
0
alex created

Hi,

Is is possible to skip the .Application layer en use .Core domain services directly from the controllers? Do I miss anything?

I saw in other posts and in the documentation that we can eliminate the domain services and use .Application services and put logic in there. In some cases it might be a more productive approach. But I wonder what would I miss if I skip the .Application services and DTO's and use Domain directly. Something like ZeroModule. Would I miss transaction, UoW, Logging, Auditing, ....and all that stuff all together or I have them in the .Core Services as well?

Before someone point me to the 'best practices' stories, YES people I know them very well. In my current project I don't need DTO's and have one UI.

By the way, I think you have done a great job with this ABP. Thanks for sharing it.

But


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

    Hi,

    Sure, you can use Core layer from Controllers and it has no problem. All infrastructure will work fine, with a little differences:

    • You should add [UnitOfWork] attribute and make your controller actions virtual in some cases (see <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Unit-Of-Work#DocRepositoryGetAll">http://www.aspnetboilerplate.com/Pages/ ... toryGetAll</a> and <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Unit-Of-Work#DocUowRestrictions">http://www.aspnetboilerplate.com/Pages/ ... strictions</a>).
    • Use [AbpMvcAuthorize] for auth attribute instead of [AbpAuthorize].
    • Use MVC's Validation (Model.IsValid thing) since ABP's currently does not works for Controllers (will be)

    But... DTOs or ViewModels is must as you know. For example, you should not send an Entity back to client in an AJAX request. Because Entities are not well serializable to JSON in most cases (<a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Data-Transfer-Objects#DocDtoSerializationProblems">http://www.aspnetboilerplate.com/Pages/ ... onProblems</a>).