Skip to content

Commit

Permalink
Admin panel - Minor fix KnowledgebaseCategoryModelValidator
Browse files Browse the repository at this point in the history
  • Loading branch information
KrzysztofPajak committed Sep 27, 2021
1 parent 17f6815 commit d1944a3
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,19 @@ public class KnowledgebaseCategoryModelValidator : BaseGrandValidator<Knowledgeb
RuleFor(x => x.Name).NotEmpty().WithMessage(translationService.GetResource("Admin.Content.Knowledgebase.KnowledgebaseCategory.Fields.Name.Required"));
RuleFor(x => x.ParentCategoryId).MustAsync(async (x, y, context) =>
{
var category = await knowledgebaseService.GetKnowledgebaseCategory(x.ParentCategoryId);
if (category != null || string.IsNullOrEmpty(x.ParentCategoryId))
if (!string.IsNullOrEmpty(x.ParentCategoryId))
{
return true;
}
else
{
var categories = await knowledgebaseService.GetKnowledgebaseCategories();
if (!categories.Any())
if (x.Id == x.ParentCategoryId)
return false;
var category = await knowledgebaseService.GetKnowledgebaseCategory(x.ParentCategoryId);
if (category == null)
{
return true;
return false;
}
}
return false;
return true;
}).WithMessage(translationService.GetResource("Admin.Content.Knowledgebase.KnowledgebaseCategory.Fields.ParentCategoryId.MustExist"));
}
}
Expand Down

0 comments on commit d1944a3

Please sign in to comment.