public IEnumerable <Entities.Workflow> GetWorkflows(int portalId)
        {
            using (var context = DataContext.Instance())
            {
                var rep       = context.GetRepository <Entities.Workflow>();
                var workflows = rep.Find("WHERE (PortalId = @0 OR PortalId IS NULL)", portalId).ToArray();

                // Worfklow States eager loading
                foreach (var workflow in workflows)
                {
                    workflow.States = _stateRepository.GetWorkflowStates(workflow.WorkflowID);
                }

                return(workflows);
            }
        }
 public IEnumerable <WorkflowState> GetWorkflowStates(int workflowId)
 {
     return(_workflowStateRepository.GetWorkflowStates(workflowId));
 }