I have an asp.net-MVC website with a SQL server backend. There are a 100 different tables and this site works for an organization of 300 people.
We now want to use it for another organization and there then a technical issue with how to expand the site. Here are some of the requirements:
Background:
There are many tables that would be completely reused across both organizations but also many tables where i would have to add a filter to make sure i only get the records back that are relevant to that particular org.
Given that, I have the Single or Multiple Database decision to make like this question or as discussed on Joel's podcast (I am trying to keep it to a single database if possible as there are users that want to look across both organizations) so I sort of have to go with shared in the multi tenant database decision
As discussed in the podcast, as an example there is a People table. That is simple as it just adding a "where Person.Org = "A" into the query if i was just querying the people table. But it also affects any query that has a direct or indirect join with the People table. So lets say I have a Car table and that has a Owner column (which would be a foreign key into People table), If i have a dropdown of Cars I would first have to join with People and then add that filter (before it was just Select * from Cars). I am using nhibernate but you get the point
Question:
My focus now is that I am trying to determine how to have an additional switch around all of my asp.net-mvc Controller actions to support this new organization. So if i have 40 Controllers and each controller has 10 Actions, i have to update 400 actions and every page (and all of the view and javascript code to points to certain URLs. I have I need to first determine which "mode" i am in to determine if i should query for org 1 or org 2
I don't want to go through every single Controller Action and add a new parameter or a route that is "Org Name" or something like that so I wanted to see if there were any idea. Even if it ran two different web sites I still would have to have this global switch if i want to have this run in a single code base.
Is there suggestions so I can avoid adding additional parameter on every controller action?