using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using EMIS.DataLogic.ExaminationApply;
using EMIS.ViewModel.ExaminationApply;
using EMIS.ViewModel;
using EMIS.Entities;
using Bowin.Common.Linq.Entity;
namespace EMIS.CommonLogic.ExaminationApply
{
public class ExaminationTypeServices : BaseServices, IExaminationTypeServices
{
public ExaminationTypeDAL ExaminationTypeDAL { get; set; }
///
/// 考试类型
///
/// 实体
/// 当前页码
/// 显示页码
///
public Bowin.Common.Linq.Entity.IGridResultSet GetExaminationTypeViewList(ConfiguretView examinationTypeView, int pageIndex, int pageSize)
{
Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
var q = ExaminationTypeDAL.GetExaminationTypeView(exp);
if (!string.IsNullOrEmpty(examinationTypeView.ConditionValue) && !string.IsNullOrEmpty(examinationTypeView.Attribute))
q = q.DynamicWhere(examinationTypeView.Attribute, examinationTypeView.Condition, examinationTypeView.ConditionValue);
return q.OrderBy(x => x.Name).ToGridResultSet(pageIndex, pageSize);
}
///
/// 考试类型
///
/// 实体
///
public IList GetExaminationTypeViewList(ConfiguretView examinationTypeView)
{
Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
var q = ExaminationTypeDAL.GetExaminationTypeView(exp);
if (!string.IsNullOrEmpty(examinationTypeView.ConditionValue) && !string.IsNullOrEmpty(examinationTypeView.Attribute))
q = q.DynamicWhere(examinationTypeView.Attribute, examinationTypeView.Condition, examinationTypeView.ConditionValue);
return q.OrderBy(x => x.Name).ToList();
}
///
/// 根据ID获取考试类型详细信息
///
/// 考试类型ID
///
public ExaminationTypeView GetExaminationTypeViewInfo(Guid? examinationTypeID)
{
return ExaminationTypeDAL.GetExaminationTypeView(x => x.ExaminationTypeID == examinationTypeID).FirstOrDefault();
}
///
/// 保存考试类型
///
/// 考试类型实体
///
public void Save(ExaminationTypeView examinationTypeView)
{
var examinationTypeEntity = ExaminationTypeDAL.ExaminationTypeRepository.GetSingle(x => x.ExaminationTypeID == examinationTypeView.ExaminationTypeID);
if (examinationTypeEntity != null)
{
examinationTypeEntity.Name = examinationTypeView.Name;
examinationTypeEntity.IsTimesLimit = examinationTypeView.IsTimesLimit;
this.SetModifyStatus(examinationTypeEntity);
}
else
{
examinationTypeEntity = new EX_ExaminationType();
examinationTypeEntity.ExaminationTypeID = Guid.NewGuid();
examinationTypeEntity.Name = examinationTypeView.Name;
examinationTypeEntity.IsTimesLimit = examinationTypeView.IsTimesLimit;
this.SetNewStatus(examinationTypeEntity);
UnitOfWork.Add(examinationTypeEntity);
}
UnitOfWork.Commit();
}
///
/// 删除考试类型
///
/// 主键ID
///
public void Delete(IList examinationTypeID)
{
if (examinationTypeID.Count > 0)
{
UnitOfWork.Delete(x => examinationTypeID.Contains(x.ExaminationTypeID));
}
}
public ExaminationTypeView GetView(Expression> expCampus)
{
try
{
var query = ExaminationTypeDAL.GetExaminationTypeView(expCampus).FirstOrDefault();
return query;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
}
}