123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.Common.EvaluationManage;
- using Bowin.Common.Linq.Entity;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using System.Linq.Expressions;
- using EMIS.ViewModel.EvaluationManage;
- using EMIS.CommonLogic.SystemServices;
- namespace EMIS.CommonLogic.EvaluationManage
- {
- public class EvaluationTypeServices : BaseServices, IEvaluationTypeServices
- {
- public EvaluationTypeDAL evaluationTypeDAL { get; set; }
- public ISerialNumberServices SerialNumberServices { get; set; }
- /// <summary>
- /// 查询参评类型信息
- /// </summary>
- /// <param name="configuretView">查询条件实体</param>
- /// <param name="pageIndex">页码</param>
- /// <param name="pageSize">显示页数</param>
- /// <returns></returns>
- public IGridResultSet<EvaluationTypeView> GetEvaluationTypeViewGrid(ConfiguretView configuretView, int? isStudent, int? isDefault, int pageIndex, int pageSize)
- {
- var query = evaluationTypeDAL.GetEvaluationTypeQueryable(x => true);
- if (isStudent.HasValue && isStudent > -1)
- {
- bool student = isStudent == 1 ? true : false;
- query = query.Where(x => x.IsStudent == student);
- }
- if (isDefault.HasValue && isDefault > -1)
- {
- bool isdefault = isDefault == 1 ? true : false;
- query = query.Where(x => x.IsDefault == isdefault);
- }
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderByDescending(x => x.Name).ToGridResultSet<EvaluationTypeView>(pageIndex, pageSize);
- return query.OrderByDescending(x => x.Name).ToGridResultSet<EvaluationTypeView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询参评类型信息
- /// </summary>
- /// <param name="configuretView">查询条件实体</param>
- /// <returns></returns>
- public List<EvaluationTypeView> GetEvaluationTypeViewList(ConfiguretView configuretView, int? isStudent, int? isDefault)
- {
- var query = evaluationTypeDAL.GetEvaluationTypeQueryable(x => true);
- if (isStudent.HasValue && isStudent > -1)
- {
- bool student = isStudent == 1 ? true : false;
- query = query.Where(x => x.IsStudent == student);
- }
- if (isDefault.HasValue && isDefault > -1)
- {
- bool isdefault = isDefault == 1 ? true : false;
- query = query.Where(x => x.IsDefault == isdefault);
- }
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderByDescending(x => x.CreateTime).ToList();
- return query.OrderByDescending(x => x.CreateTime).ToList();
- }
- /// <summary>
- /// 获取参评类型信息
- /// </summary>
- /// <param name="typeID">主键ID</param>
- /// <returns></returns>
- public EMIS.Entities.EM_EvaluationType GetEvaluationType(Guid? typeID)
- {
- //查询条件
- Expression<Func<EMIS.Entities.EM_EvaluationType, bool>> expression = (x => x.EvaluationTypeID == typeID.Value);
- return evaluationTypeDAL.evaluationTypeRepository.GetSingle(expression);
- }
- /// <summary>
- /// 获取参评类型信息
- /// </summary>
- /// <param name="intType">参评类型</param>
- /// <returns></returns>
- public EMIS.Entities.EM_EvaluationType GetEvaluationType(string Name)
- {
- //查询条件
- Expression<Func<EMIS.Entities.EM_EvaluationType, bool>> expression = (x => x.Name == Name);
- return evaluationTypeDAL.evaluationTypeRepository.GetSingle(expression);
- }
- /// <summary>
- /// 获取参评类型信息
- /// </summary>
- /// <param name="typeID">主键ID</param>
- /// <returns></returns>
- public EvaluationTypeView GetEvaluationTypeView(Guid? typeID)
- {
- EvaluationTypeView evaluationTypeView = new EvaluationTypeView();
- if (typeID.HasValue)
- evaluationTypeView = evaluationTypeDAL.GetEvaluationTypeQueryable(x => true).Where(x => x.TypeID == typeID).FirstOrDefault();
- return evaluationTypeView;
- }
- /// <summary>
- /// 添加
- /// </summary>
- /// <param name="evaluationType">实体</param>
- /// <returns></returns>
- public bool EvaluationTypeAdd(EMIS.Entities.EM_EvaluationType evaluationType)
- {
- try
- {
- UnitOfWork.Add(evaluationType);
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 修改
- /// </summary>
- /// <param name="evaluationType">实体</param>
- /// <returns></returns>
- public bool EvaluationTypeUpdate(EMIS.Entities.EM_EvaluationType evaluationType)
- {
- try
- {
- UnitOfWork.Update(evaluationType);
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 保存或新增参评类型
- /// </summary>
- /// <param name="model"></param>
- public void SaveOrUpdateEvaluationType(EvaluationTypeView model)
- {
- var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- EM_EvaluationType entity;
- var entities = evaluationTypeDAL.evaluationTypeRepository.Entities.ToList();
- if (!model.TypeID.HasValue || model.TypeID == Guid.Empty)
- {
- entity = new EM_EvaluationType();
- entity.EvaluationTypeID = Guid.NewGuid();
- entity.CreateTime = DateTime.Now;
- entity.CreateUserID = user.UserID;
- //entity.Code = model.Code;
- UnitOfWork.Add(entity);
- }
- else
- {
- entity = entities.FirstOrDefault(w => w.EvaluationTypeID == model.TypeID);
- entities.Remove(entity);
- //UnitOfWork.Update(entity);
- }
- //entity.Name = model.Name;
- //entity.IsStudent = model.IsStudent;
- //entity.IsDefault = model.IsDefault;
- entity.StartTime = model.StartTime;
- entity.EndTime = model.EndTime;
- entity.Number = model.Number;
- entity.Remark = model.Remark;
- entity.ModifyUserID = user.UserID;
- entity.ModifyTime = DateTime.Now;
- if (entity.IsStudent == true)
- {
- //UnitOfWork.Update<EM_EvaluationType>(a => new EM_EvaluationType { IsDefault = false }, w => true);
- entities.ForEach(item => item.IsStudent = false);
- }
- UnitOfWork.Commit();
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="typeIDs"></param>
- /// <returns></returns>
- public bool EvaluationTypeDelete(List<Guid> typeIDs)
- {
- try
- {
- UnitOfWork.Delete<EMIS.Entities.EM_EvaluationType>(x => typeIDs.Contains(x.EvaluationTypeID));
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|