I have class that has many public method which perfrom differnet service operations.
Inorder to do service operation it need to create service Instance.
How do I avoid calling private method from each function?
code snippet.
public class EmployeeModel
{
private IOrganizationService _service = CRMConnect.CrmService();
private void CreateCrmServiceInstance()
{
if (_service == null){
_service = CRMConnect.CrmService();
}
}
public List<EmployeeModel> RetrieveAllContacts()
{
CreateCrmServiceInstance();
// do something using _service
}
public List<ContactModel> UpdateContactStatus()
{
CreateCrmServiceInstance();
// do something using _service
}