예제 #1
0
        private async Task <bool> ValidateCode(Ward Ward)
        {
            if (string.IsNullOrEmpty(Ward.Code))
            {
                Ward.AddError(nameof(WardValidator), nameof(Ward.Code), ErrorCode.CodeEmpty);
                return(false);
            }
            WardFilter WardFilter = new WardFilter
            {
                Skip = 0,
                Take = 10,
                Id   = new IdFilter {
                    NotEqual = Ward.Id
                },
                Code = new StringFilter {
                    Equal = Ward.Code
                },
                Selects = WardSelect.Code
            };

            int count = await UOW.WardRepository.Count(WardFilter);

            if (count != 0)
            {
                Ward.AddError(nameof(WardValidator), nameof(Ward.Code), ErrorCode.CodeExisted);
            }
            return(count == 0);
        }
예제 #2
0
 private async Task <bool> ValidateName(Ward Ward)
 {
     if (string.IsNullOrEmpty(Ward.Name))
     {
         Ward.AddError(nameof(WardValidator), nameof(Ward.Name), ErrorCode.NameEmpty);
         return(false);
     }
     else if (Ward.Name.Length > 255)
     {
         Ward.AddError(nameof(WardValidator), nameof(Ward.Name), ErrorCode.NameOverLength);
         return(false);
     }
     return(true);
 }
예제 #3
0
        public async Task <bool> ValidateId(Ward Ward)
        {
            WardFilter WardFilter = new WardFilter
            {
                Skip = 0,
                Take = 10,
                Id   = new IdFilter {
                    Equal = Ward.Id
                },
                Selects = WardSelect.Id
            };

            int count = await UOW.WardRepository.Count(WardFilter);

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