using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EMIS.DataLogic.Repositories;
using EMIS.ViewModel;
using Bowin.Common.Linq.Entity;
using EMIS.Entities;
using EMIS.ViewModel.ScoreManage;
namespace EMIS.CommonLogic.ScoreManage
{
public class GradePointFormulaServices : BaseServices, IGradePointFormulaServices
{
public GradePointFormulaRepository gradePointFormulaRepository { get; set; }
///
/// 绩点公式设置查询列表
///
///
///
///
///
public Bowin.Common.Linq.Entity.IGridResultSet GetGradePointFormulaGrid(string name, int pageIndex, int pageSize)
{
var query = gradePointFormulaRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
if (!string.IsNullOrEmpty(name))
query = query.Where(x => x.Name.Contains(name));
return query.OrderByDescending(x => x.CreateTime).ToGridResultSet(pageIndex, pageSize);
}
///
/// 绩点公式设置查询列表
///
///
///
public List GetGradePointFormulaList(string name)
{
var query = gradePointFormulaRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
if (!string.IsNullOrEmpty(name))
query = query.Where(x => x.Name.Contains(name));
return query.OrderByDescending(x => x.CreateTime).ToList();
}
///
/// 绩点公式设置
///
///
///
public Entities.ER_GradePointFormula GetGradePointFormula(Guid? gradePointFormulaID)
{
return gradePointFormulaRepository.GetSingle(x => x.GradePointFormulaID == gradePointFormulaID);
}
///
/// 新增、修改绩点公式设置
///
///
public void GradePointFormulaAdd(GradePointFormulaView gradePointFormulaView)
{
try
{
ER_GradePointFormula gradePointFormula = null;
if (gradePointFormulaView.GradePointFormulaID == null || gradePointFormulaView.GradePointFormulaID == Guid.Empty)
{
gradePointFormula = new ER_GradePointFormula();
gradePointFormula.GradePointFormulaID = Guid.NewGuid();
gradePointFormula.Name = gradePointFormulaView.Name;
gradePointFormula.GradePointlimit = gradePointFormulaView.GradePointlimit;
gradePointFormula.GradePointFloor = gradePointFormulaView.GradePointFloor;
SetNewStatus(gradePointFormula);
UnitOfWork.Add(gradePointFormula);
}
else
{
gradePointFormula = GetGradePointFormula(gradePointFormulaView.GradePointFormulaID);
if (gradePointFormula == null)
throw new Exception("未找到相对应的成绩绩点公式设置!");
gradePointFormula.Name = gradePointFormulaView.Name;
gradePointFormula.GradePointlimit = gradePointFormulaView.GradePointlimit;
gradePointFormula.GradePointFloor = gradePointFormulaView.GradePointFloor;
SetModifyStatus(gradePointFormula);
}
UnitOfWork.Commit();
}
catch (Exception)
{
throw;
}
}
///
/// 删除
///
///
public void GradePointFormulaDelete(List gradePointFormulaIDs)
{
try
{
if (gradePointFormulaIDs.Count > 0)
{
UnitOfWork.Delete(x => gradePointFormulaIDs.Contains(x.GradePointFormulaID));
}
}
catch (Exception)
{
throw;
}
}
}
}