107 lines
3.5 KiB
C#
107 lines
3.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.Entity;
|
|
using System.Linq;
|
|
using WX.CRM.BLL.Base;
|
|
using WX.CRM.BLL.Util;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.IBLL.Res;
|
|
using WX.CRM.Model.Entity;
|
|
|
|
namespace WX.CRM.BLL.Res
|
|
{
|
|
public class RES_CUSTOMERFEEDBACK_BL : IRES_CUSTOMERFEEDBACK, IRES_CUSTOMERFEEDBACK_Q
|
|
{
|
|
ValidationErrors errors = new ValidationErrors();
|
|
|
|
|
|
public bool Create(ref ValidationErrors errors, WX.CRM.Model.Entity.RES_CUSTOMERFEEDBACK model)
|
|
{
|
|
try
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
model.PKID = new SEQUENCES_BL().Seq_base_get();
|
|
model.CTIME = DateTime.Now;
|
|
db.RES_CUSTOMERFEEDBACK.Add(model);
|
|
return db.SaveChanges().GetResult();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
errors.Add(ex.Message);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public bool Update(ref ValidationErrors errors, WX.CRM.Model.Entity.RES_CUSTOMERFEEDBACK model)
|
|
{
|
|
try
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
model.CTIME = DateTime.Now;
|
|
db.RES_CUSTOMERFEEDBACK.Attach(model);
|
|
db.Entry<RES_CUSTOMERFEEDBACK>(model).State = EntityState.Modified;
|
|
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())
|
|
{
|
|
WX.CRM.Model.Entity.RES_CUSTOMERFEEDBACK entry = db.RES_CUSTOMERFEEDBACK.FirstOrDefault(m => m.PKID == id);
|
|
if (entry == null)
|
|
{
|
|
errors.Add("数据已经被删除!");
|
|
return false;
|
|
}
|
|
db.RES_CUSTOMERFEEDBACK.Remove(entry);
|
|
return db.SaveChanges().GetResult();
|
|
}
|
|
}
|
|
catch (Exception ex) { errors.Add(ex.Message); return false; }
|
|
}
|
|
|
|
public WX.CRM.Model.Entity.RES_CUSTOMERFEEDBACK GetModel(decimal id)
|
|
{
|
|
using (var db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
return db.RES_CUSTOMERFEEDBACK.Where(m => m.PKID == id).FirstOrDefault();
|
|
}
|
|
}
|
|
|
|
public List<WX.CRM.Model.Entity.RES_CUSTOMERFEEDBACK> GetList(ref Pager pager)
|
|
{
|
|
using (var db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
var queryData = db.RES_CUSTOMERFEEDBACK.AsQueryable();
|
|
|
|
queryData = queryData.OrderByDescending(m => m.CTIME);
|
|
|
|
PagerUtil.SetPager<WX.CRM.Model.Entity.RES_CUSTOMERFEEDBACK>(ref queryData, ref pager);
|
|
return queryData.ToList();
|
|
}
|
|
}
|
|
|
|
public List<WX.CRM.Model.Entity.RES_CUSTOMERFEEDBACK> GetList()
|
|
{
|
|
using (var db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
return db.RES_CUSTOMERFEEDBACK.ToList();
|
|
}
|
|
}
|
|
}
|
|
}
|