Example #1
0
        public override List <Model.Favorites> Get(FavoritesSearchRequest search)
        {
            var query = _context.Favorites.AsQueryable();

            if (search.UserId > 0)
            {
                query = query.Where(w => w.UserId == search.UserId);
            }

            if (search.VehicleId > 0)
            {
                query = query.Where(w => w.VehicleId == search.VehicleId);
            }

            return(_mapper.Map <List <Model.Favorites> >(query.ToList()));
        }
Example #2
0
        public List <Model.Favorites> Get(FavoritesSearchRequest request)
        {
            var query = _context.Favorites.AsQueryable();

            if (request?.NotationId != 0)
            {
                query = query.Where(x => x.NotationId == request.NotationId);
            }

            query = query.Where(x => x.UserId == _usersService.GetCurrentUser().Id);

            query = query.Include(x => x.Notation.User);
            query = query.Include(x => x.Notation.Song.Artist);
            query = query.Include(x => x.Notation.Song.Album);
            query = query.Include(x => x.Notation.Song.Genre);

            var list = query.ToList();

            return(_mapper.Map <List <Model.Favorites> >(list));
        }