using System.Collections.Generic; using System.Linq; using Neo.Afx.ComponentModel; namespace Neo.Afx.Admin.Wf { /// /// Afx admin database /// public class AfxAdminWorkflowDatabase : Database { /// /// Constructor /// public AfxAdminWorkflowDatabase() : base(new AfxAdminWorkflowContext()) { } #region GetWorkflows /// /// Get all data from table. /// /// List of objects public IEnumerable GetWorkflows() { return (from item in Context.Workflows select item).ToList(); } /// /// Get data from table based on count. /// /// Restricts amount returned items in the collection. /// List of objects. public IEnumerable GetWorkflows(int count) { return (from item in Context.Workflows select item).Take(count).ToList(); } #endregion #region GetWorkflowCategories /// /// Gets the workflow categories. /// /// List of objects. public IEnumerable GetWorkflowCategories() { return (from item in Context.WorkflowCategories where !item.IsCancelled select item).ToList(); } #endregion #region GetWorkflow /// /// Gets the workflow. /// /// The workflow id. /// public Workflow GetWorkflow(long? workflowId) { if(!workflowId.HasValue) { return null; } return (from item in Context.Workflows .Include("WorkflowTaskHandlers") .Include("WorkflowTemplates") where item.WorkflowID == workflowId.Value select item).FirstOrDefault(); } #endregion #region GetWorkflowTemplate public WorkflowTemplate GetWorkflowTemplate(long? workflowTemplateId) { if(!workflowTemplateId.HasValue) { return null; } return (from item in Context.WorkflowTemplates .Include("WorkflowTemplateDefaults") where item.WorkflowTemplateID == workflowTemplateId.Value select item).SingleOrDefault(); } #endregion #region GetWorkflowTemplateScripts public IEnumerable GetWorkflowTemplateScripts(long? workflowTemplateId) { if(!workflowTemplateId.HasValue) { return null; } return (from item in Context.WorkflowTemplateScripts where item.WorkflowTemplateID == workflowTemplateId.Value select item); } #endregion } }