90 lines
3.0 KiB
C#
90 lines
3.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using WX.CRM.BLL.Base;
|
|
using WX.CRM.BLL.Util;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.IBLL.Wx;
|
|
|
|
namespace WX.CRM.BLL.Wx
|
|
{
|
|
public class WX_UNLINE_NOTICECONFIG_BL : IWX_UNLINE_NOTICECONFIG
|
|
{
|
|
#region 添加
|
|
/// <summary>
|
|
/// 添加
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public bool Create(ref ValidationErrors errors, WX.CRM.Model.Entity.WX_UNLINE_NOTICECONFIG model)
|
|
{
|
|
try
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
var entry = db.WX_UNLINE_NOTICECONFIG.FirstOrDefault(m => m.EID == model.EID);
|
|
if (entry != null)
|
|
{
|
|
errors.Add("已经添加了这个工号!");
|
|
return false;
|
|
}
|
|
var xn = db.BAS_INNERUSER.FirstOrDefault(m => m.EID == model.EID);
|
|
if (xn == null)
|
|
{
|
|
errors.Add("请输入正确的工号!");
|
|
return false;
|
|
}
|
|
|
|
model.PKID = new SEQUENCES_BL().Seq_base_get();
|
|
model.CTIME = DateTime.Now;
|
|
db.WX_UNLINE_NOTICECONFIG.Add(model);
|
|
return db.SaveChanges().GetResult();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
errors.Add(ex.Message);
|
|
return false;
|
|
}
|
|
}
|
|
#endregion
|
|
#region 删除
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public bool Delete(ref ValidationErrors errors, decimal id)
|
|
{
|
|
try
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
WX.CRM.Model.Entity.WX_UNLINE_NOTICECONFIG entry = db.WX_UNLINE_NOTICECONFIG.FirstOrDefault(m => m.PKID == id);
|
|
if (entry == null)
|
|
{
|
|
errors.Add("数据已经被删除!");
|
|
return false;
|
|
}
|
|
db.WX_UNLINE_NOTICECONFIG.Remove(entry);
|
|
return db.SaveChanges().GetResult();
|
|
}
|
|
}
|
|
catch (Exception ex) { errors.Add(ex.Message); return false; }
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 推送配置人
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<WX.CRM.Model.Entity.WX_UNLINE_NOTICECONFIG> GetList()
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
return db.WX_UNLINE_NOTICECONFIG.OrderByDescending(m => m.CTIME).ToList();
|
|
}
|
|
}
|
|
}
|
|
}
|