
using New_College.IServices;
using New_College.Model.Models;
using New_College.Services.BASE;
using New_College.IRepository.Base;
using System.Threading.Tasks;
using System.Collections.Generic;
using New_College.Model.Request;
using System.Linq;

namespace New_College.Services
{
    public class D_FackUniversityServices : BaseServices<D_FackUniversity>, ID_FackUniversityServices
    {
        private readonly IBaseRepository<D_FackUniversity> _dal;
        public D_FackUniversityServices(IBaseRepository<D_FackUniversity> dal)
        {
            this._dal = dal;
            base.BaseDal = dal;
        }

        /// <summary>
        /// 根据关键词获取对应院校数据
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task<List<D_FackUniversity>> Get_FackUniversities(FackRequest request)
        {
            var response = new List<D_FackUniversity>();
            var query = await _dal.Query(e => e.UniversityName.Contains(request.KeyWord));
            if (query.Any() && query.Count() > 0)
            {
                response = query.ToList();
            }
            return response;
        }
    }
}