public WorkflowBatch AddWorkflowBatch(WorkflowBatch entity)
        {
            Uow.WorkflowBatchRepository.Add(entity);

            Uow.CommitChanges();

            return entity;
        }
        public WorkflowBatch CloneWorkflowBatch(Int32 id)
        {
            var source = GetWorkflowBatch(new WorkflowBatch(id));

            var batch = new WorkflowBatch();

            using (var transaction = Uow.BeginTransaction())
            {
                try
                {
                    batch.Name = String.Format("Clone of {0}", source.Name);
                    batch.Description = source.Description;

                    AddWorkflowBatch(batch);

                    if (source.Constants != null && source.Constants.Count > 0)
                    {
                        foreach (var item in source.Constants)
                        {
                            batch.Constants.Add(new WorkflowConstant { Name = item.Name, Description = item.Description, Value = item.Value });
                        }

                        Uow.CommitChanges();
                    }

                    if (source.Workflows != null && source.Workflows.Count > 0)
                    {
                        foreach (var item in source.Workflows)
                        {
                            batch.Workflows.Add(new Workflow { Name = item.Name, Description = item.Description, WorkflowBatchID = batch.ID });
                        }

                        Uow.CommitChanges();
                    }

                    transaction.Commit();
                }
                catch
                {
                    transaction.Rollback();
                }
            }

            return batch;
        }
        public WorkflowBatch DeleteWorkflowBatch(Int32 id, WorkflowBatch changes)
        {
            var entity = GetWorkflowBatch(new WorkflowBatch(id));

            if (entity != null)
            {
                Uow.WorkflowBatchRepository.Delete(entity);

                Uow.CommitChanges();
            }

            return entity;
        }
        public WorkflowBatch UpdateWorkflowBatch(Int32 id, WorkflowBatch changes)
        {
            var entity = GetWorkflowBatch(new WorkflowBatch(id));

            if (entity != null)
            {
                entity.Name = changes.Name;
                entity.Description = changes.Description;

                Uow.CommitChanges();
            }

            return entity;
        }
 public WorkflowBatch GetWorkflowBatch(WorkflowBatch viewModel)
 {
     return Uow.WorkflowBatchRepository.Get(new WorkflowBatch(viewModel.ID));
 }