78 lines
2.6 KiB
C#
78 lines
2.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using WX.CRM.BLL.Base;
|
|
using WX.CRM.BLL.Util;
|
|
using WX.CRM.DAL.Csvr;
|
|
using WX.CRM.IBLL.Csvr;
|
|
using WX.CRM.Model.Entity;
|
|
|
|
namespace WX.CRM.BLL.Csvr
|
|
{
|
|
public class CSVR_IDMAP_BL : ICSVR_IDMAP_Q, ICSVR_IDMAP
|
|
{
|
|
/// <summary>
|
|
/// 根据旧的customerID
|
|
/// </summary>
|
|
/// <param name="OldCustoemrId"></param>
|
|
/// <returns></returns>
|
|
public List<string> GetResId(string OldCustoemrId)
|
|
{
|
|
using (var db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
List<string> list = new List<string>();
|
|
list = (from m in db.CSVR_IDMAP join b in db.RES_CUSTOMER on m.RESID equals b.RESID where m.CUSTOMERID == OldCustoemrId select b.CUSTOMERID).Distinct().ToList();
|
|
return list;
|
|
}
|
|
}
|
|
|
|
public List<CSVR_IDMAP> GetResIdList(System.Data.DataTable dt, string selecttype)
|
|
{
|
|
//using (var db = new WX.CRM.Model.Entity.crmContext())
|
|
//{
|
|
|
|
// List<string> list = new List<string>();
|
|
// list = (from m in db.CSVR_IDMAP join b in db.RES_CUSTOMER on m.RESID equals b.RESID where oldCustomerId.Contains(m.CUSTOMERID) select b.CUSTOMERID).Distinct().ToList();
|
|
// return list;
|
|
|
|
//}
|
|
CSVR_IDMAPDAL dal = new CSVR_IDMAPDAL();
|
|
dal.InserCustomerIds(dt);
|
|
return dal.GetResIdByCustomerIds(selecttype);
|
|
}
|
|
|
|
public bool Create(CSVR_IDMAP model)
|
|
{
|
|
try
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
CSVR_IDMAP ciModel = db.CSVR_IDMAP.Where(m => m.RESID == model.RESID && m.CUSTOMERID == model.CUSTOMERID).FirstOrDefault();
|
|
if (ciModel != null)
|
|
{
|
|
return false;
|
|
}
|
|
model.PKID = new SEQUENCES_BL().Seq_base_get();
|
|
model.CTIME = DateTime.Now;
|
|
db.CSVR_IDMAP.Add(model);
|
|
return db.SaveChanges().GetResult();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
public CSVR_IDMAP GetModelByResIdAndCustomerId(string oldcustomerid, string newresid)
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
return db.CSVR_IDMAP.Where(m => m.RESID == newresid && m.CUSTOMERID == oldcustomerid).FirstOrDefault();
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|