private async Task <bool> ValidateCode(Province Province) { if (string.IsNullOrEmpty(Province.Code)) { Province.AddError(nameof(ProvinceValidator), nameof(Province.Code), ErrorCode.CodeEmpty); return(false); } ProvinceFilter ProvinceFilter = new ProvinceFilter { Skip = 0, Take = 10, Id = new IdFilter { NotEqual = Province.Id }, Code = new StringFilter { Equal = Province.Code }, Selects = ProvinceSelect.Code }; int count = await UOW.ProvinceRepository.Count(ProvinceFilter); if (count != 0) { Province.AddError(nameof(ProvinceValidator), nameof(Province.Code), ErrorCode.CodeExisted); } return(count == 0); }
private async Task <bool> ValidateName(Province Province) { if (string.IsNullOrEmpty(Province.Name)) { Province.AddError(nameof(ProvinceValidator), nameof(Province.Name), ErrorCode.NameEmpty); return(false); } else if (Province.Name.Length > 255) { Province.AddError(nameof(ProvinceValidator), nameof(Province.Name), ErrorCode.NameOverLength); return(false); } return(true); }
public async Task <bool> ValidateId(Province Province) { ProvinceFilter ProvinceFilter = new ProvinceFilter { Skip = 0, Take = 10, Id = new IdFilter { Equal = Province.Id }, Selects = ProvinceSelect.Id }; int count = await UOW.ProvinceRepository.Count(ProvinceFilter); if (count == 0) { Province.AddError(nameof(ProvinceValidator), nameof(Province.Id), ErrorCode.IdNotExisted); } return(count == 1); }