using System; using System.Collections.Generic; using System.Data; using System.Data.Entity; using System.Linq; using WX.CRM.BLL.Util; using WX.CRM.Common; using WX.CRM.IBLL.Level2; namespace WX.CRM.BLL.Level2 { public class L2_SOFT_REFUNDAPPLAY_BL : IL2_SOFT_REFUNDAPPLAY, IL2_SOFT_REFUNDAPPLAY_Q { public void Create(Model.Entity.L2_SOFT_REFUNDAPPLAY model) { using (var contex = new Model.Entity.crmContext()) { model.CTIME = DateTime.Now; model.PKID = new Base.SEQUENCES_BL().Seq_base_get(); contex.L2_SOFT_REFUNDAPPLAY.Add(model); contex.SaveChanges(); } } public void Update(Model.Entity.L2_SOFT_REFUNDAPPLAY model) { using (var contex = new Model.Entity.crmContext()) { contex.L2_SOFT_REFUNDAPPLAY.Attach(model); contex.Entry(model).State = EntityState.Modified; contex.SaveChanges(); } } public void Delete(decimal pkid) { using (var contex = new Model.Entity.crmContext()) { var model = contex.L2_SOFT_REFUNDAPPLAY.FirstOrDefault(p => p.PKID == pkid); contex.L2_SOFT_REFUNDAPPLAY.Remove(model); contex.SaveChanges(); } } public Model.Entity.L2_SOFT_REFUNDAPPLAY getRefundapplay(decimal orderId, string username) { using (var contex = new Model.Entity.crmContext()) { return contex.L2_SOFT_REFUNDAPPLAY.FirstOrDefault(p => p.ORDERID == orderId && p.USERNAME == username); } } public Model.Entity.L2_SOFT_REFUNDAPPLAY getRefundapplay(decimal pkid) { using (var contex = new Model.Entity.crmContext()) { return contex.L2_SOFT_REFUNDAPPLAY.FirstOrDefault(p => p.PKID == pkid); } } public List GetList(ref Pager pager, decimal? orderId, string username, decimal? orderstatus, DateTime? ctime, DateTime? etime) { using (var contex = new Model.Entity.crmContext()) { var list = contex.L2_SOFT_REFUNDAPPLAY.AsQueryable(); if (orderId.HasValue) list = list.Where(p => p.ORDERID == orderId); if (!string.IsNullOrEmpty(username)) list = list.Where(p => p.USERNAME == username); if (orderstatus.HasValue) list = list.Where(p => p.ORDERSTATUS == orderstatus); if (ctime.HasValue) list = list.Where(p => p.CTIME > ctime); if (etime.HasValue) list = list.Where(p => p.CTIME < etime); list = list.OrderByDescending(m => m.CTIME); PagerUtil.SetPager(ref list, ref pager); return list.ToList(); } } } }