Exemple #1
0
        public PagedList.IPagedList <WinListEntry> GetChristmas2015WinList(Christmas2015QueryOptionsByWin options)
        {
            var query = repository.Christmas2015Wins.Select(e => new WinListEntry {
                Name         = e.Name,
                Mobile       = e.Mobile,
                Zipcode      = e.Zipcode,
                Address1     = e.Address1,
                Address2     = e.Address2,
                PrizeType    = e.PrizeType,
                IpAddress    = e.IpAddress,
                Channel      = e.Channel,
                RegisterDate = e.RegisterDate
            });

            if (options.StartDate.HasValue)
            {
                var sDate = options.StartDate.Value.Date;
                query = query.Where(e => e.RegisterDate >= sDate);
            }

            if (options.EndDate.HasValue)
            {
                var eDate = options.EndDate.Value.AddDays(1);
                query = query.Where(e => e.RegisterDate < eDate);
            }
            if (!string.IsNullOrEmpty(options.Channel))
            {
                query = query.Where(e => e.Channel == options.Channel);
            }
            if (!string.IsNullOrEmpty(options.Name))
            {
                query = query.Where(e => e.Name.Contains(options.Name));
            }
            if (!string.IsNullOrEmpty(options.Mobile))
            {
                query = query.Where(e => e.Mobile.Contains(options.Mobile));
            }

            if (options.PrizeType.HasValue)
            {
                var prizeType = options.PrizeType.Value;
                query = query.Where(e => e.PrizeType == prizeType);
            }
            query = query.OrderByDescending(e => e.RegisterDate);
            return(new SerializablePagedList <WinListEntry>(query, options.Page, options.PageSize));
        }
Exemple #2
0
        public PagedList.IPagedList <WinListByIpAddress> GetChristmas2015WinByIpAddress(Christmas2015QueryOptionsByWin options)
        {
            var query = repository.Christmas2015Wins;

            if (options.StartDate.HasValue)
            {
                var sDate = options.StartDate.Value.Date;
                query = query.Where(e => e.RegisterDate >= sDate);
            }
            if (options.EndDate.HasValue)
            {
                var eDate = options.EndDate.Value.AddDays(1);
                query = query.Where(e => e.RegisterDate < eDate);
            }
            if (!string.IsNullOrEmpty(options.IpAddress))
            {
                query = query.Where(e => e.IpAddress.Contains(options.IpAddress));
            }

            var sql = query.GroupBy(e => e.IpAddress).Select(e => new WinListByIpAddress {
                IpAddress   = e.Key,
                TotalCount  = e.Count(),
                LoserCount  = e.Count(x => x.PrizeType == Domain.Abstract.Christmas2015.Christmas2015EnumConst.Christmas2015WinPrize.Loser),
                KinderCount = e.Count(x => x.PrizeType == Domain.Abstract.Christmas2015.Christmas2015EnumConst.Christmas2015WinPrize.Kinder),
                CloakCount  = e.Count(x => x.PrizeType == Domain.Abstract.Christmas2015.Christmas2015EnumConst.Christmas2015WinPrize.Cloak)
            });

            sql = sql.OrderByDescending(e => e.TotalCount);
            return(new SerializablePagedList <WinListByIpAddress>(sql, options.Page, options.PageSize));
        }