123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Linq.Expressions;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel;
- using Bowin.Common.Linq;
- using EMIS.Entities;
- using EMIS.DataLogic.CultureplanManage.CourseMaterial;
- using EMIS.ViewModel.Cultureplan;
- using EMIS.ViewModel.CultureplanManage.CourseMaterial;
- namespace EMIS.CommonLogic.CultureplanManage.CourseMaterial
- {
- public class ClubCourseServices : BaseServices, IClubCourseServices
- {
- public ClubCourseDAL ClubCourseDAL { get; set; }
-
-
-
-
-
-
-
-
-
-
-
- public IGridResultSet<ClubCourseView> GetClubCourseViewGrid(ConfiguretView configuretView, int? courseLevelID, int? courseScienceID,
- Guid? classGroupingID, int? isEnable, int pageIndex, int pageSize)
- {
-
- Expression<Func<ER_ClubCourse, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var query = ClubCourseDAL.GetClubCourseViewQueryable(exp);
- if (courseLevelID.HasValue)
- {
- query = query.Where(x => x.CourseLevelID == courseLevelID);
- }
- if (courseScienceID.HasValue)
- {
- query = query.Where(x => x.CourseScienceID == courseScienceID);
- }
- if (classGroupingID.HasValue)
- {
- query = query.Where(x => x.ClassGroupingID == classGroupingID);
- }
- if (isEnable.HasValue)
- {
- if (isEnable == 1)
- {
- query = query.Where(x => x.IsEnable == true);
- }
- if (isEnable == 0)
- {
- query = query.Where(x => x.IsEnable != true);
- }
- }
-
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
- .ToGridResultSet<ClubCourseView>(pageIndex, pageSize);
- }
-
-
-
-
-
-
-
-
-
- public List<ClubCourseView> GetClubCourseViewList(ConfiguretView configuretView, int? courseLevelID, int? courseScienceID,
- Guid? classGroupingID, int? isEnable)
- {
-
- Expression<Func<ER_ClubCourse, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var query = ClubCourseDAL.GetClubCourseViewQueryable(exp);
- if (courseLevelID.HasValue)
- {
- query = query.Where(x => x.CourseLevelID == courseLevelID);
- }
- if (courseScienceID.HasValue)
- {
- query = query.Where(x => x.CourseScienceID == courseScienceID);
- }
- if (classGroupingID.HasValue)
- {
- query = query.Where(x => x.ClassGroupingID == classGroupingID);
- }
- if (isEnable.HasValue)
- {
- if (isEnable == 1)
- {
- query = query.Where(x => x.IsEnable == true);
- }
- if (isEnable == 0)
- {
- query = query.Where(x => x.IsEnable != true);
- }
- }
-
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode).ToList();
- }
-
-
-
-
-
-
-
-
-
-
- public IGridResultSet<CoursematerialView> GetCourseNoClubViewGrid(ConfiguretView configuretView, int? courseLevelID,
- int? courseScienceID, int? isEnable, int pageIndex, int pageSize)
- {
-
- Expression<Func<EM_Coursematerial, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (courseLevelID.HasValue)
- {
-
- exp = exp.And(x => x.CourseLevelID == courseLevelID);
- }
- if (courseScienceID.HasValue)
- {
-
- exp = exp.And(x => x.CourseScienceID == courseScienceID);
- }
- if (isEnable.HasValue)
- {
- if (isEnable == 1)
- {
- exp = exp.And(x => x.IsEnable == true);
- }
- if (isEnable == 0)
- {
- exp = exp.And(x => x.IsEnable != true);
- }
- }
- var query = ClubCourseDAL.GetCourseNoClubViewQueryable(exp);
-
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
- .ToGridResultSet<CoursematerialView>(pageIndex, pageSize);
- }
-
-
-
-
-
-
-
-
- public List<CoursematerialView> GetCourseNoClubViewList(ConfiguretView configuretView, int? courseLevelID, int? courseScienceID, int? isEnable)
- {
-
- Expression<Func<EM_Coursematerial, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (courseLevelID.HasValue)
- {
-
- exp = exp.And(x => x.CourseLevelID == courseLevelID);
- }
- if (courseScienceID.HasValue)
- {
-
- exp = exp.And(x => x.CourseScienceID == courseScienceID);
- }
- if (isEnable.HasValue)
- {
- if (isEnable == 1)
- {
- exp = exp.And(x => x.IsEnable == true);
- }
- if (isEnable == 0)
- {
- exp = exp.And(x => x.IsEnable != true);
- }
- }
- var query = ClubCourseDAL.GetCourseNoClubViewQueryable(exp);
-
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode).ToList();
- }
-
-
-
-
-
- public ClubCourseView GetClubCourseView(Guid? ClubCourseID)
- {
- try
- {
- var query = ClubCourseDAL.GetClubCourseViewQueryable(x => x.ClubCourseID == ClubCourseID)
- .SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
-
-
-
-
-
-
- public string ClubCourseBatchAdd(ClubCourseView clubCourseView, List<CoursematerialView> courseNoClubViewList)
- {
- try
- {
-
- var clubCourseList = ClubCourseDAL.ClubCourseRepository
- .GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
- int success = 0;
- int fail = 0;
- string tipMessage = null;
- List<ER_ClubCourse> clubCourseInList = new List<ER_ClubCourse>();
- foreach (var courseNoClubView in courseNoClubViewList)
- {
-
- var clubCourseVerification = clubCourseList
- .Where(x => x.CoursematerialID == courseNoClubView.CoursematerialID)
- .SingleOrDefault();
- if (clubCourseVerification == null)
- {
-
- ER_ClubCourse clubCourse = new ER_ClubCourse();
- clubCourse.ClubCourseID = Guid.NewGuid();
- clubCourse.CoursematerialID = courseNoClubView.CoursematerialID;
- SetNewStatus(clubCourse);
- clubCourseInList.Add(clubCourse);
- success++;
- }
- else
- {
-
- fail++;
- }
- }
-
- UnitOfWork.BulkInsert<ER_ClubCourse>(clubCourseInList);
- if (success > 0 && fail <= 0)
- {
- tipMessage = success + "条";
- }
- else
- {
- tipMessage = success + "条," + fail + "条失败,原因:已存在相同的俱乐部课程,请检查";
- }
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
-
-
-
-
-
- public bool ClubCourseDelete(List<Guid?> clubCourseIDList)
- {
- try
- {
- UnitOfWork.Delete<ER_ClubCourse>(x => clubCourseIDList.Contains(x.ClubCourseID));
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- }
- }
|