using Exam.Infrastructure.Extensions;
using Hotline.Share.Requests.Exam;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Hotline.Application.Exam.Core.Utilities;
using Hotline.Exams.ExamManages;

namespace Hotline.Application.Exam.QueryExtensions.ExamManages
{
    public static class ExamQuestionQueryExtensions
    {

        public static Expression<Func<ExamManage,bool>> GetExpression(this ExamQuestionGroupRequest examQuestionGroupRequest)
        {
            Expression<Func<ExamManage, bool>> expression = m => m.Id != null;

            expression = ExpressionableUtility.CreateExpression<ExamManage>()
                .AndIF(examQuestionGroupRequest.ExamId.IsNotNullOrEmpty(), x => x.Id == examQuestionGroupRequest.ExamId).ToExpression();

            return expression;
        }

        public static Expression<Func<ExamQuestionBak, bool>> GetExpression(this ExamQuestionRequest examQuestionRequest)
        {
            Expression<Func<ExamQuestionBak, bool>> expression = m => m.Id != null;

            expression = ExpressionableUtility.CreateExpression<ExamQuestionBak>()
                .AndIF(examQuestionRequest.QuestionId.IsNotNullOrEmpty(), x => x.QuestionId == examQuestionRequest.QuestionId)
                .ToExpression();

            return expression;
        }

        public static Expression<Func<ExamUserExam, bool>> GetUserExamExpression(this ExamQuestionRequest examQuestionRequest)
        {
            Expression<Func<ExamUserExam, bool>> expression = m => m.Id != null;

            expression = ExpressionableUtility.CreateExpression<ExamUserExam>()
                .AndIF(examQuestionRequest.UserExamId.IsNotNullOrEmpty(), x => x.Id == examQuestionRequest.UserExamId
                )
                .ToExpression();

            return expression;
        }
    }
}
