using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.Common.EvaluationManage; using Bowin.Common.Linq.Entity; using EMIS.ViewModel.EvaluationManage; using EMIS.ViewModel; using System.Linq.Expressions; using EMIS.Entities; using Bowin.Common.Linq; using Bowin.Common.Utility; using Bowin.Common.Mapping; using EMIS.CommonLogic.SystemServices; namespace EMIS.CommonLogic.EvaluationManage { public class TeacherEvaluationServices : BaseServices, ITeacherEvaluationServices { public TeacherEvaluationDAL TeacherEvaluationDAL { get; set; } public ISerialNumberServices SerialNumberServices { get; set; } public IGridResultSet GetTeacherEvaluationViewGrid(ConfiguretView configuretView, Guid? schoolYearID, Guid? campusID, Guid? collegeID, int? openStatus, int pageIndex, int pageSize) { Expression> filter = w => w.RecordStatus == (int)SYS_STATUS.USABLE; if (openStatus.HasValue && openStatus != -1) { filter = filter.And(w => w.OpenStatus == openStatus); } var query = TeacherEvaluationDAL.GetTeacherEvaluationQuery(filter); if (schoolYearID.HasValue && schoolYearID != Guid.Empty) { query.Where(w => w.SchoolyearID == schoolYearID); } if (campusID.HasValue && campusID != Guid.Empty) { query.Where(w => w.CampusID == campusID); } if (collegeID.HasValue && collegeID != Guid.Empty) { query.Where(w => w.CollegeID == collegeID); } query = GetQueryByDataRangeByCollege(query); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue); query = query.OrderByDescending(o => o.EntityCreateTime); return query.ToGridResultSet(pageIndex, pageSize); } public TeacherEvaluationView GetTeacherEvaluationView(Guid? id) { var result = new TeacherEvaluationView(); if (id.HasValue && id != Guid.Empty) result = TeacherEvaluationDAL.GetTeacherEvaluationQuery(w => w.ID == id).FirstOrDefault(); return result; } public void AddOrUpdateTeacherEvaluation(TeacherEvaluationView model) { EM_TeacherEvaluation entity; if (model.EntityID == Guid.Empty) { entity = new EM_TeacherEvaluation(); model.DynamicCloneTo(entity); //SetNewStatus方法去掉了设置ID的功能 entity.ID = Guid.NewGuid(); SetNewStatus(entity); entity.Code = SerialNumberServices.SetSN(model.CourseCode + "(" + model.SchoolyearCode + ")"); entity.CreateTime = DateTime.Now; UnitOfWork.Add(entity); } else { entity = TeacherEvaluationDAL.TeacherEvaluationRepository.GetSingle(w => w.ID == model.EntityID); model.DynamicCloneTo(entity); SetModifyStatus(entity); UnitOfWork.Update(entity); } UnitOfWork.Commit(); } public void DeleteTeacherEvaluation(List ids) { UnitOfWork.Delete(w => ids.Contains(w.ID)); } } }