public List <JinderSeeker> Get(String Username, [FromUri] int count, int dummy = 0)
        {
            JinderDBConnection dbContext = new JinderDBConnection();
            var usersTable = dbContext.JinderUsers;

            JinderUser jinderUser = (from user in usersTable
                                     where user.Username == Username
                                     select user).FirstOrDefault <JinderUser>();

            if (jinderUser.UserType != "poster")
            {
                throw new Exception("JinderUser with username: "******" is not a poster!");
            }

            var viewedSeekerIds = from log in dbContext.PosterExpressionLogs
                                  where log.PosterId == jinderUser.JinderUserId
                                  select log.SeekerId;


            var notViewedSeekers = (from seeker in dbContext.JinderUsers
                                    where seeker.UserType == "seeker" &&
                                    !viewedSeekerIds.Contains <int>(seeker.JinderUserId)
                                    select seeker).Take <JinderUser>(count);

            List <JinderSeeker> jinderSeekers = new List <JinderSeeker>();

            foreach (JinderUser seeker in notViewedSeekers)
            {
                jinderSeekers.Add(JinderSeeker.getJinderSeeker(seeker));
            }

            return(jinderSeekers);
        }
示例#2
0
        public List <JinderSeeker> GetSeekers(String Username, [FromUri] int count)
        {
            JinderDBEntities dbContext = new JinderDBEntities();
            var usersTable             = dbContext.JinderUsers;

            JinderUser jinderuser = (from user in usersTable
                                     where user.username == Username
                                     select user).FirstOrDefault <JinderUser>();

            if (jinderuser.UserType != "poster")
            {
                throw new Exception(" JinderUser with username: "******" is not a poster");
            }

            var viewedSeekers = from log in dbContext.ExpressionLogs
                                where log.SourceUserId == jinderuser.JinderUserId
                                select log.TargetUserId;

            //var viewedIds = viewedSeekers.ToList();

            var notViewedSeekers = (from seeker in usersTable
                                    where seeker.UserType == "seeker" && !viewedSeekers.Contains(seeker.JinderUserId)
                                    select seeker).Take <JinderUser>(count);

            List <JinderSeeker> jinderSeekers = new List <JinderSeeker>();

            foreach (JinderUser seeker in notViewedSeekers)
            {
                JinderSeeker js = new JinderSeeker();
                js.username = seeker.username;
                jinderSeekers.Add(js);
            }
            return(jinderSeekers);
        }