Search code examples
c#asp.net-mvcarchitectureonion-architecture

Where do I keep logic for file upload and calculations in onion architecture?


So.. I was working lately with onion architecture and also been reading quite a lot about it, the only thing that most of blog posts/guide/etc. did not explained is, where do I keep logic like upload of image or some calculations?

Right now I got something like this

-app.core <-- keeps the domain models and interfaces for repository with simple add,update,remove, get, getAll things

-app.infrastructure <-- implements my app.core repository and also has services, contains the IoC modules and mappersettings

-app.application <- it just all about users that makes request to the controllers and the controllers calling the services from app.infrastructure and gets back DTO models

So.. where do I put those two things? Because I feel like all onion does is is add,update,remove,get,getAll

Where do I keep more complex code.. like file uploading? halp


Solution

  • Your domain (or core) doesn't have to be logicless. In fact, I'd say that your business logic SHOULD be in your domain, as your business logic is the core of your application. It's what actually gives your business value. I'd put that logic there. While you're writing that logic, you might notice that you'll need to certain infrastructure calls to save to a file system or send emails. You then just add the interfaces to your core, and assume that it'd be implemented (and injected in) by an outer layer.