using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; using System.Transactions; using Bowin.Common.Linq; using Bowin.Common.Linq.Entity; using Bowin.Common.Utility; using EMIS.Entities; using EMIS.ViewModel; using EMIS.ViewModel.StudentManage.StudentProfile; using EMIS.DataLogic.StudentManage.StudentProfile; namespace EMIS.CommonLogic.StudentManage.StudentProfile { public class StudentPostPracticeServices : BaseServices, IStudentPostPracticeServices { public Lazy StudentPostPracticeDAL { get; set; } /// /// 查询对应的学生顶岗实习信息StudentPostPracticeView /// /// /// /// /// /// public IGridResultSet GetStudentPostPracticeViewGrid(Guid userID, int rowCount, int? pageIndex, int? pageSize) { Expression> expStudentPostPractice = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expStudentPostPractice = expStudentPostPractice.And(x => x.UserID == userID); var result = this.StudentPostPracticeDAL.Value.GetStudentPostPracticeViewQueryable(expStudentPostPractice).Take(rowCount).ToList(); var newRowCount = rowCount - result.Count; for (var i = 0; i < newRowCount; i++) { result.Add(new StudentPostPracticeView { StudentPostPracticeID = Guid.NewGuid(), UserID = userID }); } return new GridResultSet { rows = result, total = result.Count }; } /// /// 编辑 /// /// /// public void StudentPostPracticeEdit(Guid userID, IList studentPostPracticeViewList) { UnitOfWork.Remove(x => x.UserID == userID); var studentPostPracticeList = new List(); for (int i = 1; i <= studentPostPracticeViewList.Count; i++) { var studentPostPractice = studentPostPracticeViewList[i - 1]; var newStudentPostPractice = new CF_StudentPostPractice { StudentPostPracticeID = Guid.NewGuid(), UserID = userID, PracticePlace = studentPostPractice.PracticePlace, StartYear = studentPostPractice.StartYear, StartMonth = studentPostPractice.StartMonth, EndYear = studentPostPractice.EndYear, EndMonth = studentPostPractice.EndMonth, PracticeMentor = studentPostPractice.PracticeMentor, PracticeContent = studentPostPractice.PracticeContent, SelfAppraise = studentPostPractice.SelfAppraise }; this.SetNewStatus(newStudentPostPractice); studentPostPracticeList.Add(newStudentPostPractice); } UnitOfWork.AddRange(studentPostPracticeList); UnitOfWork.Commit(); } } }