private async Task <bool> ValidateReciepient(CustomerLeadEmail CustomerLeadEmail) { if (string.IsNullOrWhiteSpace(CustomerLeadEmail.Reciepient)) { CustomerLeadEmail.AddError(nameof(CustomerLeadEmailValidator), nameof(CustomerLeadEmail.Reciepient), ErrorCode.ReciepientEmpty); } else { if (!IsValidEmail(CustomerLeadEmail.Reciepient)) { CustomerLeadEmail.AddError(nameof(CustomerLeadEmailValidator), nameof(CustomerLeadEmail.Reciepient), ErrorCode.ReciepientEmailInvalid); } if (CustomerLeadEmail.Reciepient.Length > 255) { CustomerLeadEmail.AddError(nameof(CustomerLeadEmailValidator), nameof(CustomerLeadEmail.Reciepient), ErrorCode.ReciepientEmailOverLength); } } return(CustomerLeadEmail.IsValidated); }
public async Task <bool> ValidateId(CustomerLeadEmail CustomerLeadEmail) { CustomerLeadEmailFilter CustomerLeadEmailFilter = new CustomerLeadEmailFilter { Skip = 0, Take = 10, Id = new IdFilter { Equal = CustomerLeadEmail.Id }, Selects = CustomerLeadEmailSelect.Id }; int count = await UOW.CustomerLeadEmailRepository.Count(CustomerLeadEmailFilter); if (count == 0) { CustomerLeadEmail.AddError(nameof(CustomerLeadEmailValidator), nameof(CustomerLeadEmail.Id), ErrorCode.IdNotExisted); } return(count == 1); }