Exemplo n.º 1
0
 public async Task <bool> ValidateFromDateAndToDate(KnowledgeArticle KnowledgeArticle)
 {
     if (KnowledgeArticle.FromDate == null)
     {
         KnowledgeArticle.AddError(nameof(KnowledgeArticleValidator), nameof(KnowledgeArticle.FromDate), ErrorCode.FromDateEmpty);
     }
     if (KnowledgeArticle.FromDate != null && KnowledgeArticle.ToDate != null && KnowledgeArticle.FromDate >= KnowledgeArticle.ToDate)
     {
         KnowledgeArticle.AddError(nameof(KnowledgeArticleValidator), nameof(KnowledgeArticle.ToDate), ErrorCode.ToDateMoreThanFromDate);
     }
     return(KnowledgeArticle.IsValidated);
 }
Exemplo n.º 2
0
 public async Task <bool> ValidateTitle(KnowledgeArticle KnowledgeArticle)
 {
     if (string.IsNullOrWhiteSpace(KnowledgeArticle.Title))
     {
         KnowledgeArticle.AddError(nameof(KnowledgeArticleValidator), nameof(KnowledgeArticle.Title), ErrorCode.TitleEmpty);
     }
     else if (KnowledgeArticle.Title.Length > 2000)
     {
         KnowledgeArticle.AddError(nameof(KnowledgeArticleValidator), nameof(KnowledgeArticle.Title), ErrorCode.TitleOverLength);
     }
     return(KnowledgeArticle.IsValidated);
 }
Exemplo n.º 3
0
 public async Task <bool> ValidateDetail(KnowledgeArticle KnowledgeArticle)
 {
     if (string.IsNullOrWhiteSpace(KnowledgeArticle.Detail))
     {
         KnowledgeArticle.AddError(nameof(KnowledgeArticleValidator), nameof(KnowledgeArticle.Detail), ErrorCode.DetailEmpty);
     }
     return(KnowledgeArticle.IsValidated);
 }
Exemplo n.º 4
0
        public async Task <bool> ValidateGroup(KnowledgeArticle KnowledgeArticle)
        {
            if (KnowledgeArticle.Group == null)
            {
                KnowledgeArticle.AddError(nameof(KnowledgeArticleValidator), nameof(KnowledgeArticle.Group), ErrorCode.GroupEmpty);
            }

            return(KnowledgeArticle.IsValidated);
        }
Exemplo n.º 5
0
        public async Task <bool> ValidateId(KnowledgeArticle KnowledgeArticle)
        {
            KnowledgeArticleFilter KnowledgeArticleFilter = new KnowledgeArticleFilter
            {
                Skip = 0,
                Take = 10,
                Id   = new IdFilter {
                    Equal = KnowledgeArticle.Id
                },
                Selects = KnowledgeArticleSelect.Id
            };

            int count = await UOW.KnowledgeArticleRepository.Count(KnowledgeArticleFilter);

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