| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- using SqlSugar;
- using System;
- using System.Collections.Generic;
- using System.Common;
- using System.Data;
- using System.IRepositories;
- using System.Linq.Expressions;
- using System.Model;
- using System.Text;
- using System.Threading.Tasks;
- namespace System.Repositories
- {
- public class Cus_VipInfoRepository : BaseRepository<T_Cus_VipInfo>, ICus_VipInfoRepository
- {
- public async Task<PageData<V_Cus_VipInfo>> GetListViewByPage(List<IConditionalModel> conModels, MyPageModel pagemodel, string orderby)
- {
- var list = await Db.SqlQueryable<V_Cus_VipInfo>("select * from T_Cus_VipInfo ").With(SqlWith.NoLock).Where(conModels).OrderBy(orderby).ToPageListAsync(pagemodel.PageIndex, pagemodel.PageSize, pagemodel.PageCount);
- var newlist = new List<V_Cus_VipInfo>();
- foreach (var item in list)
- {
- var newmodel = item;
- if (item.F_Birthday != null)
- newmodel.Birthday = item.F_Birthday.Value.ToString("yyyy-MM-dd");
- newmodel.F_Contact = 0;
- newlist.Add(newmodel);
- }
- PageData<V_Cus_VipInfo> pd = new PageData<V_Cus_VipInfo>();
- pd.Rows = newlist;
- pd.Totals = pagemodel.PageCount;
- return pd;
- }
-
- public async Task<V_Cus_VipInfo> GetSingleV(Expression<Func<V_Cus_VipInfo, bool>> whereExpression)
- {
- var model= await Db.SqlQueryable<V_Cus_VipInfo>("select * from T_Cus_VipInfo ").With(SqlWith.NoLock).Where(whereExpression).SingleAsync();
- if(model.F_Birthday!=null)
- model.Birthday=model.F_Birthday.Value.ToString("yyyy-MM-dd");
- return model;
- //return CurrentDb.GetSingle(whereExpression);
- }
- public async Task<int> GetVCount(string Tel,string whereExpression)
- {
- string sql = "SELECT COUNT(1) FROM T_Cus_VipInfo where F_State=1 ";
- sql += $" AND (F_Phone in ({Tel} )or F_Mobile in ( {Tel} )";
- if (!string .IsNullOrEmpty (whereExpression))
- {
- sql += $" { whereExpression} )";
- }
- else
- {
- sql += ")";
- }
- List<SugarParameter> sugarParameter = new List<SugarParameter>()
- {
- };
- DataTable dt = await GetTableSugar(sql);
- if (dt != null && dt.Rows.Count > 0)
- {
- return dt.Rows[0][0].ObjToInt();
- }
- return 0;
- }
- public async Task<T_Cus_VipInfo> GetListVipInfo(string where)
- {
- var list = await Db.SqlQueryable<T_Cus_VipInfo>("select * from T_Cus_VipInfo where "+ where).ToListAsync();
- T_Cus_VipInfo pd = new T_Cus_VipInfo();
- if (list != null && list.Count > 0)
- pd = list[0];
- return pd;
- }
- }
-
- }
|