1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.Common.Students;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.Students;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using EMIS.ViewModel;
- namespace EMIS.CommonLogic.Students
- {
- public class StudentFamilyServices : BaseServices, IStudentFamilyServices
- {
- public StudentFamilyDAL StudentFamilyDAL { get; set; }
- public IGridResultSet<StudentFamilyView> GetTopStudentFamilyGridView(Guid userID, int rowCount, int? pageIndex, int? pageSize)
- {
- Expression<Func<CF_StudentFamily, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
- && x.UserID == userID);
- var result = this.StudentFamilyDAL.GetStudentFamilyViewQueryable(exp).Take(rowCount).ToList();
- var newRowCount = rowCount - result.Count;
- for (var i = 0; i < newRowCount; i++)
- {
- result.Add(new StudentFamilyView
- {
- StudentFamilyID = Guid.NewGuid(),
- UserID = userID
- });
- }
- return new GridResultSet<StudentFamilyView> { rows = result, total = result.Count };
- }
- public void Save(Guid userID, IList<StudentFamilyView> studentFamilyViewList)
- {
- UnitOfWork.Remove<CF_StudentFamily>(x => x.UserID == userID);
- var studentFamilyList = new List<CF_StudentFamily>();
- for (int i = 1; i <= studentFamilyViewList.Count; i++)
- {
- var family = studentFamilyViewList[i - 1];
- var studentFamily = new CF_StudentFamily
- {
- StudentFamilyID = Guid.NewGuid(),
- UserID = userID,
- Name = family.Name,
- Relation = family.Relation,
- Age = family.Age,
- Politics = family.Politics,
- Unit = family.Unit,
- PhoneNumber = family.PhoneNumber,
- OrderNo = i
- };
- this.SetNewStatus(studentFamily);
- studentFamilyList.Add(studentFamily);
- }
- UnitOfWork.AddRange(studentFamilyList);
- UnitOfWork.Commit();
- }
- }
- }
|