Exemplo n.º 1
0
 private async Task <bool> ValidateReciepient(CompanyEmail CompanyEmail)
 {
     if (string.IsNullOrWhiteSpace(CompanyEmail.Reciepient))
     {
         CompanyEmail.AddError(nameof(CompanyEmailValidator), nameof(CompanyEmail.Reciepient), ErrorCode.ReciepientEmpty);
     }
     else
     {
         if (!IsValidEmail(CompanyEmail.Reciepient))
         {
             CompanyEmail.AddError(nameof(CompanyEmailValidator), nameof(CompanyEmail.Reciepient), ErrorCode.ReciepientEmailInvalid);
         }
         if (CompanyEmail.Reciepient.Length > 255)
         {
             CompanyEmail.AddError(nameof(CompanyEmailValidator), nameof(CompanyEmail.Reciepient), ErrorCode.ReciepientEmailOverLength);
         }
     }
     return(CompanyEmail.IsValidated);
 }
Exemplo n.º 2
0
        public async Task <bool> ValidateId(CompanyEmail CompanyEmail)
        {
            CompanyEmailFilter CompanyEmailFilter = new CompanyEmailFilter
            {
                Skip = 0,
                Take = 10,
                Id   = new IdFilter {
                    Equal = CompanyEmail.Id
                },
                Selects = CompanyEmailSelect.Id
            };

            int count = await UOW.CompanyEmailRepository.Count(CompanyEmailFilter);

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