public static Entertainment[] GetLastNEntertainmentByTypeAndReviewCount(Entertainment.Type type, uint N, uint reviewCount) { lock (_locker) { _dataAdapter.SelectCommand.CommandText = "SELECT TOP(" + N + ") Entertainment." + _idColumnName + ", Entertainment.ReleaseDate FROM " + _tableName + ",Review WHERE Review." + _idColumnName + "=Entertainment." + _idColumnName + " AND Review.Publication IS NOT NULL AND EntertainmentType=@type GROUP BY Entertainment." + _idColumnName + ", Entertainment.ReleaseDate HAVING COUNT(Review.ReviewId)>=" + reviewCount + " ORDER BY Entertainment.ReleaseDate DESC"; if (!_dataAdapter.SelectCommand.Parameters.Contains("@type")) { _dataAdapter.SelectCommand.Parameters.Add(new SqlParameter("@type", type.ToString())); } else { _dataAdapter.SelectCommand.Parameters["@type"].Value = type.ToString(); } DataTable dataTable = new DataTable(); if (_dataAdapter.Fill(dataTable) == 0) { return(null); } List <Guid> ids = new List <Guid>(); foreach (DataRow dataRow in dataTable.Rows) { ids.Add((Guid)dataRow[_idColumnName]); } List <Entertainment> result = new List <Entertainment>(); result.AddRange(Entertainment.GetByIds(ids.ToArray())); return(result.OrderByDescending(entertainment => entertainment.ReleaseDate).ToArray()); } }
public static Entertainment GetOneTopEntertainmentByTypeAndReviewCount(Entertainment.Type type, uint reviewCount) { lock (_locker) { _dataAdapter.SelectCommand.CommandText = "SELECT Entertainment." + _idColumnName + " FROM " + _tableName + ",Review WHERE Review." + _idColumnName + "=Entertainment." + _idColumnName + " AND Review.Publication IS NOT NULL AND EntertainmentType=@type GROUP BY Entertainment." + _idColumnName + " HAVING COUNT(Review.ReviewId)>=" + reviewCount + "ORDER BY AVG(Review.Point) DESC"; if (!_dataAdapter.SelectCommand.Parameters.Contains("@type")) { _dataAdapter.SelectCommand.Parameters.Add(new SqlParameter("@type", type.ToString())); } else { _dataAdapter.SelectCommand.Parameters["@type"].Value = type.ToString(); } DataTable dataTable = new DataTable(); if (_dataAdapter.Fill(dataTable) == 0) { return(null); } DataRow[] row = dataTable.AsEnumerable().Take(1).ToArray(); return(Entertainment.GetById((Guid)row[0][_idColumnName])); } }
public EntertainmentVM(Entertainment.Type entertainmentType, string name, DateTime releaseDate, string company, byte[] poster, string summary, string buyLink, string mainLanguage, string rating, string ratingComment, int?movieRuntimeMinute, string officialSite, string movieCountries, byte?tVSeason, decimal?budget, string trailerLink) { _entertainment = new Entertainment(entertainmentType, name, releaseDate, company, poster, summary, buyLink, mainLanguage, rating, ratingComment, movieRuntimeMinute, officialSite, movieCountries, tVSeason, budget, trailerLink); this.AuthorsUpdate(); }
public GenreVM(GenreVM parentGenre, string name, Entertainment.Type genreType, string summary) { if (parentGenre != null) { _genre = new Genre(parentGenre.GenreDL, name, genreType, summary); } else { _genre = new Genre(null, name, genreType, summary); } }
public static Genre[] GetByNameExceptId(string partOfName, Entertainment.Type type, Guid id) { lock (_locker) { List <Genre> result = new List <Genre>(); partOfName = partOfName.ToLower(); _dataAdapter.SelectCommand.CommandText = "SELECT * FROM " + _tableName + " WHERE LOWER(" + _nameColumnName + ") LIKE '%' + @partOfName + '%' AND GenreType=@type AND " + _idColumnName + "!=@id"; if (!_dataAdapter.SelectCommand.Parameters.Contains("@partOfName")) { _dataAdapter.SelectCommand.Parameters.Add(new SqlParameter("@partOfName", partOfName)); } else { _dataAdapter.SelectCommand.Parameters["@partOfName"].Value = partOfName; } if (!_dataAdapter.SelectCommand.Parameters.Contains("@type")) { _dataAdapter.SelectCommand.Parameters.Add(new SqlParameter("@type", type.ToString())); } else { _dataAdapter.SelectCommand.Parameters["@type"].Value = type.ToString(); } if (!_dataAdapter.SelectCommand.Parameters.Contains("@id")) { _dataAdapter.SelectCommand.Parameters.Add(new SqlParameter("@id", id)); } else { _dataAdapter.SelectCommand.Parameters["@id"].Value = id; } _dataAdapter.Fill(_dataTable); var selectedRows = from row in _dataTable.AsEnumerable().AsParallel() where ((Entertainment.Type)Enum.Parse(typeof(Entertainment.Type), row["GenreType"].ToString()) == type) && (row[_nameColumnName].ToString().ToLower().Contains(partOfName)) && ((Guid)row[_idColumnName] != id) select row; foreach (DataRow dr in selectedRows) { result.Add(new Genre(dr)); } if (result.Count != 0) { return(result.ToArray()); } return(null); } }
public GenreVM(GenreVM parentGenre, string name, Entertainment.Type genreType, string summary) { if (parentGenre != null) { _genre = new Genre(parentGenre.GenreDL, name, genreType, summary); } else { _genre = new Genre(null, name, genreType, summary); } Logger.Info("GenreVM.GenreVM", "Екземпляр GenreVM створений."); }
public Genre(Genre parentGenre, string name, Entertainment.Type genreType, string summary) : base() { if (parentGenre == null) { ParentGenreId = default(Guid?); } else { ParentGenreId = parentGenre.Id; } Name = name; GenreType = genreType; Summary = summary; }
public EntertainmentVM[] GetLastBestEntertainment(Entertainment.Type type) { List <EntertainmentVM> result = new List <EntertainmentVM>(); Entertainment[] lastNEntertainmentByTypeAndReviewCount = Entertainment.GetLastNEntertainmentByTypeAndReviewCount(type, 4, _reviewCountForDisplayOnTop); if (lastNEntertainmentByTypeAndReviewCount == null) { return(null); } foreach (Entertainment entertainment in lastNEntertainmentByTypeAndReviewCount) { result.Add(new EntertainmentVM(entertainment)); } return(result.OrderByDescending(ent => ent.EntertainmentDL.AverageCriticPointForOneEntertainment()).ToArray()); }
public static string EntertainmentTypeToUkrString(Entertainment.Type type) { switch (type) { case Entertainment.Type.Movie: return("Фільм"); case Entertainment.Type.Game: return("Гра"); case Entertainment.Type.TVSeries: return("Серіал"); case Entertainment.Type.Album: return("Музика"); default: return(""); } }
public Entertainment(Entertainment.Type entertainmentType, string name, DateTime releaseDate, string company, byte[] poster, string summary, string buyLink, string mainLanguage, string rating, string ratingComment, int?movieRuntimeMinute, string officialSite, string movieCountries, byte?tVSeason, decimal?budget, string trailerLink) : base() { EntertainmentType = entertainmentType; Name = name; ReleaseDate = releaseDate; Company = company; Poster = poster; Summary = summary; BuyLink = buyLink; MainLanguage = mainLanguage; Rating = rating; RatingComment = ratingComment; MovieRuntimeMinute = movieRuntimeMinute; OfficialSite = officialSite; MovieCountries = movieCountries; TVSeason = tVSeason; Budget = budget; TrailerLink = trailerLink; }