using System; using System.Collections.Generic; using System.Linq; using System.Text; using Bowin.Common.Linq.Entity; using EMIS.ViewModel.SupervisionManage; using EMIS.DataLogic.SupervisionManage; using EMIS.Entities; using EMIS.ViewModel; namespace EMIS.CommonLogic.SupervisionManage { public class SupervisionUserServices : BaseServices, ISupervisionUserServices { public SupervisionUserDAL SupervisionUserDAL { get; set; } public IGridResultSet GetSupervisionUserGrid(ConfiguretView conditionView, Guid? collegeID, int? pageIndex, int? pageSize) { var query = SupervisionUserDAL.GetProjectRecordTeacherView(); if (collegeID.HasValue) { query = query.Where(x => x.CollegeID == collegeID); } return query.OrderBy(x => x.LoginID.Length).OrderBy(x => x.LoginID).ToGridResultSet(pageIndex, pageSize); } public ProjectRecordTeacherView GetProjectRecordTeacherView(Guid? supervisionUserID) { return SupervisionUserDAL.GetProjectRecordTeacherView().Where(x => x.SupervisionUserID == supervisionUserID).FirstOrDefault(); } public void Save(ProjectRecordTeacherView projectRecordTeacherView) { var supervisionUser = new SUP_SupervisionUser(); if (projectRecordTeacherView.SupervisionUserID != Guid.Empty) { supervisionUser = this.SupervisionUserDAL.SupervisionUserRepository.GetSingle(x => x.SupervisionUserID == projectRecordTeacherView.SupervisionUserID); this.SetModifyStatus(supervisionUser); } else { supervisionUser.SupervisionUserID = Guid.NewGuid(); supervisionUser.UserID = projectRecordTeacherView.TeacherID; this.SetNewStatus(supervisionUser); this.UnitOfWork.Add(supervisionUser); } UnitOfWork.Commit(); } public void Delete(IList supervisionUserIDList) { UnitOfWork.Delete(x => supervisionUserIDList.Contains(x.SupervisionUserID)); } } }