I have an existing web application in which asp.net client uses the business via using the dll of the business project. Code for the business project is given below.
Now, we need to make it as WCF web service. I need to create a service interface (contract) from the existing class BankAccountService. But the class has an overloaded constructor. This constructor cannot be defined in the service interface (as web service is not object oriented). What is the best solution I can use here to make it working as a web service?
Do we need to create any facade rather than making BankAccountService as the service implementation?
Note: I understand that it is not a good practice to extract interface after implementing the service. But for this special scenario we need to do this.
Note: This is a very simple application and this is the only functionality needed in the application. The website will be the only client using the service.
Reference:
1 Interface defining a constructor signature?
CODE
namespace ApplicationServiceForBank
{
public class BankAccountService
{
RepositoryLayer.IRepository<RepositoryLayer.BankAccount> accountRepository;
ApplicationServiceForBank.IBankAccountFactory bankFactory;
public BankAccountService(RepositoryLayer.IRepository<RepositoryLayer.BankAccount> repo, IBankAccountFactory bankFact)
{
accountRepository = repo;
bankFactory = bankFact;
}
public void FreezeAllAccountsForUser(int userId)
{
IEnumerable<RepositoryLayer.BankAccount> accountsForUser = accountRepository.FindAll(p => p.BankUser.UserID == userId);
foreach (RepositoryLayer.BankAccount repositroyAccount in accountsForUser)
{
DomainObjectsForBank.IBankAccount acc = null;
acc = bankFactory.CreateAccount(repositroyAccount);
if (acc != null)
{
acc.BankAccountID = repositroyAccount.BankAccountID;
acc.accountRepository = this.accountRepository;
acc.FreezeAccount();
}
}
}
}