Пример #1
0
 public static MemberModel Get(int id, string mobilePhone)
 {
     using (var pointContext = new PointContexts())
     {
         return(pointContext.Members.FirstOrDefault(m => m.Id == id && m.MobilePhone == mobilePhone && m.Status == MemberStatus.Normal));
     }
 }
Пример #2
0
 public static OrderModel Get(string orderNo)
 {
     using (var pointContext = new PointContexts())
     {
         return(pointContext.Orders.FirstOrDefault(m => m.OrderNo == orderNo));
     }
 }
Пример #3
0
 public static bool?Exists(string mobilePhone)
 {
     using (var context = new PointContexts())
     {
         return(context.Members.Any(m => m.MobilePhone == mobilePhone));
     }
 }
Пример #4
0
 public static NewsModel Get(int id)
 {
     using (var context = new PointContexts())
     {
         return(context.News.FirstOrDefault(m => m.Id == id));
     }
 }
Пример #5
0
 public static bool?Exists(string keyName, int id = 0)
 {
     using (var context = new PointContexts())
     {
         return(context.SysConfigs.Any(m => id == 0 && m.KeyName == keyName || m.Id != id && m.KeyName == keyName));
     }
 }
Пример #6
0
 public static ShopCouponCardModel Get(int id)
 {
     using (var pointContext = new PointContexts())
     {
         return(pointContext.ShopCouponCards.FirstOrDefault(m => m.Id == id));
     }
 }
Пример #7
0
 public static SysConfigModel GetDictionaryConfig(string keyName)
 {
     using (var context = new PointContexts())
     {
         return(context.SysConfigs.FirstOrDefault(m => m.KeyName == keyName && m.IsActive));
     }
 }
Пример #8
0
 public static void GetList(QueryBase <MemberFundingModel> entity)
 {
     using (var context = new PointContexts())
     {
         entity.DataList = context.MemberFundings.Where(m => m.UserId == entity.UserId).OrderBy(m => m.Id).Skip(entity.PageSize * (entity.PageIndex - 1)).Take(entity.PageSize).ToList();
     }
 }
Пример #9
0
 public static List <NewsModel> GetList(List <int> ids)
 {
     using (var context = new PointContexts())
     {
         return(context.News.Where(m => ids.Contains(m.Id)).ToList());
     }
 }
Пример #10
0
 public static bool Exists(int newsId, int userId)
 {
     using (var context = new PointContexts())
     {
         return(context.QuestionFeedbacks.Any(m => m.NewsId == newsId && m.UserId == userId));
     }
 }
Пример #11
0
 public static MemberModel Get(string mobilePhone, string encryptedPwd)
 {
     using (var pointContext = new PointContexts())
     {
         return(pointContext.Members.FirstOrDefault(m => m.MobilePhone == mobilePhone && m.EncryptedPwd == encryptedPwd && m.Status == MemberStatus.Normal));
     }
 }
Пример #12
0
 public static List <QuestionModel> GetList(int newsId)
 {
     using (var context = new PointContexts())
     {
         return(context.Questions.Where(m => m.NewsId == newsId).ToList());
     }
 }
Пример #13
0
 public static int Count(int userId, int newId)
 {
     using (var context = new PointContexts())
     {
         var query = context.Favorites.Count(m => m.UserId == userId && m.NewsId == newId);
         return(query);
     }
 }
Пример #14
0
 public static void GetShopList(ShopRequest entity)
 {
     using (var context = new PointContexts())
     {
         var query = context.Shops.Where(m => m.Category == entity.Category);
         entity.DataList = query.Skip(entity.PageSize * (entity.PageIndex - 1)).Take(entity.PageSize).ToList();
     }
 }
Пример #15
0
 public static bool Add(SysConfigModel entity)
 {
     using (var context = new PointContexts())
     {
         context.SysConfigs.Add(entity);
         return(context.SaveChanges() >= 1);
     }
 }
