private ServiceResponse GetStepExecutionForView(ProcessExecution processExe, int currentUserID)
        {
            ServiceResponse res = new ServiceResponse();


            var stepExe = processExe.StepExecutions.OrderByDescending(x => x.ProcessStep.SortOrder).First();

            if (stepExe != null)
            {
                if (processExe.CurrentStep != null)
                {
                    processExe.CurrentStep.ProcessExecutions = null;
                }

                var listStepExe = new List <StepExecution>();

                foreach (var item in processExe.StepExecutions)
                {
                    item.ProcessExecution = null;
                    if (item.CurrentAssignee != null)
                    {
                        item.CurrentAssignee.ProcessExecutions = null;
                    }

                    if (item.NextAssigneeId != null && item.NextAssigneeId != -999)
                    {
                        listStepExe.Add(item);
                    }
                }
                var result = new StepExecutionHandel()
                {
                    CurrentStep = stepExe.ProcessStep,
                    ListStep    = listStepExe,
                    IsHandle    = false,
                    Status      = processExe.Status,
                    ProcessName = processExe.ProcessExecutionName
                };

                res.OnSuccess(result);
                return(res);
            }
            else
            {
                res.OnError("Not permittion");
                return(res);
            }
        }
        private ServiceResponse GetStepExecutionForHandle(ProcessExecution processExe, int currentUserID)
        {
            ServiceResponse res = new ServiceResponse();
            // kiem tra xem dung nguoi nay duoc giao hay khong
            var lastProcess = processExe.StepExecutions.OrderByDescending(x => x.ProcessStep.SortOrder).First();

            if (lastProcess.CurrentAssigneeId == currentUserID)
            {
                if (processExe.CurrentStep != null)
                {
                    processExe.CurrentStep.ProcessExecutions = null;
                }

                var listStepExe = new List <StepExecution>();

                foreach (var item in processExe.StepExecutions)
                {
                    item.ProcessExecution = null;
                    if (item.CurrentAssignee != null)
                    {
                        item.CurrentAssignee.ProcessExecutions = null;
                    }

                    if (item.NextAssigneeId != null && item.NextAssigneeId != -999)
                    {
                        listStepExe.Add(item);
                    }
                }
                var result = new StepExecutionHandel()
                {
                    CurrentStep = processExe.CurrentStep,
                    ListStep    = listStepExe,
                    IsHandle    = true,
                    Status      = processExe.Status,
                    ProcessName = processExe.ProcessExecutionName
                };

                res.OnSuccess(result);
                return(res);
            }
            else
            {
                res = GetStepExecutionForView(processExe, currentUserID);
                return(res);
            }
        }