using Hotline.Application.Exam.Extensions;
using Hotline.Share.Requests.Exam;
using JiebaNet.Segmenter.Common;
using System.Linq.Expressions;
using Hotline.Application.Exam.Core.Utilities;
using Hotline.Exams.Questions;

namespace Hotline.Application.Exam.QueryExtensions.ExamManages
{
    public static class TagQuestionQueryExtensions
    {
        public static Expression<Func<ExamQuestionTag, bool>> GetExpression(this TagQuestionRequest tagQuestionRequest)
        {
            Expression<Func<ExamQuestionTag, bool>> expression = m => m.Id != null;

            expression = ExpressionableUtility.CreateExpression<ExamQuestionTag>()
                .AndIF(tagQuestionRequest.TagIds.IsNotNullOrEmpty(), x => tagQuestionRequest.TagIds.Contains(x.TagId)).ToExpression();

            return expression;
        }
    }
}
