Beispiel #1
0
 /// <summary>
 /// Gets all.
 /// </summary>
 /// <param name="userId">The user identifier.</param>
 /// <param name="groupType">Type of the group.</param>
 /// <param name="originLanguage">The origin language.</param>
 /// <param name="orderBy">order by game</param>
 /// <param name="page">The page.</param>
 /// <param name="pageSize">Size of the page.</param>
 /// <returns>
 /// the game
 /// </returns>
 public IPagedList <Game> GetAll(
     int?userId              = null,
     GroupType?groupType     = null,
     Language?originLanguage = null,
     OrderByGame orderBy     = OrderByGame.Newest,
     int page     = 0,
     int pageSize = int.MaxValue)
 {
     return(new PagedList <Game>(this.GetAllQuery(userId, groupType, originLanguage), page, pageSize));
 }
Beispiel #2
0
 /// <summary>
 /// Gets all asynchronous.
 /// </summary>
 /// <param name="userId">The user identifier.</param>
 /// <param name="groupType">Type of the group.</param>
 /// <param name="originLanguage">The origin language.</param>
 /// <param name="orderBy">order by game</param>
 /// <param name="page">The page.</param>
 /// <param name="pageSize">Size of the page.</param>
 /// <returns>
 /// the games
 /// </returns>
 public async Task <IPagedList <Game> > GetAllAsync(
     int?userId              = null,
     GroupType?groupType     = null,
     Language?originLanguage = null,
     OrderByGame orderBy     = OrderByGame.Newest,
     int page     = 0,
     int pageSize = int.MaxValue)
 {
     return(await new PagedList <Game>().Async(this.GetAllQuery(userId, groupType, originLanguage, orderBy), page, pageSize));
 }
Beispiel #3
0
        /// <summary>
        /// Gets all query.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <param name="groupType">Type of the group.</param>
        /// <param name="originLanguage">The origin language.</param>
        /// <param name="orderBy">The order by.</param>
        /// <returns>the query</returns>
        private IQueryable <Game> GetAllQuery(
            int?userId              = null,
            GroupType?groupType     = null,
            Language?originLanguage = null,
            OrderByGame orderBy     = OrderByGame.Newest)
        {
            var query = this.gameRepository.TableNoTracking;

            if (userId.HasValue)
            {
                query = query.Where(c => c.UserId == userId.Value);
            }

            if (groupType.HasValue)
            {
                query = query.Where(c => c.GroupId == Convert.ToInt16(groupType));
            }

            if (originLanguage.HasValue)
            {
                query = query.Where(c => c.OriginLanguage.Equals(originLanguage.ToString()));
            }

            switch (orderBy)
            {
            case OrderByGame.Newest:
                query = query.OrderByDescending(c => c.CreationDate);
                break;

            case OrderByGame.Top:
                query = query.OrderByDescending(c => c.Positives);
                break;

            default:
                query = query.OrderBy(c => c.Id);
                break;
            }

            return(query);
        }