123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.SchedulingManage.SchedulingSettings;
- using EMIS.CommonLogic.CalendarManage;
- using EMIS.Entities;
- using System.Linq.Expressions;
- using Bowin.Common.Linq.Entity;
- using Bowin.Common.Linq;
- using EMIS.ViewModel.SchedulingManage.SchedulingSettings;
- using EMIS.ViewModel.CalendarManage;
- using EMIS.DataLogic.Repositories;
- namespace EMIS.CommonLogic.SchedulingManage.SchedulingSettings
- {
- public class CourseScheduleSettingServices : BaseServices, ICourseScheduleSettingServices
- {
- public CourseScheduleSettingDAL courseScheduleSettingDAL { get; set; }
- public IArrangementServices arrangementServices { get; set; }
- /// <summary>
- /// 查询课程排课时间设置
- /// </summary>
- /// <param name="coursematerialID"></param>
- /// <param name="courseLevelID"></param>
- /// <param name="courseScienceID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.SchedulingManage.SchedulingSettings.CourseScheduleSettingView> GetCourseScheduleSettingViewGrid(Guid? coursematerialID, int? courseLevelID, int? courseScienceID, int pageIndex, int pageSize)
- {
- Expression<Func<EM_Coursematerial, bool>> exp = (x => true);
- if (coursematerialID.HasValue)
- exp = exp.And(x => x.CoursematerialID == coursematerialID);
- if (courseLevelID.HasValue)
- exp = exp.And(x => x.CourseLevelID == courseLevelID);
- if (courseScienceID.HasValue)
- exp = exp.And(x => x.CourseScienceID == courseScienceID);
- var query = courseScheduleSettingDAL.GetCourseScheduleSettingViewQueryable(exp);
- return query.OrderByDescending(x => x.CreateTime).ToGridResultSet<CourseScheduleSettingView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询
- /// </summary>
- /// <param name="coursematerialID"></param>
- /// <returns></returns>
- public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.CalendarManage.ArrangementView> GetArrangementViewGrid(Guid? coursematerialID)
- {
- var resultSet = courseScheduleSettingDAL.GetArrangementViewQueryable(coursematerialID).OrderBy(x => x.StartTimes).ToGridResultSet<ArrangementView>();
- if (resultSet.total > 0)
- {
- return resultSet;
- }
- return arrangementServices.GetArrangementViewGrid();
- }
- /// <summary>
- /// 新增
- /// </summary>
- /// <param name="listArrangement"></param>
- public void CourseScheduleSettingAdd(List<ViewModel.CalendarManage.ArrangementView> listArrangement, Guid? coursematerialID)
- {
- try
- {
- UnitOfWork.Delete<ES_CourseScheduleSetting>(x => x.CoursematerialID == coursematerialID);
- foreach (var arrangementView in listArrangement)
- {
- bool? IsOnWork = false;
- for (int i = 0; i < 7; i++)
- {
- if (i == (int)DayOfWeek.Monday)
- IsOnWork = arrangementView.MondayIsOnWork;
- if (i == (int)DayOfWeek.Tuesday)
- IsOnWork = arrangementView.TuesdayIsOnWork;
- if (i == (int)DayOfWeek.Wednesday)
- IsOnWork = arrangementView.WednesdayIsOnWork;
- if (i == (int)DayOfWeek.Thursday)
- IsOnWork = arrangementView.ThursdayIsOnWork;
- if (i == (int)DayOfWeek.Friday)
- IsOnWork = arrangementView.FridayIsOnWork;
- if (i == (int)DayOfWeek.Saturday)
- IsOnWork = arrangementView.SaturdayIsOnWork;
- if (i == (int)DayOfWeek.Sunday)
- IsOnWork = arrangementView.SundayIsOnWork;
- ES_CourseScheduleSetting courseScheduleSetting = new ES_CourseScheduleSetting();
- courseScheduleSetting.CourseScheduleSettingID = Guid.NewGuid();
- courseScheduleSetting.CoursematerialID = coursematerialID;
- courseScheduleSetting.CoursesTimeID = arrangementView.CoursesTimeID;
- courseScheduleSetting.Weekday = i;
- courseScheduleSetting.IsOnWork = IsOnWork;
- SetNewStatus(courseScheduleSetting);
- UnitOfWork.Add(courseScheduleSetting);
- }
- }
- UnitOfWork.Commit();
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="userIDs"></param>
- public void CourseScheduleSettingDelete(List<Guid?> coursematerialIDs)
- {
- try
- {
- UnitOfWork.Delete<ES_CourseScheduleSetting>(x => coursematerialIDs.Contains(x.CoursematerialID));
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|