Ejemplo n.º 1
0
        public HttpResponseMessage GetCrowdInfo(int status = -1)
        {

            //查询项目表所有的数据
            var sech = new CrowdSearchCondition
            {
                OrderBy = EnumCrowdSearchOrderBy.OrderById,
                Statuss = status
            };
            var list = _crowdService.GetCrowdsByCondition(sech).Select(p => new
            {
                //项目表
                p.Ttitle,
                p.Id,
                p.Status,
                p.Intro,
                p.Starttime,
                p.Endtime,
                p.Uptime,
                p.Upuser,
                p.Adduser,
                p.Addtime,
                p.crowdUrl
            }).ToList().Select(a => new
            {
                //返回数据
                Id = a.Id,
                Ttitle = a.Ttitle,
                Intro = a.Intro,
                Endtime = a.Endtime,
                Starttime = a.Starttime,
                Status = a.Status,
                ImgList = _partImageService.GetPartImageByCrowdId(a.Id),//查询众筹对应的图片
                // Dislist = _discountService.GetDiscountByCrowdId(a.Id),//查询众筹人数
                ////已参与众筹人数
                //crowdNum = _participationService.GetParticipationCountByCrowdId(a.Id),
                ////众筹最低优惠对应的人数
                //crowdMaxNum = _discountService.GetDiscountMaxCountByCrowdId(a.Id),
                crowdUrl = a.crowdUrl,
                //Addtime=a.Addtime.ToString("yyyy-MM-dd") ,
                Addtime = a.Addtime.ToString("yyyy-MM-dd"),
                i = 0
            });
            //.Where(p => p.crowdMaxNum != 0);
            return PageHelper.toJson(new { list });
        }
Ejemplo n.º 2
0
        public ActionResult crowd()
        {
            
            //查询项目表所有的数据
            var sech = new CrowdSearchCondition
            {
                OrderBy = EnumCrowdSearchOrderBy.OrderById,
                //Statuss = new[] { status }
            };
            var list = _crowdService.GetCrowdsByCondition(sech).Select(p => new
            {
                //项目表
                p.Ttitle,
                p.Id,
                p.Status,
                p.Intro,
                p.Starttime,
                p.Endtime,
                p.Uptime,
                p.Upuser,
                p.Adduser,
                p.Addtime
            }).ToList().Select(a => new CrowdModel
            {
                //返回数据
                Id = a.Id,
                Ttitle = a.Ttitle,
                Intro = a.Intro,
                Endtime = a.Endtime,
                Starttime = a.Starttime,
                Status = a.Status,
                ImgList = _partImageService.GetPartImageByCrowdId(a.Id),
                Dislist = _discountService.GetDiscountByCrowdId(a.Id),
                //已参与众筹人数
                crowdNum = _participationService.GetParticipationCountByCrowdId(a.Id),
                //众筹最低优惠对应的人数
                crowdMaxNum = _discountService.GetDiscountMaxCountByCrowdId(a.Id),
            }).Where (p=>p.crowdMaxNum !=0);

            return View(list);
        }
