123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- using EMIS.ViewModel.EvaluationManage;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.DataLogic.Common.EvaluationManage;
- using EMIS.Entities;
- using System.Linq.Expressions;
- namespace EMIS.CommonLogic.EvaluationManage
- {
- public class EvaluationIntTypeServices : BaseServices, IEvaluationIntTypeServices
- {
- public EvaluationIntTypeDAL evaluationIntTypeDAL { get; set; }
- /// <summary>
- /// 列表信息
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="intType"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<EvaluationIntTypeView> GetEvaluationIntTypeViewGrid(ViewModel.ConfiguretView configuretView, int? intType, int pageIndex, int pageSize)
- {
- Expression<Func<EM_EvaluationIntType, bool>> exp = x => true;
- if (intType.HasValue && intType > 0)
- {
- exp = exp.And(x => x.EM_EvaluationTeachingMode.Select(w => w.TeachingModeID).Contains(intType));
- }
- var query = evaluationIntTypeDAL.GetEvaluationIntTypeQueryable(exp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- }
- var result = query.OrderBy(x => x.Code.Length).ThenBy(x => x.Code).ToGridResultSet<EvaluationIntTypeView>(pageIndex, pageSize);
- var evaluationIntTypeIDList = result.rows.Select(x => x.EvaluationIntTypeID).ToList();
- var querEvaluationTeachingModeTypeView = evaluationIntTypeDAL.GetEvaluationTeachingModeTypeQuery(x => evaluationIntTypeIDList.Contains(x.EvaluationIntTypeID)).ToList();
- result.rows.ForEach(x => x.TeachingModeTypeViewList = new HashSet<TeachingModeTypeView>(querEvaluationTeachingModeTypeView.Where(y => y.EvaluationIntTypeID == x.EvaluationIntTypeID)));
- return result;
- }
- public List<EvaluationIntTypeView> GetEvaluationIntTypeViewList(ViewModel.ConfiguretView configuretView, int? intType)
- {
- Expression<Func<EM_EvaluationIntType, bool>> exp = x => true;
- if (intType.HasValue && intType > 0)
- {
- exp = exp.And(x => x.EM_EvaluationTeachingMode.Select(w => w.TeachingModeID).Contains(intType));
- }
- var query = evaluationIntTypeDAL.GetEvaluationIntTypeQueryable(exp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- }
- var result = query.OrderBy(x => x.Code.Length).ThenBy(x => x.Code).ToList();
- var evaluationIntTypeIDList = result.Select(x => x.EvaluationIntTypeID).ToList();
- var querEvaluationTeachingModeTypeView = evaluationIntTypeDAL.GetEvaluationTeachingModeTypeQuery(x => evaluationIntTypeIDList.Contains(x.EvaluationIntTypeID)).ToList();
- result.ForEach(x => x.TeachingModeTypeViewList = new HashSet<TeachingModeTypeView>(querEvaluationTeachingModeTypeView.Where(y => y.EvaluationIntTypeID == x.EvaluationIntTypeID)));
- return result.ToList();
- }
- /// <summary>
- /// 编辑新增
- /// </summary>
- /// <param name="model"></param>
- public void SaveOrUpdateEvaluationIntType(EvaluationIntTypeView model)
- {
- if (model.EvaluationIntTypeID == Guid.Empty || model.EvaluationIntTypeID == null)
- {
- EM_EvaluationIntType evaluationIntType = new EM_EvaluationIntType();
- evaluationIntType.EvaluationIntTypeID = Guid.NewGuid();
- evaluationIntType.Code = model.Code;
- evaluationIntType.Name = model.Name;
- evaluationIntType.Remark = model.Remark;
- SetNewStatus(evaluationIntType);
- UnitOfWork.Add(evaluationIntType);
- if (model.TeachingModeTypeID == null || model.TeachingModeTypeID.Count() < 0)
- {
- throw new Exception("授课方式不能为空。");
- }
- model.TeachingModeTypeID.ForEach(x =>
- {
- EM_EvaluationTeachingMode evaluationTeachingMode = new EM_EvaluationTeachingMode();
- evaluationTeachingMode.EvaluationTeachingModeID = Guid.NewGuid();
- evaluationTeachingMode.EvaluationIntTypeID = evaluationIntType.EvaluationIntTypeID;
- evaluationTeachingMode.TeachingModeID = x;//授课方式
- SetNewStatus(evaluationTeachingMode);
- UnitOfWork.Add(evaluationTeachingMode);
- });
- }
- else
- {
- if (model.TeachingModeTypeID == null || model.TeachingModeTypeID.Count() < 0)
- {
- throw new Exception("授课方式不能为空。");
- }
- EM_EvaluationIntType evaluationIntType = evaluationIntTypeDAL.evaluationIntTypeRepository.
- GetSingle(x => x.EvaluationIntTypeID == model.EvaluationIntTypeID);
- evaluationIntType.Code = model.Code;
- evaluationIntType.Name = model.Name;
- evaluationIntType.Remark = model.Remark;
- Guid EvaluationIntTypeIDList = evaluationIntType.EvaluationIntTypeID;
- UnitOfWork.Delete<EM_EvaluationTeachingMode>(x => x.EvaluationIntTypeID == EvaluationIntTypeIDList);//先删除评价类型授课方式再重新添加
- SetModifyStatus(evaluationIntType);
- UnitOfWork.Update(evaluationIntType);
- model.TeachingModeTypeID.ForEach(x =>
- {
- EM_EvaluationTeachingMode evaluationTeachingMode = new EM_EvaluationTeachingMode();
- evaluationTeachingMode.EvaluationTeachingModeID = Guid.NewGuid();
- evaluationTeachingMode.EvaluationIntTypeID = evaluationIntType.EvaluationIntTypeID;
- evaluationTeachingMode.TeachingModeID = x;//授课方式
- SetNewStatus(evaluationTeachingMode);
- UnitOfWork.Add(evaluationTeachingMode);
- });
- }
- UnitOfWork.Commit();
- }
- /// <summary>
- /// 删除操作
- /// </summary>
- /// <param name="IntTypeIDs"></param>
- /// <returns></returns>
- public bool EvaluationIntTypeDelete(List<Guid> IntTypeIDs)
- {
- try
- {
- //设置极联删除~~
- UnitOfWork.Delete<EM_EvaluationTeachingMode>(x => IntTypeIDs.Contains((Guid)x.EvaluationIntTypeID));//删除评价类型授课方式
- UnitOfWork.Delete<EM_EvaluationIntType>(x => IntTypeIDs.Contains(x.EvaluationIntTypeID));//删除评价类型
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 加载授课方式
- /// </summary>
- /// <param name="evaluationIntTypeID"></param>
- /// <returns></returns>
- public List<int> GetTeachingMode(Guid? evaluationIntTypeID)
- {
- return evaluationIntTypeDAL.GetTeachingModeTypeQueryble(evaluationIntTypeID);
- }
- public EvaluationIntTypeView GetEvaluationIntTypeView(Guid? evaluationIntTypeID)
- {
- EvaluationIntTypeView evaluationIntTypeView = new EvaluationIntTypeView();
- if (evaluationIntTypeID.HasValue && evaluationIntTypeID != Guid.Empty)
- {
- evaluationIntTypeView = evaluationIntTypeDAL.GetEvaluationIntTypeQueryable(x => true).Where(x => x.EvaluationIntTypeID == evaluationIntTypeID).FirstOrDefault();
- }
- return evaluationIntTypeView;
- }
- }
- }
|