Esempio n. 1
0
 private async Task <bool> ValidateName(WorkflowStep WorkflowStep)
 {
     if (string.IsNullOrWhiteSpace(WorkflowStep.Name))
     {
         WorkflowStep.AddError(nameof(WorkflowStepValidator), nameof(WorkflowStep.Name), ErrorCode.NameEmpty);
     }
     else if (WorkflowStep.Name.Length > 255)
     {
         WorkflowStep.AddError(nameof(WorkflowStepValidator), nameof(WorkflowStep.Name), ErrorCode.NameOverLength);
     }
     return(WorkflowStep.IsValidated);
 }
Esempio n. 2
0
 private async Task <bool> ValidateSubjectMail(WorkflowStep WorkflowStep)
 {
     if (!string.IsNullOrWhiteSpace(WorkflowStep.SubjectMailForReject) && WorkflowStep.SubjectMailForReject.Length > 255)
     {
         WorkflowStep.AddError(nameof(WorkflowStepValidator), nameof(WorkflowStep.SubjectMailForReject), ErrorCode.SubjectMailForRejectOverLength);
     }
     return(WorkflowStep.IsValidated);
 }
Esempio n. 3
0
        private async Task <bool> ValidateCode(WorkflowStep WorkflowStep)
        {
            if (string.IsNullOrWhiteSpace(WorkflowStep.Code))
            {
                WorkflowStep.AddError(nameof(WorkflowStepValidator), nameof(WorkflowStep.Code), ErrorCode.CodeEmpty);
            }
            else
            {
                var Code = WorkflowStep.Code;
                if (WorkflowStep.Code.Contains(" ") || !FilterExtension.ChangeToEnglishChar(Code).Equals(WorkflowStep.Code))
                {
                    WorkflowStep.AddError(nameof(WorkflowStepValidator), nameof(WorkflowStep.Code), ErrorCode.CodeHasSpecialCharacter);
                }

                WorkflowStepFilter WorkflowStepFilter = new WorkflowStepFilter
                {
                    Skip = 0,
                    Take = 10,
                    Id   = new IdFilter {
                        NotEqual = WorkflowStep.Id
                    },
                    Code = new StringFilter {
                        Equal = WorkflowStep.Code
                    },
                    Selects = WorkflowStepSelect.Code
                };

                int count = await UOW.WorkflowStepRepository.Count(WorkflowStepFilter);

                if (count != 0)
                {
                    WorkflowStep.AddError(nameof(WorkflowStepValidator), nameof(WorkflowStep.Code), ErrorCode.CodeExisted);
                }
            }

            return(WorkflowStep.IsValidated);
        }
Esempio n. 4
0
        private async Task <bool> ValidateWorkflowStepInUsed(WorkflowStep WorkflowStep)
        {
            RequestWorkflowStepMappingFilter RequestWorkflowStepMappingFilter = new RequestWorkflowStepMappingFilter
            {
                WorkflowStepId = new IdFilter {
                    Equal = WorkflowStep.Id
                }
            };

            var count = await UOW.RequestWorkflowStepMappingRepository.Count(RequestWorkflowStepMappingFilter);

            if (count != 0)
            {
                WorkflowStep.AddError(nameof(WorkflowStepValidator), nameof(WorkflowStep.Id), ErrorCode.WorkflowStepInUsed);
            }
            return(WorkflowStep.IsValidated);
        }
Esempio n. 5
0
        private async Task <bool> ValidateRole(WorkflowStep WorkflowStep)
        {
            RoleFilter RoleFilter = new RoleFilter
            {
                Id = new IdFilter {
                    Equal = WorkflowStep.RoleId
                }
            };

            var count = await UOW.RoleRepository.Count(RoleFilter);

            if (count == 0)
            {
                WorkflowStep.AddError(nameof(WorkflowStepValidator), nameof(WorkflowStep.Role), ErrorCode.RoleNotExisted);
            }
            return(WorkflowStep.IsValidated);
        }
Esempio n. 6
0
        public async Task <bool> ValidateId(WorkflowStep WorkflowStep)
        {
            WorkflowStepFilter WorkflowStepFilter = new WorkflowStepFilter
            {
                Skip = 0,
                Take = 10,
                Id   = new IdFilter {
                    Equal = WorkflowStep.Id
                },
                Selects = WorkflowStepSelect.Id
            };

            int count = await UOW.WorkflowStepRepository.Count(WorkflowStepFilter);

            if (count == 0)
            {
                WorkflowStep.AddError(nameof(WorkflowStepValidator), nameof(WorkflowStep.Id), ErrorCode.IdNotExisted);
            }
            return(count == 1);
        }