public List <GetMapListVm> GetList(string sort = null, int?gameId = null) { var query = ((gameId.HasValue) ? _mapRepository.GetAll(PlayerId, gameId) : _mapRepository.GetAll(PlayerId)) .Select(x => new GetMapListVm() { Id = x.Id, Name = x.Name }); if (sort == "id") { query = query.OrderBy(x => x.Id); } else if (sort == "name") { query = query.OrderBy(x => x.Name); } return(query.ToList()); }