Esempio n. 1
0
 public ActiveListRS GetActives(ActiveListRQ rq)
 {
     if (rq == null || rq.pageIndex <= 0 || rq.pageSize <= 0)
     {
         return new ActiveListRS {
                    total = 0, list = null
         }
     }
     ;
     return(_service.GetActives(rq));
 }
Esempio n. 2
0
        /// <summary>
        /// 活动管理列表
        /// </summary>
        /// <param name="rq"></param>
        /// <returns></returns>

        public ActiveListRS GetActives(ActiveListRQ rq)
        {
            var result = new ActiveListRS {
                total = 0, list = null
            };
            var sql = string.Empty;//"select * from Active where 1=1 ";

            if (!string.IsNullOrWhiteSpace(rq.paraName))
            {
                sql += string.Format(" (Title like '%{0}%' or ContentUrl like '%{0}%') ", rq.paraName);
            }
            var user  = Active.FindAll(sql, "Id desc", null, (rq.pageIndex - 1) * rq.pageSize, rq.pageSize);
            var query = (from a in user.ToList()
                         select new
            {
                a.ContentUrl,
                a.ImageUrl,
                a.Title,
                a.CreatedByName,
                a.CreatedOn,
                a.Id,
                a.ModifiedByName,
                a.ModifiedOn,
            });

            query        = query.OrderByDescending(q => q.ModifiedOn).ThenByDescending(q => q.Id);
            result.total = Active.FindAll(sql, null, null, 0, 0).Count;//query.Count();
            if (result.total == 0)
            {
                return(result);
            }
            result.list = query.Select(a => new ActiveListItemRS
            {
                ContentUrl     = a.ContentUrl,
                ImageUrl       = a.ImageUrl,
                Title          = a.Title,
                Id             = a.Id,
                ModifiedByName = a.ModifiedByName,
                ModifiedOn     = a.ModifiedOn,
                CreatedOn      = a.CreatedOn,
                CreatedByName  = a.CreatedByName
            }).ToList();
            return(result);
        }