public ActionResult GetMoviesStats() { try { var data = _statservice.GetDataStats(); if (data == null || !data.Any()) { return(NotFound()); } // I just assume that the needed Language is EN // if i will not filter it by languages, there will be a lot of movieIDs var meta_data = _metadataservice.GetMetaDataPerGroupbyMovieIdByEN(); List <MovieStatsVM> newdata = new List <MovieStatsVM>(); foreach (var data_stat in data.OrderBy(a => a.Watches)) { List <MovieStatsVM> new_metadata = meta_data.Where(a => a.MovieId == data_stat.MovieId) .Select(r => new MovieStatsVM { movieId = r.MovieId, title = r.Title, averageWatchDurationS = Math.Round(data_stat.averageWatchDurationS), Watches = data_stat.Watches, releaseYear = r.ReleaseYear }).ToList(); newdata.AddRange(new_metadata); } newdata = newdata.OrderBy(c => c.Watches).ThenByDescending(c => c.releaseYear).ToList(); return(Ok(newdata)); } catch (Exception ex) { throw ex; } }