示例#1
0
 public async Task <bool> ValidateColorCode(TicketType TicketType)
 {
     if (string.IsNullOrWhiteSpace(TicketType.ColorCode))
     {
         TicketType.AddError(nameof(TicketTypeValidator), nameof(TicketType.ColorCode), ErrorCode.ColorCodeEmpty);
     }
     else if (TicketType.ColorCode.Length > 20)
     {
         TicketType.AddError(nameof(TicketTypeValidator), nameof(TicketType.ColorCode), ErrorCode.ColorCodeOverLength);
     }
     return(TicketType.IsValidated);
 }
示例#2
0
 public async Task <bool> ValidateStatus(TicketType TicketType)
 {
     if (StatusEnum.ACTIVE.Id != TicketType.StatusId && StatusEnum.INACTIVE.Id != TicketType.StatusId)
     {
         TicketType.AddError(nameof(TicketTypeValidator), nameof(TicketType.Status), ErrorCode.StatusNotExisted);
     }
     return(TicketType.IsValidated);
 }
示例#3
0
        public async Task <bool> ValidateCode(TicketType TicketType)
        {
            if (string.IsNullOrWhiteSpace(TicketType.Code))
            {
                TicketType.AddError(nameof(TicketTypeValidator), nameof(TicketType.Code), ErrorCode.CodeEmpty);
            }
            else
            {
                var Code = TicketType.Code;
                if (TicketType.Code.Contains(" ") || !FilterExtension.ChangeToEnglishChar(Code).Equals(TicketType.Code))
                {
                    TicketType.AddError(nameof(TicketTypeValidator), nameof(TicketType.Code), ErrorCode.CodeHasSpecialCharacter);
                }

                TicketTypeFilter TicketTypeFilter = new TicketTypeFilter
                {
                    Skip = 0,
                    Take = 10,
                    Id   = new IdFilter {
                        NotEqual = TicketType.Id
                    },
                    Code = new StringFilter {
                        Equal = TicketType.Code
                    },
                    Selects = TicketTypeSelect.Code
                };

                int count = await UOW.TicketTypeRepository.Count(TicketTypeFilter);

                if (count != 0)
                {
                    TicketType.AddError(nameof(TicketTypeValidator), nameof(TicketType.Code), ErrorCode.CodeExisted);
                }
            }
            return(TicketType.IsValidated);
        }
示例#4
0
        public async Task <bool> ValidateId(TicketType TicketType)
        {
            TicketTypeFilter TicketTypeFilter = new TicketTypeFilter
            {
                Skip = 0,
                Take = 10,
                Id   = new IdFilter {
                    Equal = TicketType.Id
                },
                Selects = TicketTypeSelect.Id
            };

            int count = await UOW.TicketTypeRepository.Count(TicketTypeFilter);

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