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; }
- /// <summary>
- /// 查询对应的俱乐部课程View
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="courseLevelID"></param>
- /// <param name="courseScienceID"></param>
- /// <param name="classGroupingID"></param>
- /// <param name="isEnable"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- 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);
- }
- /// <summary>
- /// 查询对应的俱乐部课程List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="courseLevelID"></param>
- /// <param name="courseScienceID"></param>
- /// <param name="classGroupingID"></param>
- /// <param name="isEnable"></param>
- /// <returns></returns>
- 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();
- }
- /// <summary>
- /// 查询对应的课程信息View(课程信息表左连俱乐部课程表,排除对应的俱乐部课程信息)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="courseLevelID"></param>
- /// <param name="courseScienceID"></param>
- /// <param name="isEnable"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- 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);
- }
- /// <summary>
- /// 查询对应的课程信息List(课程信息表左连俱乐部课程表,排除对应的俱乐部课程信息)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="courseLevelID"></param>
- /// <param name="courseScienceID"></param>
- /// <param name="isEnable"></param>
- /// <returns></returns>
- 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();
- }
- /// <summary>
- /// 根据俱乐部课程ID查询对应的俱乐部课程信息ClubCourseView
- /// </summary>
- /// <param name="ClubCourseID"></param>
- /// <returns></returns>
- 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);
- }
- }
- /// <summary>
- /// 批量新增
- /// </summary>
- /// <param name="clubCourseView"></param>
- /// <param name="courseNoClubViewList"></param>
- /// <returns></returns>
- public string ClubCourseBatchAdd(ClubCourseView clubCourseView, List<CoursematerialView> courseNoClubViewList)
- {
- try
- {
- //俱乐部课程信息List
- 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);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="clubCourseIDList"></param>
- /// <returns></returns>
- 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);
- }
- }
- }
- }
|