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(); }
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(); }
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); }