Example #1
0
        public static Review[] GetReviewByEntertainment(Entertainment entertainment)
        {
            lock (_locker)
            {
                List <Review> result = new List <Review>();

                _dataAdapter.SelectCommand.CommandText = "SELECT * FROM " + _tableName + " WHERE EntertainmentId=@id";

                if (!_dataAdapter.SelectCommand.Parameters.Contains("@id"))
                {
                    _dataAdapter.SelectCommand.Parameters.Add(new SqlParameter("@id", entertainment.Id));
                }
                else
                {
                    _dataAdapter.SelectCommand.Parameters["@id"].Value = entertainment.Id;
                }

                _dataAdapter.Fill(_dataTable);
                var selectedRows = from row in _dataTable.AsEnumerable().AsParallel()
                                   where (Guid)row["EntertainmentId"] == entertainment.Id
                                   select row;
                foreach (DataRow dr in selectedRows)
                {
                    result.Add(new Review(dr));
                }

                if (result.Count != 0)
                {
                    return(result.ToArray());
                }
                return(null);
            }
        }
Example #2
0
        public static Performer[] GetSingerByEntertainment(Entertainment entertainment)
        {
            lock (_locker)
            {
                _dataAdapter.SelectCommand.CommandText = "SELECT Performer." + _idColumnName + " FROM " + _tableName + ",PerformerInEntertainment WHERE PerformerInEntertainment.EntertainmentId=@id AND PerformerInEntertainment." + _idColumnName + "=Performer." + _idColumnName + " AND PerformerInEntertainment.PerformerRole='AlbumSinger'";

                if (!_dataAdapter.SelectCommand.Parameters.Contains("@id"))
                {
                    _dataAdapter.SelectCommand.Parameters.Add(new SqlParameter("@id", entertainment.Id));
                }
                else
                {
                    _dataAdapter.SelectCommand.Parameters["@id"].Value = entertainment.Id;
                }

                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]);
                }

                return(Performer.GetByIds(ids.ToArray()));
            }
        }
Example #3
0
 public Review(UserCritic userCritic, Entertainment entertainment, byte point, string opinion, DateTimeOffset time,
               string link, string publication, int helpful, int unhelpful, bool checkedByAdmin) : base()
 {
     UserId          = userCritic.Id;
     EntertainmentId = entertainment.Id;
     Point           = point;
     Opinion         = opinion;
     Time            = time;
     Link            = link;
     Publication     = publication;
     Helpful         = helpful;
     Unhelpful       = unhelpful;
     CheckedByAdmin  = checkedByAdmin;
 }
Example #4
0
        public static Genre[] GetGenreByEntertainment(Entertainment entertainment)
        {
            GenreInEntertainment[] genreInEntertainments = GenreInEntertainment.GetGenreInEntertainmentByEntertainment(entertainment);
            if (genreInEntertainments == null)
            {
                return(null);
            }
            List <Guid> ids = new List <Guid>();

            foreach (var genreInEntertainment in genreInEntertainments)
            {
                ids.Add(genreInEntertainment.GenreId);
            }
            return(Genre.GetByIds(ids.ToArray()));
        }
Example #5
0
        public static Performer[] GetPerformerByEntertainmentAndRole(Entertainment entertainment, PerformerInEntertainment.Role role)
        {
            PerformerInEntertainment[] performerInEntertainments = PerformerInEntertainment.GetPerformerInEntertainmentByEntertainmentAndRole(entertainment, role);
            if (performerInEntertainments == null)
            {
                return(null);
            }
            List <Guid> ids = new List <Guid>();

            foreach (var performerInEntertainment in performerInEntertainments)
            {
                ids.Add(performerInEntertainment.PerformerId);
            }
            return(Performer.GetByIds(ids.ToArray()));
        }
Example #6
0
        public static Review GetReviewByEntertainmentAndUser(Entertainment entertainment, UserCritic user)
        {
            lock (_locker)
            {
                var query = from row in _dataTable.AsEnumerable().AsParallel()
                            where (Guid)row["EntertainmentId"] == entertainment.Id && (Guid)row["UserId"] == user.Id
                            select row;
                DataRow[] result = query.ToArray();
                if (result.Length == 1)
                {
                    return(new Review(result[0]));
                }
                else
                {
                    _dataAdapter.SelectCommand.CommandText = "SELECT * FROM " + _tableName + " WHERE EntertainmentId=@entertainmentId AND UserId=@userId;";

                    if (!_dataAdapter.SelectCommand.Parameters.Contains("@entertainmentId"))
                    {
                        _dataAdapter.SelectCommand.Parameters.Add(new SqlParameter("@entertainmentId", entertainment.Id));
                    }
                    else
                    {
                        _dataAdapter.SelectCommand.Parameters["@entertainmentId"].Value = entertainment.Id;
                    }
                    if (!_dataAdapter.SelectCommand.Parameters.Contains("@userId"))
                    {
                        _dataAdapter.SelectCommand.Parameters.Add(new SqlParameter("@userId", user.Id));
                    }
                    else
                    {
                        _dataAdapter.SelectCommand.Parameters["@userId"].Value = user.Id;
                    }

                    if (_dataAdapter.Fill(_dataTable) == 1)
                    {
                        var selectedRow = from row in _dataTable.AsEnumerable().AsParallel()
                                          where (Guid)row["EntertainmentId"] == entertainment.Id && (Guid)row["UserId"] == user.Id
                                          select row;
                        return(new Review(selectedRow.ToArray()[0]));
                    }
                    return(null);
                }
            }
        }
