using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EMIS.DataLogic.Repositories;
using EMIS.Entities;
using EMIS.ViewModel.TeachingMaterial;
using System.Linq.Expressions;
namespace EMIS.DataLogic.Common.TeachingMaterial
{
public class LibraryDAL
{
public LibraryRepository LibraryRepository { get; set; }
public UserRepository UserRepository { get; set; }
public CampusRepository CampusRepository { get; set; }
///
/// 获取出版单位信息列表
///
///
///
public IQueryable GetLibraryGridView(Expression> exp)
{
var view = (from l in LibraryRepository.Entities.Where(exp)
join c in CampusRepository.Entities on l.CampusID equals c.CampusID
join u in UserRepository.Entities on l.CreateUserID equals u.UserID
select new LibraryView
{
LibraryID = l.LibraryID,
LibraryCode = l.LibraryCode,
LibraryName = l.LibraryName,
HeadPeople =l.HeadPeople,
ContectTelNumber = l.ContectTelNumber,
Desc = l.Desc,
CampusCode = c.No,
CampusName = c.Name,
CampusID = l.CampusID,
CreateTime = l.CreateTime,
CreateUserName = u.Name
});
return view;
}
///
/// 获取出版单位单位
///
///
public LibraryView GetSingleLibrary(Guid libraryID)
{
var library = LibraryRepository.GetSingle(x => x.LibraryID == libraryID,
(x => x.CF_Campus));
var publishView = new LibraryView()
{
LibraryID = library.LibraryID,
LibraryName = library.LibraryName,
LibraryCode = library.LibraryCode,
ContectTelNumber = library.ContectTelNumber,
Desc = library.Desc,
HeadPeople = library.HeadPeople,
CampusID = library.CampusID,
CampusCode = library.CF_Campus.No,
CampusName = library.CF_Campus.Name
};
return publishView;
}
}
}