Esempio n. 1
0
        public IPagedList <Models.Admin.ChildrensDay.ChildrensDayHiddenPicture> GetChildrensDayHiddenPictureList(ChildrensDayOption options)
        {
            var query = repository.ChildrensDayHiddenPicture.AsQueryable();

            if (options.FromDate.HasValue)
            {
                var fromDate = options.FromDate.Value.Date;
                query = query.Where(e => e.CreateDate >= fromDate);
            }
            if (options.ToDate.HasValue)
            {
                var toDate = options.ToDate.Value.AddDays(1).Date;
                query = query.Where(e => e.CreateDate < toDate);
            }

            if (!string.IsNullOrEmpty(options.Name))
            {
                query = query.Where(e => e.Name.ToLower().Contains(options.Name.ToLower()));
            }
            if (!string.IsNullOrEmpty(options.Mobile))
            {
                query = query.Where(e => e.Mobile.Contains(options.Mobile));
            }
            if (!string.IsNullOrEmpty(options.Channel))
            {
                query = query.Where(e => e.Channel.Equals(options.Channel));
            }
            var result = query.Select(e => new Models.Admin.ChildrensDay.ChildrensDayHiddenPicture {
                CreateDate = e.CreateDate,
                Channel    = e.Channel,
                IpAddress  = e.IpAddress,
                Name       = e.Name,
                Gender     = e.Gender,
                Mobile     = e.Mobile,
                Age        = e.Age
            }).OrderByDescending(e => e.CreateDate);

            return(new Domain.Service.SerializablePagedList <Models.Admin.ChildrensDay.ChildrensDayHiddenPicture>(result, options.Page, options.PageSize));
        }
Esempio n. 2
0
        public PagedList.IPagedList <Models.Admin.ChildrensDay.ChildrensDayHiddenPictureSNSState> GetChildrensDayHiddenPictureSnsStats(ChildrensDayOption options)
        {
            var sns = repository.ChildrensDayHiddenPicture.AsQueryable()
                      .Join(repository.ChildrensDayHiddenPictureSns, e => e.Id, p => p.ChildrensDayHiddenPictureId, (e, p) => new { SnsType = p.SnsType.ToLower(), Mobile = e.Mobile, Name = e.Name, Age = e.Age });

            var query = from s in sns
                        group s by s.Mobile into HiddenPicureSns

                        select new Models.Admin.ChildrensDay.ChildrensDayHiddenPictureSNSState {
                Mobile          = HiddenPicureSns.Key,
                Name            = HiddenPicureSns.Max(e => e.Name),
                Age             = HiddenPicureSns.Max(e => e.Age),
                FacebookCount   = HiddenPicureSns.Count(e => e.SnsType == "facebook"),
                KakaostoryCount = HiddenPicureSns.Count(e => e.SnsType == "kakaostory"),
                KakaotalkCount  = HiddenPicureSns.Count(e => e.SnsType == "kakaotalk"),
                TotalCount      = HiddenPicureSns.Count()
            };

            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));
            }
            query = query.OrderByDescending(e => e.TotalCount);
            return(new SerializablePagedList <Models.Admin.ChildrensDay.ChildrensDayHiddenPictureSNSState>(query, options.Page, options.PageSize));
        }