public int StartWorkFlowExecution(Common.Models.WorkflowExecution execution) { Entities.WorkflowExecution WFE = new Entities.WorkflowExecution { Id = execution.Id, Workflow = execution.Workflow.Id, WorkflowVersion = execution.Workflow.Version, UserStory = execution.UserStory.Id, StartDate = DateTime.Now, Status = execution.Status, Progress = execution.Progress, InitiatedBy = execution.InitiatedBy.Id, //EndDate = DateTime.Now, WorkflowActivityExecution = execution.ActivityExecutions.Select(s => new WorkflowActivityExecution { Id = s.Id, WorkflowExecution = s.WorkflowExecution, Activity = s.Activity.Id, Status = s.Status, StartDate = s.Status == "Started" ? DateTime.Now : default(DateTime), OutCome = s.OutCome, Comments = s.Comments, //CompletedDate = DateTime.Now }).ToList() }; db.WorkflowExecution.Add(WFE); db.SaveChanges(); return(WFE.Id); }
public int CompleteWorkFlowExecution(Common.Models.WorkflowExecution execution) { Entities.WorkflowExecution WFE = db.WorkflowExecution.FirstOrDefault(e => e.Id == execution.Id); WFE.Status = execution.Status; WFE.Progress = execution.Progress; WFE.InitiatedBy = execution.InitiatedBy.Id; WFE.EndDate = DateTime.Now; db.WorkflowExecution.Update(WFE); db.SaveChanges(); return(WFE.Id); }