using System.Linq.Expressions;
using Exam.Infrastructure.Extensions;
using Hotline.Application.Exam.Core.Utilities;
using Hotline.Exams.Sourcewares;
using Hotline.Share.Requests.Sourceware;

namespace Hotline.Application.Exam.QueryExtensions.Sourcewares
{
    public static class SourcewareQueryExtesions
    {
        public static Expression<Func<ExamSourceware, bool>> GetExpression(this SourcewarePagedRequest sourcewarePagedRequest)
        {
            Expression<Func<ExamSourceware, bool>> expression = m => m.Id != null;


            expression = ExpressionableUtility.CreateExpression<ExamSourceware>().AndIF(sourcewarePagedRequest.Name.IsNotNullOrEmpty(), m => m.Name.Contains(sourcewarePagedRequest.Name))
           .AndIF(sourcewarePagedRequest.SourcewareType.IsNotNullOrEmpty(), m => m.SourcewareType == sourcewarePagedRequest.SourcewareType)
           .AndIF(sourcewarePagedRequest.SourcewareCategoryId.IsNotNullOrEmpty(), m => m.CategoryId == sourcewarePagedRequest.SourcewareCategoryId)
           .ToExpression();

            return expression;
        }

    }
}



