using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.ViewModel.MinorManage.MinorApply; using EMIS.DataLogic.MinorManage.MinorApply; using System.Linq.Expressions; using EMIS.Entities; using Bowin.Common.Linq.Entity; using EMIS.ViewModel.MinorManage.MinorPlanManage; using EMIS.DataLogic.MinorManage.MinorPlanManage; using EMIS.ViewModel; using Bowin.Common.Linq; namespace EMIS.CommonLogic.MinorManage.MinorApply { public class StudentMinorServices : BaseServices, IStudentMinorServices { public StudentMinorDAL studentMinorDAL { get; set; } public MinorSpecialtyPlanDAL minorSpecialtyPlanDAL { get; set; } public IMinorApplyServices minorApplyServices { get; set; } public StudentMinorView GetMinorApplyView(Guid userID) { var statusList = minorApplyServices.GetStatusViewList(); Expression> exp = x => x.UserID == userID; if (statusList.Where(y => y.Description.Contains("BP")).FirstOrDefault() != null) { var returnStatus = statusList.Where(y => y.Description.Contains("BP")).FirstOrDefault().ID; exp = exp.And(x => x.RecordStatus != returnStatus); } var query = studentMinorDAL.GetStudentMinorViewQueryable(exp).FirstOrDefault(); if (query != null) { query.RecordStatusStr = statusList.FirstOrDefault(w => w.ID == query.RecordStatus).Name; } return query; } public IGridResultSet GetMinorSpecialtyViewByUserIDGrid(Guid userID, int? pageIndex, int? pageSize) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); var grademinorID = studentMinorDAL.GetGrademinorIDByUserID(userID); exp = exp.And(x => x.GrademinorID == grademinorID); var query = minorSpecialtyPlanDAL.GetMinorSpecialtyPlanViewQueryable(exp); var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StandardID).ThenBy(x => x.SchoolcodeStr) .ToGridResultSet(pageIndex, pageSize); return result; } public void StudentMinorCancel(Guid? userID, Guid? studentMinorRegistID) { try { var grademinor = studentMinorDAL.grademinorRepository.GetSingle(x => x.EM_StudentMinorRegist.Any(y => y.StudentMinorRegistID == studentMinorRegistID)); if(grademinor != null) { if (grademinor.RecordStatus == (int)CF_GrademinorStatus.Confirmed) { throw new Exception("报名的辅修专业已开班,不能取消报名"); } } if (studentMinorDAL.classminorStudentRepository.Entities.Any(x => x.UserID == userID)) { UnitOfWork.Delete(x => x.UserID == userID); } UnitOfWork.Delete(x => x.StudentMinorRegistID == studentMinorRegistID); UnitOfWork.Commit(); } catch (Exception) { throw; } } } }