using System; using System.Collections.Generic; using System.Linq; using System.Text; using Bowin.Common.Linq.Entity; using EMIS.Entities; using EMIS.DataLogic.ExamManage; using System.Linq.Expressions; using EMIS.DataLogic; using EMIS.ViewModel.Students; namespace EMIS.CommonLogic.ExamManage { public class ExamPersonControlServices : BaseServices, IExamPersonControlServices { public ExamPersonControlDAL Logic { get; set; } public Bowin.Common.Linq.Entity.IGridResultSet GetListGridView(int pageIndex, int pageSize, params ViewModel.ConfiguretView[] configuretViews) { System.Linq.Expressions.Expression> expCampus = (x => true); var query = Logic.GetList(expCampus); //查询条件 foreach (var configuretView in configuretViews) { if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return query.OrderByDescending(x => x.Schoolyear) .OrderBy(x => x.ExaminationBatchProjectPersonControlID) .ToGridResultSet(pageIndex, pageSize); } public IGridResultSet GetControlExamTypeListViewGrid(int pageIndex, int pageSize, params EMIS.ViewModel.ConfiguretView[] configuretViews) { System.Linq.Expressions.Expression> expCampus = (x => true); var query = Logic.GetList(expCampus); //查询条件 foreach (var configuretView in configuretViews) { if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } var result = query.OrderBy(x => x.ExaminationBatchProjectID).GroupBy(x => new { x.ExaminationBatchID, x.ExaminationTypeID, x.ExaminationType }).Select(x => new EMIS.ViewModel.ExaminationApply.ExaminationTypeView() { ExaminationBatchID = x.Key.ExaminationBatchID.Value, ExaminationTypeID = x.Key.ExaminationTypeID.Value, Name = x.Key.ExaminationType }); return result .OrderBy(x => x.ExaminationBatchID) .ToGridResultSet(pageIndex, pageSize); } public IGridResultSet GetControlProjectListViewGrid(int pageIndex, int pageSize, params EMIS.ViewModel.ConfiguretView[] configuretViews) { System.Linq.Expressions.Expression> expCampus = (x => true); var query = Logic.GetList(expCampus); //查询条件 foreach (var configuretView in configuretViews) { if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } var result = query.OrderBy(x => x.ExaminationBatchProjectID).GroupBy(x => new { x.ExaminationBatchID, x.ExaminationTypeID, x.ExaminationBatchProjectID, x.ProjectName }).Select(x => new EMIS.ViewModel.ExamBatchProjectView() { ExaminationBatchID = x.Key.ExaminationBatchID.Value, ExaminationTypeID = x.Key.ExaminationTypeID.Value, Name = x.Key.ProjectName, ExaminationBatchProjectID = x.Key.ExaminationBatchProjectID.Value, }); return result .OrderBy(x => x.ExaminationBatchID) .ToGridResultSet(pageIndex, pageSize); } public ViewModel.ExamPersonControlView GetView(Guid? ViewID) { var query = Logic.GetList(x => x.ExaminationBatchProjectPersonControlID == ViewID).SingleOrDefault(); return query; } public void Edit(ViewModel.ExamPersonControlView view, List studentsViewList) { //UnitOfWork.Delete(q => q.ExaminationBatchProjectID == view.ExaminationBatchProjectID); var examinationBatchProject = Logic.BatchProjectRepository.Entities.Where(x => x.ExaminationBatchID == view.ExaminationBatchID && x.ExaminationProjectID == view.ExaminationProjectID).FirstOrDefault(); var PersonControlList = Logic.PersonControlRepository.Entities.Where(x => x.ExaminationBatchProjectID == examinationBatchProject.ExaminationBatchProjectID).ToList(); foreach (var student in studentsViewList) { var entity = PersonControlList.Where(x => x.UserID == student.UserID).FirstOrDefault(); if (entity == null) { entity = new EX_ExaminationBatchProjectPersonControl(); entity.ExaminationBatchProjectPersonControlID = Guid.NewGuid(); this.SetNewStatus(entity); Logic.PersonControlRepository.UnitOfWork.Add(entity); } entity.ExaminationBatchProjectID = examinationBatchProject.ExaminationBatchProjectID; entity.ExaminationProjectFeeID = view.ExaminationProjectFeeID; entity.UserID = student.UserID; entity.IsOnlinePay = view.IsOnlinePay; entity.EndDate = view.EndDate; entity.StartDate = view.StartDate; this.SetModifyStatus(entity); } Logic.PersonControlRepository.UnitOfWork.Commit(); } public ViewModel.ExamPersonControlView GetView(System.Linq.Expressions.Expression> expCampus) { var query = Logic.GetList(expCampus).SingleOrDefault(); return query; } public IQueryable GetList(params ViewModel.ConfiguretView[] configuretViews) { System.Linq.Expressions.Expression> expCampus = (x => true); var query = Logic.GetList(expCampus); //查询条件 foreach (var configuretView in configuretViews) { if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return query .OrderBy(x => x.ExaminationBatchProjectPersonControlID); } public bool Delete(List IDs) { UnitOfWork.Delete(x => IDs.Contains(x.ExaminationBatchProjectPersonControlID)); UnitOfWork.Commit(); return true; } } }