Chapters
00:00 - Lesson Objective
00:33 - Getting Our Organization Middleware & Actions Created
01:50 - Setting the Active Organization
03:23 - Getting the Active Organization
06:51 - Joining It All Together in the Organization Middleware
10:31 - Giving It A Test Run
Join The Discussion! (2 Comments)
Please sign in or sign up for free to join in on the dicussion.
emilien
Hi Tom, could you explain why you are using actions over services ? Would be great to have your advice on this 😊
Please sign in or sign up for free to reply
tomgobich
Hi Emilien! Yeah, happily! Firstly, just want to point out that using either actions or services are perfectly acceptable options for the project we're building here. They're very similar, the primary difference being services are comprised of one class with many methods whereas with actions the service class is typically a folder and the methods are individual classes inside that folder for each action. So, actions just kind of scoot everything up a level.
With actions, since a class is dedicated to a single action, this means it is easier to split out sub actions, keeping things organized and easier to read by giving those sub actions names. I can't recall whether we've done this yet at this point in the series, but we most certainly do down the road!
Those separate classes also aide our ability to inject the HttpContext for specific actions. With services, that becomes a little more complicated and often leads to needing two different service classes (one with & one without the HttpContext injected). Whereas, with actions, we can easily make that determination on a per-action basis, which we do in this module (module 6) of the series.
Those two points are the primary deciding factors that lead me to use actions over services for this project. Actions may use more files, but that also brings with it more flexibility in how we write, organize, and inject things inside the project.
That wasn't a foresight thing either, I actually originally started this project with services (shown below) before switching to actions. Once I got to a certain level, I began feeling like actions would be the cleaner and less confusing way to go as opposed to having service methods daisy chaining other service methods to perform an action.
Hope that answers your question! 😊
Please sign in or sign up for free to reply