Example #1
0
        public async Task <IEnumerable <Message> > GetAllMessages(int userId, MemberParameter para)
        {
            using (var db = NewDb())
            {
                var lastDate = System.DateTime.Now.AddMonths(-1);
                var messages = db.Message
                               .Include(x => x.Sender)
                               .Include(x => x.Recipient)
                               .AsQueryable();

                switch (para.MessageContainer)
                {
                case "Inbox":
                    messages = messages
                               .Where(x => x.RecipientId == userId && x.RecipientDeleted == false && x.SendDate > lastDate);
                    break;

                case "Outbox":
                    messages = messages
                               .Where(x => x.SenderId == userId && x.SenderDeleted == false && x.SendDate > lastDate);
                    break;

                default:
                    messages = messages
                               .Where(x => x.RecipientId == userId && x.RecipientDeleted == false && x.SendDate > lastDate);
                    break;
                }
                messages = messages.OrderByDescending(x => x.SendDate);
                return(messages);
            }
        }
Example #2
0
        public async Task <PageList <Member> > GetLikeMeLisk(int userId, MemberParameter para)
        {
            using (var db = base.NewDb())
            {
                var member = db.Liker
                             .Where(x => x.LikerId == userId && !x.IsDelete && !x.User.IsCloseData)
                             .Select(x => x.User)
                             .AsQueryable();

                return(await PageList <Member> .CreateAsync(member, para.PageNumber, para.PageSize));
            }
        }
Example #3
0
        public async Task <PageList <Member> > GetUserPageListAsync(MemberParameter parameters)
        {
            using (var db = base.NewDb())
            {
                var list = db.Member
                           .Where(x => !x.IsCloseData)
                           .OrderByDescending(x => x.LoginDate)
                           .AsQueryable();

                return(await PageList <Member> .CreateAsync(list, parameters.PageNumber, parameters.PageSize));
            }
        }
Example #4
0
        public async Task <IEnumerable <Message> > GetUnreadMessages(int userId, MemberParameter para)
        {
            using (var db = NewDb())
            {
                var lastDate = System.DateTime.Now.AddMonths(-1);
                var messages = db.Message
                               .Include(x => x.Sender)
                               .Include(x => x.Recipient)
                               .Where(x => x.RecipientId == userId && x.SendDate > lastDate && x.RecipientDeleted == false && x.IsRead == false)
                               .AsQueryable();

                messages = messages.OrderByDescending(x => x.SendDate);
                return(messages);
            }
        }
Example #5
0
        public async Task <PageList <Member> > GetMatchList(MemberParameter parameter)
        {
            using (var db = base.NewDb())
            {
                var memberCondition = db.MemberCondition.FirstOrDefault(x => x.UserId == parameter.UserId);
                if (memberCondition == null)
                {
                    memberCondition = parameter.Condition;
                }

                var matchList = db.Member
                                .Where(x => x.Sex == memberCondition.MatchSex)
                                .OrderByDescending(x => x.LoginDate)
                                .AsQueryable();

                if (memberCondition.MarryMin > 0 && memberCondition.MarryMax > 0)
                {
                    matchList = matchList.Where(x => (x.Marry >= memberCondition.MarryMin && x.Marry <= memberCondition.MarryMax));
                }

                if (memberCondition.YearMin > 0 && memberCondition.YearMax > 0)
                {
                    matchList = matchList.Where(x => (x.BirthYear >= memberCondition.YearMin && x.BirthYear <= memberCondition.YearMax));
                }

                if (memberCondition.EducationMin > 0 && memberCondition.EducationMax > 0)
                {
                    matchList = matchList.Where(x => (x.Education >= memberCondition.EducationMin && x.Education <= memberCondition.EducationMax));
                }

                if (memberCondition.HeightsMin > 0 && memberCondition.HeightsMax > 0)
                {
                    matchList = matchList.Where(x => (x.Heights >= memberCondition.HeightsMin && x.Heights <= memberCondition.HeightsMax));
                }

                if (memberCondition.WeightsMin > 0 && memberCondition.WeightsMax > 0)
                {
                    matchList = matchList.Where(x => (x.Weights >= memberCondition.WeightsMin && x.Weights <= memberCondition.WeightsMax));
                }

                if (!string.IsNullOrEmpty(memberCondition.BloodInclude))
                {
                    matchList = matchList.Where(x => memberCondition.BloodInclude.Contains(x.Blood));
                }

                if (!string.IsNullOrEmpty(memberCondition.StarInclude))
                {
                    matchList = matchList.Where(x => memberCondition.StarInclude.Contains(x.Star));
                }

                if (!string.IsNullOrEmpty(memberCondition.CityInclude))
                {
                    matchList = matchList.Where(x => memberCondition.CityInclude.Contains(x.City));
                }

                if (!string.IsNullOrEmpty(memberCondition.JobTypeInclude))
                {
                    matchList = matchList.Where(x => memberCondition.JobTypeInclude.Contains(x.JobType));
                }

                if (!string.IsNullOrEmpty(memberCondition.ReligionInclude))
                {
                    matchList = matchList.Where(x => memberCondition.ReligionInclude.Contains(x.Religion));
                }

                return(await PageList <Member> .CreateAsync(matchList, parameter.PageNumber, parameter.PageSize));
            }
        }