80 lines
2.7 KiB
C#
80 lines
2.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using WX.CRM.BLL.Util;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.IBLL.Base;
|
|
|
|
namespace WX.CRM.BLL.Base
|
|
{
|
|
public class BAS_RIGHT_TOOLBUTTON_BL : IBAS_RIGHT_TOOLBUTTON, IBAS_RIGHT_TOOLBUTTON_Q
|
|
{
|
|
public bool Create_ToolButton(ref ValidationErrors errors, WX.CRM.Model.Entity.BAS_RIGHT_TOOLBUTTON model)
|
|
{
|
|
try
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
db.BAS_RIGHT_TOOLBUTTON.Add(model);
|
|
return db.SaveChanges().GetResult();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
errors.Add(ex.Message);
|
|
return false;
|
|
}
|
|
}
|
|
public bool Create_ListToolButton(ref ValidationErrors errors, List<WX.CRM.Model.Entity.BAS_RIGHT_TOOLBUTTON> models)
|
|
{
|
|
try
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
foreach (var model in models)
|
|
{
|
|
db.BAS_RIGHT_TOOLBUTTON.Add(model);
|
|
}
|
|
return db.SaveChanges().GetResult();
|
|
}
|
|
}
|
|
catch (System.Data.Entity.Validation.DbEntityValidationException ex)
|
|
{
|
|
errors.Add(ex.Message);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public bool Delete_ToolButton(ref ValidationErrors errors, string RightId, decimal ButtonId)
|
|
{
|
|
try
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
WX.CRM.Model.Entity.BAS_RIGHT_TOOLBUTTON entry = db.BAS_RIGHT_TOOLBUTTON.FirstOrDefault(m => m.RIGHTID.Equals(RightId) && m.BUTTONID.Equals(ButtonId));
|
|
if (entry == null)
|
|
{
|
|
errors.Add("已经被删除!");
|
|
return false;
|
|
}
|
|
db.BAS_RIGHT_TOOLBUTTON.Remove(entry);
|
|
return db.SaveChanges().GetResult();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
errors.Add(ex.Message);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public List<WX.CRM.Model.Entity.BAS_RIGHT_TOOLBUTTON> GetALLToolButton()
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
return db.BAS_RIGHT_TOOLBUTTON.ToList();
|
|
}
|
|
}
|
|
}
|
|
}
|