Example #1
0
        private Workflow FindOrCreate(int id, string type, string state, string assignee)
        {
            var workflow = _context.Workflows.Include(v => v.WorkflowVariables)
                           .SingleOrDefault(w => w.CorrelationId == id && w.Type == type);

            if (workflow == null)
            {
                workflow = Workflow.Create(id, type, state, assignee);
                _context.Workflows.Add(workflow);
            }

            return(workflow);
        }
Example #2
0
        private async Task <Workflow> FindOrCreate(
            int id,
            string type,
            string state,
            string assignee = null
            )
        {
            var list = await this.repository.ListAsync(new GetWorkflowInstanceVariables(type, id));

            var workflow = list.FirstOrDefault();

            if (workflow == null)
            {
                workflow = Workflow.Create(id, type, state, assignee);
                await this.repository.AddAsync(workflow);
            }

            return(workflow);
        }