Example #7
0
        public static Song[] GetSongsByAlbum(Entertainment album)
        {
            lock (_locker)
            {
                if (album.EntertainmentType != Entertainment.Type.Album)
                {
                    return(null);
                }

                _dataAdapter.SelectCommand.CommandText = "SELECT " + _tableName + "." + _idColumnName + ", Name, Duration, Lyrics FROM " + _tableName + ", " + SongInEntertainment._tableName + " WHERE EntertainmentId=@id AND " + _tableName + "." + _idColumnName + "=" + SongInEntertainment._tableName + "." + _idColumnName;

                if (!_dataAdapter.SelectCommand.Parameters.Contains("@id"))
                {
                    _dataAdapter.SelectCommand.Parameters.Add(new SqlParameter("@id", album.Id));
                }
                else
                {
                    _dataAdapter.SelectCommand.Parameters["@id"].Value = album.Id;
                }

                DataTable dataTable = new DataTable();
                if (_dataAdapter.Fill(dataTable) > 0)
                {
                    List <Song> result = new List <Song>();
                    _dataAdapter.Fill(_dataTable);

                    var ids = from row in dataTable.AsEnumerable().AsParallel()
                              select(Guid) row[_idColumnName];

                    var selectedRows = from row in _dataTable.AsEnumerable().AsParallel()
                                       where ids.Contains((Guid)row[_idColumnName])
                                       select row;

                    foreach (DataRow dr in selectedRows)
                    {
                        result.Add(new Song(dr));
                    }
                    return(result.ToArray());
                }
                return(null);
            }
        }
Example #8
0
        public static Performer[] GetAlbumAuthorsByAlbum(Entertainment entertainment)
        {
            lock (_locker)
            {
                if (entertainment.EntertainmentType != Entertainment.Type.Album)
                {
                    return(null);
                }

                PerformerInEntertainment[] performerInEntertainments = PerformerInEntertainment.GetAlbumAuthorsPerformerInEntertainmentsByEntertainment(entertainment);
                if (performerInEntertainments == null)
                {
                    return(null);
                }
                List <Guid> ids = new List <Guid>();
                foreach (var performerInEntertainment in performerInEntertainments)
                {
                    ids.Add(performerInEntertainment.PerformerId);
                }

                return(Performer.GetByIds(ids.ToArray()));
            }
        }
Example #9
0
 public Award(Performer performer, Entertainment entertainment, string name, string nomination, DateTime date,
              byte[] image) : base()
 {
     if (performer == null)
     {
         PerformerId = default(Guid?);
     }
     else
     {
         PerformerId = performer.Id;
     }
     if (entertainment == null)
     {
         EntertainmentId = default(Guid?);
     }
     else
     {
         EntertainmentId = entertainment.Id;
     }
     Name       = name;
     Nomination = nomination;
     Date       = date;
     Image      = image;
 }
Example #10
0
        public static PerformerInEntertainment[] GetAlbumAuthorsPerformerInEntertainmentsByEntertainment(Entertainment entertainment)
        {
            lock (_locker)
            {
                List <PerformerInEntertainment> result = new List <PerformerInEntertainment>();

                _dataAdapter.SelectCommand.CommandText = "SELECT * FROM " + _tableName + " WHERE EntertainmentId=@id AND (PerformerRole='AlbumBand' OR PerformerRole='AlbumSinger')";

                if (!_dataAdapter.SelectCommand.Parameters.Contains("@id"))
                {
                    _dataAdapter.SelectCommand.Parameters.Add(new SqlParameter("@id", entertainment.Id));
                }
                else
                {
                    _dataAdapter.SelectCommand.Parameters["@id"].Value = entertainment.Id;
                }

                _dataAdapter.Fill(_dataTable);
                var selectedRows = from row in _dataTable.AsEnumerable().AsParallel()
                                   where ((Guid)row["EntertainmentId"] == entertainment.Id) &&
                                   (((PerformerInEntertainment.Role)Enum.Parse(typeof(PerformerInEntertainment.Role), row["PerformerRole"].ToString()) == PerformerInEntertainment.Role.AlbumSinger) ||
                                    ((PerformerInEntertainment.Role)Enum.Parse(typeof(PerformerInEntertainment.Role), row["PerformerRole"].ToString()) == PerformerInEntertainment.Role.AlbumBand))
                                   select row;
                foreach (DataRow dr in selectedRows)
                {
                    result.Add(new PerformerInEntertainment(dr));
                }
                if (result.Count != 0)
                {
                    return(result.ToArray());
                }
                return(null);
            }
        }
Example #11
0
 public PerformerInEntertainment(Performer performer, Entertainment entertainment, PerformerInEntertainment.Role performerRole) : base()
 {
     PerformerId     = performer.Id;
     EntertainmentId = entertainment.Id;
     PerformerRole   = performerRole;
 }
Example #12
0
 public SongInEntertainment(Song song, Entertainment entertainment) : base()
 {
     SongId          = song.Id;
     EntertainmentId = entertainment.Id;
 }
 public GenreInEntertainment(Entertainment entertainment, Genre genre) : base()
 {
     EntertainmentId = entertainment.Id;
     GenreId         = genre.Id;
 }