using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Transactions;
using EMIS.Entities;
using EMIS.ViewModel;
using EMIS.ViewModel.EvaluationManage.EvaluationSetting;
using EMIS.DataLogic.Repositories;
namespace EMIS.CommonLogic.EvaluationManage.EvaluationSetting
{
public class EvaluationSensitiveWordServices : BaseServices, IEvaluationSensitiveWordServices
{
public ParameterRepository ParameterRepository { get; set; }
///
/// 查询对应的敏感词信息EvaluationSensitiveWordView
///
///
public EvaluationSensitiveWordView GetEvaluationSensitiveWordView()
{
var evaluationSensitiveWordView = new EvaluationSensitiveWordView();
var parameter = ParameterRepository.GetSingle(x => x.ParameterTypeID == (int)CF_ParameterType.EvaluationSensitiveWord);
if (parameter != null)
{
evaluationSensitiveWordView.EvaluationSensitiveWordID = parameter.ParameterID;
evaluationSensitiveWordView.ParameterTypeID = parameter.ParameterTypeID;
evaluationSensitiveWordView.Value = parameter.Value;
evaluationSensitiveWordView.RecordStatus = parameter.RecordStatus;
}
return evaluationSensitiveWordView;
}
///
/// 敏感词保存
///
///
public void EvaluationSensitiveWordSave(EvaluationSensitiveWordView evaluationSensitiveWordView)
{
try
{
var parameterInList = new List();
var newParameter = new CF_Parameter();
newParameter.ParameterID = Guid.NewGuid();
newParameter.ParameterTypeID = (int)CF_ParameterType.EvaluationSensitiveWord;
newParameter.Value = evaluationSensitiveWordView.Value;
this.SetNewStatus(newParameter);
parameterInList.Add(newParameter);
using (TransactionScope ts = new TransactionScope())
{
UnitOfWork.Delete(x => x.ParameterTypeID == (int)CF_ParameterType.EvaluationSensitiveWord);
UnitOfWork.BulkInsert(parameterInList);
ts.Complete();
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
}
}