public PerformerDetailsViewModel(Guid id) { PerformerViewModel = new PerformerVM(Performer.GetById(id)); Entertainment[] entertainmentByPerformer = Entertainment.GetEntertainmentByPerformer(PerformerViewModel.PerformerDL); if (entertainmentByPerformer != null) { AvarageCriticPoint = Entertainment.AverageCriticPointForEntertainments(entertainmentByPerformer); AvarageUserPoint = Entertainment.AverageUserPointForEntertainments(entertainmentByPerformer); } Awards = this.GetAwardByPerfomer(); EntertainmentVMs = this.GetEntertainmentVMByPerformer(); Movies = Array.FindAll(EntertainmentVMs, (ent) => ent.EntertainmentType == Entertainment.Type.Movie).ToArray(); Games = Array.FindAll(EntertainmentVMs, (ent) => ent.EntertainmentType == Entertainment.Type.Game).ToArray(); TVSeries = Array.FindAll(EntertainmentVMs, (ent) => ent.EntertainmentType == Entertainment.Type.TVSeries).ToArray(); Albums = Array.FindAll(EntertainmentVMs, (ent) => ent.EntertainmentType == Entertainment.Type.Album).ToArray(); MoviesByDate = Movies.OrderByDescending((ent) => ent.ReleaseDate).ToArray(); GamesByDate = Games.OrderByDescending((ent) => ent.ReleaseDate).ToArray(); TVSeriesByDate = TVSeries.OrderByDescending((ent) => ent.ReleaseDate).ToArray(); AlbumsByDate = Albums.OrderByDescending((ent) => ent.ReleaseDate).ToArray(); MoviesByCriticPoint = Movies.OrderByDescending((ent) => ent.EntertainmentDL.AverageCriticPointForOneEntertainment()).ToArray(); GamesByCriticPoint = Games.OrderByDescending((ent) => ent.EntertainmentDL.AverageCriticPointForOneEntertainment()).ToArray(); TVSeriesByCriticPoint = TVSeries.OrderByDescending((ent) => ent.EntertainmentDL.AverageCriticPointForOneEntertainment()).ToArray(); AlbumsByCriticPoint = Albums.OrderByDescending((ent) => ent.EntertainmentDL.AverageCriticPointForOneEntertainment()).ToArray(); MoviesByUserPoint = Movies.OrderByDescending((ent) => ent.EntertainmentDL.AverageUserPointForOneEntertainment()).ToArray(); GamesByUserPoint = Games.OrderByDescending((ent) => ent.EntertainmentDL.AverageUserPointForOneEntertainment()).ToArray(); TVSeriesByUserPoint = TVSeries.OrderByDescending((ent) => ent.EntertainmentDL.AverageUserPointForOneEntertainment()).ToArray(); AlbumsByUserPoint = Albums.OrderByDescending((ent) => ent.EntertainmentDL.AverageUserPointForOneEntertainment()).ToArray(); }
public PerformerMiniViewModel(PerformerVM performer, PerformerInEntertainment.Role role) { _performer = performer; Role = role; Entertainment[] entertainmentByPerformer = Entertainment.GetEntertainmentByPerformer(performer.PerformerDL); if (entertainmentByPerformer != null) { AvaragePerformerPoint = Entertainment.AverageCriticPointForEntertainments(entertainmentByPerformer); } if (role == PerformerInEntertainment.Role.MovieCast) { Entertainment[] lastThreeActorsEntertainments = Entertainment.GetLastThreeEntertainmentByActor(performer.PerformerDL); if (lastThreeActorsEntertainments != null) { List <EntertainmentVM> result = new List <EntertainmentVM>(); foreach (var entertainment in lastThreeActorsEntertainments) { result.Add(new EntertainmentVM(entertainment)); } LastThreePerformersEntertainments = result.ToArray(); } } if (role == PerformerInEntertainment.Role.AlbumSinger) { Entertainment[] lastThreeActorsEntertainments = Entertainment.GetLastThreeEntertainmentBySinger(performer.PerformerDL); if (lastThreeActorsEntertainments != null) { List <EntertainmentVM> result = new List <EntertainmentVM>(); foreach (var entertainment in lastThreeActorsEntertainments) { result.Add(new EntertainmentVM(entertainment)); } LastThreePerformersEntertainments = result.ToArray(); } } }
public PerformerVM[] GetLastTwoActors() { List <Performer> allActors = new List <Performer>(); if (_lastBestMovies == null) { return(null); } foreach (var entertainment in _lastBestMovies) { Performer[] allEntertainmentsActors = Performer.GetActorByEntertainment(entertainment.EntertainmentDL); if (allEntertainmentsActors != null) { foreach (var actor in allEntertainmentsActors) { if (allActors.FindAll((act) => act.Id == actor.Id).Count == 0) { allActors.Add(actor); } } } if (allActors.Count == 0) { return(null); } } Performer[] twoPerformers = allActors.OrderByDescending(actor => Entertainment.AverageCriticPointForEntertainments(Entertainment.GetEntertainmentByPerformer(actor))).Take(2).ToArray(); List <PerformerVM> result = new List <PerformerVM>(); foreach (var performer in twoPerformers) { result.Add(new PerformerVM(performer)); } return(result.ToArray()); }
public PerformerVM[] GetLastTwoSingers() { List <Performer> allSingers = new List <Performer>(); if (_lastBestAlbums == null) { return(null); } foreach (var entertainment in _lastBestAlbums) { Performer[] allEntertainmentsSingers = Performer.GetSingerByEntertainment(entertainment.EntertainmentDL); if (allEntertainmentsSingers != null) { foreach (var singer in allEntertainmentsSingers) { if (allSingers.FindAll((sing) => sing.Id == singer.Id).Count == 0) { allSingers.Add(singer); } } } if (allSingers.Count == 0) { return(null); } } Performer[] twoPerformers = allSingers.OrderByDescending(singer => Entertainment.AverageCriticPointForEntertainments(Entertainment.GetEntertainmentByPerformer(singer))).Take(2).ToArray(); List <PerformerVM> result = new List <PerformerVM>(); foreach (var performer in twoPerformers) { result.Add(new PerformerVM(performer)); } return(result.ToArray()); }