Exemplo n.º 1
0
        public JsonResult GetUserPostStats([FromBody] CommunitySearchResults result)
        {
            var popularPosts    = _context.Posts.Where(n => n.GameId == result.gameId && string.IsNullOrEmpty(n.ImageUri)).OrderByDescending(n => n.EmpathyCount).Take(4).ToList();
            var popularDrawings = _context.Posts.Where(n => n.GameId == result.gameId && !string.IsNullOrEmpty(n.ImageUri)).OrderByDescending(n => n.EmpathyCount).Take(4).ToList();

            popularPosts.AddRange(popularDrawings);
            return(Json(new UserPostMetadata()
            {
                popularPosts = popularPosts
            }));
        }
Exemplo n.º 2
0
        public PagedResult <Game> GetCommunitySearchResults([FromBody] CommunitySearchResults result)
        {
            // var test = JsonConvert.DeserializeObject<PagedResult<Game>>(TestOutput.CommunityString);
            // return test;
            IQueryable <Game> query;

            query = _context.Games.Where(n => n.GameId != "0");

            if (!string.IsNullOrEmpty(result.title))
            {
                query = query.Where(n => n.Title.Contains(result.title));
            }

            if (!string.IsNullOrEmpty(result.type))
            {
                query = query.Where(n => n.Title.Contains(result.type));
            }

            if (!string.IsNullOrEmpty(result.titleId))
            {
                query = query.Where(n => n.TitleId == result.titleId);
            }

            if (!string.IsNullOrEmpty(result.gameId))
            {
                query = query.Where(n => n.TitleId == result.gameId);
            }

            if (result.searchAmerica)
            {
                query = query.Where(n => n.ViewRegion == ViewRegion.America);
            }

            if (result.searchEurope)
            {
                query = query.Where(n => n.ViewRegion == ViewRegion.Europe);
            }

            if (result.searchJapan)
            {
                query = query.Where(n => n.ViewRegion == ViewRegion.Japan);
            }

            if (result.searchWorld)
            {
                query = query.Where(n => n.ViewRegion == ViewRegion.World);
            }

            if (result.sortPosts != SortPosts.None)
            {
                if (result.sortPosts == SortPosts.Most)
                {
                    query = query.OrderByDescending(n => n.TotalPosts);
                }

                if (result.sortPosts == SortPosts.Least)
                {
                    query = query.OrderBy(n => n.TotalPosts);
                }
            }
            else if (result.sortReplies != SortPosts.None)
            {
                if (result.sortReplies == SortPosts.Most)
                {
                    query = query.OrderByDescending(n => n.TotalReplies);
                }

                if (result.sortReplies == SortPosts.Least)
                {
                    query = query.OrderBy(n => n.TotalReplies);
                }
            }
            else if (result.sortDeletedPosts != SortPosts.None)
            {
                if (result.sortDeletedPosts == SortPosts.Most)
                {
                    query = query.OrderByDescending(n => n.TotalDeletedPosts);
                }

                if (result.sortDeletedPosts == SortPosts.Least)
                {
                    query = query.OrderBy(n => n.TotalDeletedPosts);
                }
            }
            else
            {
                if (result.sortTitle == SortTitle.Ascending)
                {
                    query = query.OrderBy(n => n.Title);
                }

                if (result.sortTitle == SortTitle.Descending)
                {
                    query = query.OrderByDescending(n => n.Title);
                }
            }
            var community = query.GetPaged(result.page, 50);

            return(community);
        }
Exemplo n.º 3
0
 public JsonResult GetGame([FromBody] CommunitySearchResults result)
 {
     return(Json(_context.Games.FirstOrDefault(n => n.GameId == result.gameId)));
 }
Exemplo n.º 4
0
 public JsonResult GetRelatedGames([FromBody] CommunitySearchResults result)
 {
     return(Json(_context.Games.Where(n => n.TitleId == result.titleId && n.GameId != result.gameId).ToList()));
 }