Ejemplo n.º 1
0
        public static IQueryable <JGN_Badges_LevelAssociates> processOptionalConditions(IQueryable <JGN_Badges_LevelAssociates> collectionQuery, LevelAssociateEntity query)
        {
            if (query.order != "")
            {
                collectionQuery = (IQueryable <JGN_Badges_LevelAssociates>)collectionQuery.Sort(query.order);
            }

            // validation check (if not set, it will return zero records that will make it difficult to debug the code)
            if (query.pagesize == 0)
            {
                query.pagesize = 18;
            }
            // skip logic
            if (query.pagenumber > 1)
            {
                collectionQuery = collectionQuery.Skip(query.pagesize * (query.pagenumber - 1));
            }
            // take logic
            if (!query.loadall)
            {
                collectionQuery = collectionQuery.Take(query.pagesize);
            }


            return(collectionQuery);
        }
Ejemplo n.º 2
0
 private static int CountRecords(ApplicationDbContext context, LevelAssociateEntity entity)
 {
     return(context.JGN_Badges_LevelAssociates.Where(returnWhereClause(entity)).Count());
 }
Ejemplo n.º 3
0
        public static Task <List <JGN_Badges_LevelAssociates> > Load(ApplicationDbContext context, LevelAssociateEntity entity)
        {
            var collectionQuery = context.JGN_Badges_LevelAssociates.Where(returnWhereClause(entity));

            collectionQuery = processOptionalConditions(collectionQuery, entity);
            return(LoadCompleteList(collectionQuery));
        }
Ejemplo n.º 4
0
 public static int Count(ApplicationDbContext context, LevelAssociateEntity entity)
 {
     return(CountRecords(context, entity));
 }
Ejemplo n.º 5
0
        private static System.Linq.Expressions.Expression <Func <JGN_Badges_LevelAssociates, bool> > returnWhereClause(LevelAssociateEntity entity)
        {
            var where_clause = PredicateBuilder.New <JGN_Badges_LevelAssociates>(true);

            if (entity.rewardid > 0)
            {
                where_clause = where_clause.And(p => p.rewardid == entity.rewardid);
            }
            if (entity.levelid > 0)
            {
                where_clause = where_clause.And(p => p.levelid == entity.levelid);
            }
            if (entity.id > 0)
            {
                where_clause = where_clause.And(p => p.id == entity.id);
            }


            return(where_clause);
        }