using System;
using System.Collections.Generic;
using System.Linq;
using WX.CRM.BLL.Base;
using WX.CRM.Common;
using WX.CRM.DAL.Qc;
using WX.CRM.IBLL.Base;
using WX.CRM.Model.Entity;
namespace WX.CRM.BLL.Quality
{
public class QC_BASEUSERSCORE_BL : IQC_BASEUSERSCORE
{
///
///
///
///
///
public List GetList()
{
try
{
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
{
return db.QC_BASEUSERSCORE.ToList();
}
}
catch (Exception ex)
{
LogHelper.Error(ex);
return null;
}
}
///
/// 添加
///
///
///
public bool Create(ref ValidationErrors errors, WX.CRM.Model.Entity.QC_BASEUSERSCORE model)
{
try
{
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
{
WX.CRM.Model.Entity.BAS_INNERUSER entry = db.BAS_INNERUSER.FirstOrDefault(m => m.EID == model.SCORENO);
if (entry != null)
{
errors.Add("分值代码已经使用!");
return false;
}
db.Configuration.ValidateOnSaveEnabled = false;
model.PKID = new SEQUENCES_BL().Seq_base_get();
db.QC_BASEUSERSCORE.Add(model);
db.SaveChanges();
return true;
}
}
catch (Exception ex)
{
errors.Add(ex.Message);
return false;
}
}
///
/// 删除
///
///
///
public bool Delete(ref ValidationErrors errors, decimal id)
{
try
{
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
{
var delobj = db.QC_BASEUSERSCORE.FirstOrDefault(obj => obj.PKID == id);
if (null != delobj)
{
db.QC_BASEUSERSCORE.Remove(delobj);
db.SaveChanges();
}
return true;
}
}
catch (Exception ex)
{
errors.Add(ex.Message);
return false;
}
}
///
/// 更新基础表
///
///
public bool UpdateBaserUserCore(List list)
{
try
{
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
{
foreach (QC_BASEUSERSCORE item in list)
{
db.QC_BASEUSERSCORE.Add(item);
}
db.SaveChanges();
}
}
catch { throw; }
return true;
}
///
/// 删除 员工主管分值表数据
///
public void DeleteScoreData()
{
new UserScore_DL().DeleteScoreData("BASEUSERSCORE", null, null);
}
}
}