Пример #16
0
        public static bool Update(SysConfigModel entity)
        {
            const string sqlQuery = @"UPDATE [dbo].[DictionaryConfig] SET GroupName={0},KeyName={1},Value={2},Description={3},Expand={4},TypeId={5},OwnerName={6},LastOpUserId={7},UpdateTime={8} WHERE Id={9}";

            using (var context = new PointContexts())
            {
                return(context.Database.ExecuteSqlCommand(sqlQuery, entity.GroupName, entity.KeyName, entity.Value, entity.Description, entity.Expand, entity.TypeId, entity.OwnerName, entity.LastOpUserId, entity.UpdateTime, entity.Id) > 0);
            }
        }
Пример #17
0
 public static bool DeleteEntity(T entity)
 {
     using (var pointContext = new PointContexts())
     {
         pointContext.Set <T>().Attach(entity);
         pointContext.Entry <T>(entity).State = EntityState.Deleted;
         return(pointContext.SaveChanges() > 0);
     }
 }
Пример #18
0
        public static List <MemberFeedModel> GetMemberFeedList(int memberId, int pageIndex, int pageSize = 10)
        {
            const string sqlQuery = @"SELECT * FROM [dbo].[MemberFeed] WITH(NOLOCK) WHERE UserId = {0}";

            using (var context = new PointContexts())
            {
                var query = context.Database.SqlQuery <MemberFeedModel>(sqlQuery, memberId);
                return(query.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList());
            }
        }
Пример #19
0
        public static void GetHomeFeedList(QueryBase <NewsModel> entity)
        {
            const string sqlQuery = @"SELECT A.* FROM [dbo].[News] AS A WITH(NOLOCK) JOIN [dbo].[HomeFeed] AS B  WITH(NOLOCK) ON A.Id = B.NewsId WHERE B.UserId = {0} ";

            using (var context = new PointContexts())
            {
                var query = context.Database.SqlQuery <NewsModel>(sqlQuery, entity.UserId);
                entity.DataList = query.Skip(entity.PageSize * (entity.PageIndex - 1)).Take(entity.PageSize).ToList();
            }
        }
Пример #20
0
 protected static T AddEntity(T entity)
 {
     using (var pointContext = new PointContexts())
     {
         pointContext.Entry(entity).State = EntityState.Added;
         //下面的写法统一
         pointContext.SaveChanges();
         return(entity);
     }
 }
Пример #21
0
 public static MemberModel Get(int id)
 {
     if (id <= 0)
     {
         return(null);
     }
     using (var pointContext = new PointContexts())
     {
         return(pointContext.Members.FirstOrDefault(m => m.Id == id && m.Status == MemberStatus.Normal));
     }
 }
Пример #22
0
 protected static bool UpdateEntity(T entity)
 {
     //EF4.0的写法
     //Db.CreateObjectSet<T>().Addach(entity);
     //Db.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified);
     //EF5.0的写法
     using (var pointContext = new PointContexts())
     {
         pointContext.Set <T>().Attach(entity);
         pointContext.Entry <T>(entity).State = EntityState.Modified;
         return(pointContext.SaveChanges() > 0);
     }
 }
Пример #23
0
 public static SmsModel Get(string mobilePhone, byte smsType, int smsCode)
 {
     using (var context = new PointContexts())
     {
         return(context.Sms.OrderByDescending(m => m.Id).FirstOrDefault
                (
                    m =>
                    m.MobilePhone == mobilePhone &&
                    m.SmsType == smsType &&
                    m.SmsCode == smsCode
                ));
     }
 }
Пример #24
0
        public static List <SysConfigModel> GetList(int typeId, string search)
        {
            string sqlQuery = @"SELECT * FROM [dbo].[DictionaryConfig] WITH(NOLOCK) WHERE IsActive=1 ";

            if (typeId >= 0)
            {
                sqlQuery += string.Format(" AND TypeId = {0}", typeId);
            }
            if (!string.IsNullOrEmpty(search))
            {
                sqlQuery += String.Format(" AND ( GroupName LIKE '%{0}%' OR KeyName LIKE '%{0}%'  OR [Value] LIKE '%{0}%' OR [Description] LIKE '%{0}%' OR OwnerName LIKE '%{0}%')", search);
            }
            sqlQuery += " ORDER BY ID DESC";
            using (var context = new PointContexts())
            {
                return(context.Database.SqlQuery <SysConfigModel>(sqlQuery, typeId).ToList());
            }
        }