123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.Common.TeachingMaterial;
- using EMIS.ViewModel.TeachingMaterial;
- using EMIS.ViewModel;
- using Bowin.Common.Linq.Entity;
- using EMIS.DataLogic.Repositories;
- using EMIS.Entities;
- namespace EMIS.CommonLogic.TeachingMaterial
- {
- public class LibraryServices:BaseServices,ILibraryServices
- {
- #region --定义--
- public LibraryDAL LibraryDAL { get; set; }
- public LibraryRepository LibraryRepository { get; set; }
- public UserRepository UserRepository { get; set; }
- public CampusRepository CampusRepository { get; set; }
- #endregion
- #region 1.0 查询书库信息列表
- /// <summary>
- /// 获取书库信息列表
- /// </summary>
- /// <param name="exp"></param>
- /// <returns></returns>
- public IGridResultSet<LibraryView> GetLibraryViewGrid(ConfiguretView configuretView, int pageIndex, int pageSize)
- {
- var query = LibraryDAL.GetLibraryGridView(x => true);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderByDescending(x => x.LibraryName).ToGridResultSet<LibraryView>(pageIndex, pageSize);
- return query.OrderByDescending(x => x.LibraryName).ToGridResultSet<LibraryView>(pageIndex, pageSize);
- }
- #endregion
- #region 2.0 编辑保存书库信息
- /// <summary>
- /// 编辑书库
- /// </summary>
- /// <param name="publisherView"></param>
- public void EditLibrary(LibraryView libraryView, Guid createUserID)
- {
- try
- {
- if (this.LibraryRepository.GetList(x => x.LibraryCode == libraryView.LibraryCode
- && x.LibraryID != libraryView.LibraryID).Count() > 0)
- {
- throw new Exception("书库编号已经存在,请重新输入!");
- }
- if (libraryView.LibraryID != null && libraryView.LibraryID != Guid.Empty)
- {
- CF_Library library = LibraryRepository.GetSingle(x => x.LibraryID == libraryView.LibraryID);
- library.LibraryName = libraryView.LibraryName;
- library.LibraryCode = libraryView.LibraryCode;
- library.ContectTelNumber = libraryView.ContectTelNumber;
- library.HeadPeople = libraryView.HeadPeople;
- library.CampusID = libraryView.CampusID.GetValueOrDefault();
- library.ModifyUserID = createUserID;
- library.ModifyTime = DateTime.Now;
- LibraryRepository.UnitOfWork.Update(library);
- LibraryRepository.UnitOfWork.Commit();
- }
- else
- {
- CF_Library publish = new CF_Library()
- {
- LibraryID = Guid.NewGuid(),
- CampusID = libraryView.CampusID.GetValueOrDefault(),
- ContectTelNumber = libraryView.ContectTelNumber,
- HeadPeople = libraryView.HeadPeople,
- LibraryCode = libraryView.LibraryCode,
- LibraryName = libraryView.LibraryName,
- Desc = libraryView.Desc,
- CreateTime = DateTime.Now,
- ModifyTime = DateTime.Now,
- CreateUserID = createUserID,
- ModifyUserID = createUserID
- };
- LibraryRepository.UnitOfWork.Add(publish);
- LibraryRepository.UnitOfWork.Commit();
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- #region 3.0 删除书库信息
- /// <summary>
- /// 删除书库信息
- /// </summary>
- /// <param name="publishID"></param>
- public void DeleteLibrary(List<Guid> libraryIDs)
- {
- try
- {
- LibraryRepository.UnitOfWork.Delete<CF_Library>(x => libraryIDs.Contains(x.LibraryID));
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- #region 4.0 获取书库单位
- /// <summary>
- /// 获取书库单位
- /// </summary>
- /// <returns></returns>
- public LibraryView GetSingleLibrary(Guid libraryID)
- {
- return LibraryDAL.GetSingleLibrary(libraryID);
- }
- #endregion
- #region 5.0 获取书库信息列表导出
- /// <summary>
- /// 获取书库息列表导出
- /// </summary>
- /// <param name="exp"></param>
- /// <returns></returns>
- public IList<LibraryView> GetLibraryViewExcel(ConfiguretView configuretView)
- {
- var query = LibraryDAL.GetLibraryGridView(x => true);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderByDescending(x => x.LibraryName).ToList();
- return query.OrderByDescending(x => x.LibraryName).ToList();
- }
- #endregion
- #region 6.0 验证书库编号唯一
- public bool IsExistLibraryCode(string libraryCode)
- {
- bool IsExist = false;
- var libraryEnt = LibraryRepository.GetSingle(x => x.LibraryCode == libraryCode);
- if (libraryEnt != null)
- {
- IsExist = true;
- }
- return IsExist;
- }
- #endregion
- }
- }
|