I have developed a system with one company profile. The system is built using WCF services, asp.net.
Now another company wants to use our system as well. And they might need some customization and some of their data elements are different. So I am planning to create a separate database for the new company and branch the business logic layer.
I thought of different options to architect this and ended up with the following. So what is the best way to design a system of this sort.
Approach A:
Expose the methods as two different WCF services one for each company. So there will be one WCF client interface (IClient) but two different Service classes for each company implenting them. ClientAService : IClient, ClientBService : IClient.
Problem:
The problem with this is all my datacontracts and datamembers are exposed to the client in 2 different namespaces. (ClientAService.ObjectABC and ClientBService.ObjectABC).
So all the objects that I use in the website are conflicted. ie(when I have a list of ObjectABC
in a datasource in the webpages, the website don't understand whether its from ClientAService
or ClientBService
.
Approach B: Expose the methods as a single WCF Client, but 2 different business logic layer. But they will use the same datacontracts. So the methods will return the same datatype.
so I will have one service class
ClientService : IClient
{
public <ObjectABC> Method1(String Companycode)
{
if(CompanyCode == "A")
return new AbusinessLogic().Method1();
else if(CompanyCode == "B")
return new BbusinessLogic().Method1();
}
}
Problem: The only problem I can think of right now for every new company, I have add the above else if part for all my methods.
I am also open to know if this can done in any other better way than the stated options.
note: I was told that there might be more companies to be added in future.