Exemple #1
0
        public async Task <int> Count(FullBodyClassifications classifications, bool?recentImagesOnly)
        {
            var data    = GetQueryable(classifications, recentImagesOnly);
            var results = await data.CountAsync();

            return(results);
        }
Exemple #2
0
        private IMongoQueryable <FullBodyReference> GetQueryable(FullBodyClassifications classifications, bool?recentImagesOnly)
        {
            var query = _collection.AsQueryable();

            if (classifications.Clothing.HasValue)
            {
                query = query.Where(x => x.Classifications.Clothing.Value == classifications.Clothing);
            }
            if (classifications.Gender.HasValue)
            {
                query = query.Where(x => x.Classifications.Gender == classifications.Gender);
            }
            if (classifications.NSFW.HasValue)
            {
                query = query.Where(x => x.Classifications.NSFW.Value);
            }
            if (classifications.PoseType.HasValue)
            {
                query = query.Where(x => x.Classifications.PoseType == classifications.PoseType);
            }
            if (classifications.ViewAngle.HasValue)
            {
                query = query.Where(x => x.Classifications.ViewAngle == classifications.ViewAngle);
            }
            if (recentImagesOnly == true)
            {
                // get the most recent upload, then include anything within 30 days of that
            }

            query = query.Where(x => x.Status == Status.Active);

            return(query);
        }
Exemple #3
0
        public async Task <FullBodyReference> Get(FullBodyClassifications classifications, List <string> excludeIds, bool?recentImagesOnly)
        {
            var data = GetQueryable(classifications, recentImagesOnly);

            data = data.Where(x => !excludeIds.Contains(x.Id));
            var recordCount = await data.CountAsync();

            if (recordCount == 0)
            {
                return(null);
            }

            var random = RandomGenerator.Next(0, recordCount);

            var result = data.Skip(random).First();

            return(result);
        }