Ejemplo n.º 3
0
		public IQueryable<CrowdEntity> GetCrowdsByCondition(CrowdSearchCondition condition)
		{
			var query = _crowdRepository.Table;
			try
			{
				if (condition.StarttimeBegin.HasValue)
                {
                    query = query.Where(q => q.Starttime>= condition.StarttimeBegin.Value);
                }
                if (condition.Id >0)
                {
                    query = query.Where(q => q.Id ==condition .Id );
                }
                if (condition.StarttimeEnd.HasValue)
                {
                    query = query.Where(q => q.Starttime < condition.StarttimeEnd.Value);
                }
				if (condition.EndtimeBegin.HasValue)
                {
                    query = query.Where(q => q.Endtime>= condition.EndtimeBegin.Value);
                }
                if (condition.EndtimeEnd.HasValue)
                {
                    query = query.Where(q => q.Endtime < condition.EndtimeEnd.Value);
                }
				if (condition.AddtimeBegin.HasValue)
                {
                    query = query.Where(q => q.Addtime>= condition.AddtimeBegin.Value);
                }
                if (condition.AddtimeEnd.HasValue)
                {
                    query = query.Where(q => q.Addtime < condition.AddtimeEnd.Value);
                }
				if (condition.UptimeBegin.HasValue)
                {
                    query = query.Where(q => q.Uptime>= condition.UptimeBegin.Value);
                }
                if (condition.UptimeEnd.HasValue)
                {
                    query = query.Where(q => q.Uptime < condition.UptimeEnd.Value);
                }
				if (!string.IsNullOrEmpty(condition.Ttitle))
                {
                    query = query.Where(q => q.Ttitle.Contains(condition.Ttitle));
                }
				if (!string.IsNullOrEmpty(condition.Intro))
                {
                    query = query.Where(q => q.Intro.Contains(condition.Intro));
                }
				if (condition.Ids != null && condition.Ids.Any())
                {
                    query = query.Where(q => condition.Ids.Contains(q.Id));
                }
				if (condition.Statuss>=0)
                {
                    query = query.Where(q => condition.Statuss==q.Status);
                }
				if (condition.Addusers != null && condition.Addusers.Any())
                {
                    query = query.Where(q => condition.Addusers.Contains(q.Adduser));
                }
				if (condition.Upusers != null && condition.Upusers.Any())
                {
                    query = query.Where(q => condition.Upusers.Contains(q.Upuser));
                }
				if(condition.OrderBy.HasValue)
				{
					switch (condition.OrderBy.Value)
                    {
						case EnumCrowdSearchOrderBy.OrderById:
							query = condition.IsDescending?query.OrderByDescending(q=>q.Id):query.OrderBy(q=>q.Id);
							break;
                    }
					
				}
				else
				{
					query = query.OrderBy(q=>q.Id);
				}

				if (condition.Page.HasValue && condition.PageCount.HasValue)
                {
                    query = query.Skip((condition.Page.Value - 1)*condition.PageCount.Value).Take(condition.PageCount.Value);
                }
				return query;
			}
			catch(Exception e)
			{
				_log.Error(e,"数据库操作出错");
                return null;
			}
		}
Ejemplo n.º 4
0
		public int GetCrowdCount (CrowdSearchCondition condition)
		{
			var query = _crowdRepository.Table;
			try
			{
				if (condition.StarttimeBegin.HasValue)
                {
                    query = query.Where(q => q.Starttime>= condition.StarttimeBegin.Value);
                }
                if (condition.StarttimeEnd.HasValue)
                {
                    query = query.Where(q => q.Starttime < condition.StarttimeEnd.Value);
                }
				if (condition.EndtimeBegin.HasValue)
                {
                    query = query.Where(q => q.Endtime>= condition.EndtimeBegin.Value);
                }
                if (condition.EndtimeEnd.HasValue)
                {
                    query = query.Where(q => q.Endtime < condition.EndtimeEnd.Value);
                }
				if (condition.AddtimeBegin.HasValue)
                {
                    query = query.Where(q => q.Addtime>= condition.AddtimeBegin.Value);
                }
                if (condition.AddtimeEnd.HasValue)
                {
                    query = query.Where(q => q.Addtime < condition.AddtimeEnd.Value);
                }
				if (condition.UptimeBegin.HasValue)
                {
                    query = query.Where(q => q.Uptime>= condition.UptimeBegin.Value);
                }
                if (condition.UptimeEnd.HasValue)
                {
                    query = query.Where(q => q.Uptime < condition.UptimeEnd.Value);
                }
				if (!string.IsNullOrEmpty(condition.Ttitle))
                {
                    query = query.Where(q => q.Ttitle.Contains(condition.Ttitle));
                }
				if (!string.IsNullOrEmpty(condition.Intro))
                {
                    query = query.Where(q => q.Intro.Contains(condition.Intro));
                }
				if (condition.Ids != null && condition.Ids.Any())
                {
                    query = query.Where(q => condition.Ids.Contains(q.Id));
                }
				if (condition.Statuss>=0)
                {
                    query = query.Where(q => condition.Statuss==q.Status);
                }
				if (condition.Addusers != null && condition.Addusers.Any())
                {
                    query = query.Where(q => condition.Addusers.Contains(q.Adduser));
                }
				if (condition.Upusers != null && condition.Upusers.Any())
                {
                    query = query.Where(q => condition.Upusers.Contains(q.Upuser));
                }
				return query.Count();
			}
			catch(Exception e)
			{
				_log.Error(e,"数据库操作出错");
                return -1;
			}
		}