I am building a completely new system using WCF. I am going to use Contract-First Approach for a service which is to be built based on Service Oriented concepts. I have a service operation that returns a bank account details of a user. The account can be of type “FixedAccount” or “SavingsAccount”. I have designed the service as follows.
[ServiceContract]
interface IMyService
{
[OperationContract]
AccountSummary AccountsForUser(User user);
}
[DataContract]
class AccountSummary
{
[DataMember]
public string AccountNumber {get;set;}
[DataMember]
public string AccountType {get;set;}
}
This much is fine.
Now, I need to develop the business domain for this service. I can think of two options (any new approach is always welcome)
1) Approach 1: Come up with a BankAccount base class. The specialized classes derived from it are “FixedAccount” and “SavingsAccount”. The BankAccount will have an method as Transfer(string toAccount). This becomes our familiar & effective OOAD. This involves mapper for mapping between AccountSummary DTO and FixedAccount/ SavingsAccount domain classes.
2) Approach 2: Without using mapper translation layer.
Questions
1) Suppose I am using approach 1. Is there any article/tutorial that explains how to map AccountSummary DTO to FixedAccount/ SavingsAccount domain classes based on the AccountType value in DTO (conditional mapping) ?
2) How do I achieve the task in approach 2 ?
READING:-