Exemple #1
0
        public void Update(Core.FlowTemplate template)
        {
            var existing = _unitOfWork.FlowTemplates.Get(template.Id);

            if (existing == null)
            {
                throw new ValidationException(String.Format("FlowTemplate Id: {0} does not exist", template.Id));
            }

            _unitOfWork.FlowTemplates.Update(template.Id, template);
            if (template.Steps != null && template.Steps.Any())
            {
                foreach (var step in template.Steps)
                {
                    var stepInstance = new Core.FlowTemplateStep {
                        FlowTemplateId = template.Id
                    };

                    if (step.IsDirty)
                    {
                        _unitOfWork.FlowTemplateSteps.Update(step.Id, stepInstance);
                    }
                    else
                    {
                        _unitOfWork.FlowTemplateSteps.Add(stepInstance);
                    }
                }
            }

            _unitOfWork.Commit();
        }
Exemple #2
0
        public void Delete(Core.FlowTemplate template)
        {
            var steps = _unitOfWork.FlowTemplateSteps.Get().Where(o => o.FlowTemplateId == template.Id);

            steps.ToList().ForEach(o => _unitOfWork.FlowTemplateSteps.Delete(o.Id));
            _unitOfWork.FlowTemplates.Delete(template.Id);
            _unitOfWork.Commit();
        }
Exemple #3
0
        public int Add(Core.FlowTemplate template)
        {
            if (string.IsNullOrWhiteSpace(template.Name))
            {
                throw new ValidationException("Template Name missing");
            }

            _unitOfWork.FlowTemplates.Add(template);

            if (template.Steps != null && template.Steps.Any())
            {
                foreach (var step in template.Steps)
                {
                    var stepInstance = Mapper.Map <Core.FlowTemplateStep>(step);

                    _unitOfWork.FlowTemplateSteps.Add(stepInstance);
                }
            }

            _unitOfWork.Commit();
            return(template.Id);
        }