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 StudentExperienceServices : BaseServices, IStudentExperienceServices { public StudentExperienceDAL StudentExperienceDAL { get; set; } public IGridResultSet GetTopStudentExperienceGridView(Guid userID, int rowCount, int? pageIndex, int? pageSize) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.UserID == userID); var result = this.StudentExperienceDAL.GetStudentExperienceViewQueryable(exp).Take(rowCount).ToList(); var newRowCount = rowCount - result.Count; for (var i = 0; i < newRowCount; i++) { result.Add(new StudentExperienceView { StudentExperienceID = Guid.NewGuid(), UserID = userID }); } return new GridResultSet { rows = result, total = result.Count }; } public void Save(Guid userID, IList studentExperienceViewList) { UnitOfWork.Remove(x => x.UserID == userID); var studentExperienceList = (from experience in studentExperienceViewList select new CF_StudentExperience { StudentExperienceID = Guid.NewGuid(), UserID = userID, StartYear = experience.StartYear, StartMonth = experience.StartMonth, EndYear = experience.EndYear, EndMonth = experience.EndMonth, Experience = experience.Experience }).ToList(); studentExperienceList.ForEach(x => this.SetNewStatus(x)); UnitOfWork.AddRange(studentExperienceList); UnitOfWork.Commit(); } } }