Exemplo n.º 1
0
 public SongInfo(int id, string title, MediaType type, string genre, int price, System.DateTime releaseDate, string publisher, MediaRating rating, string artist, System.TimeSpan duration, int albumId)
     : base(id, title, type, genre, price, releaseDate, publisher, rating)
 {
     Artist = artist;
     Duration = duration;
     AlbumId = albumId;
 }
Exemplo n.º 2
0
 public MovieInfo(int id, string title, MediaType type, string genre, int price, System.DateTime releaseDate, string publisher, MediaRating rating, string director, System.TimeSpan duration, string summary)
     : base(id, title, type, genre, price, releaseDate, publisher, rating)
 {
     Director = director;
     Duration = duration;
     Summary = summary;
 }
Exemplo n.º 3
0
 /// <author>Kenneth Søhrmann</author>
 /// <summary>
 /// 
 /// </summary>
 /// <param name="databaseMedia"></param>
 /// <param name="rating"></param>
 /// <returns></returns>
 internal static MovieInfo ValueOf(RentItDatabase.Movie databaseMedia, MediaRating rating)
 {
     return new MovieInfo(
         databaseMedia.media_id,
         databaseMedia.Media.title,
         Util.MediaTypeOfValue(databaseMedia.Media.Media_type.name),
         databaseMedia.Media.Genre.name,
         databaseMedia.Media.price,
         databaseMedia.Media.release_date,
         databaseMedia.Media.Publisher.title,
         rating,
         databaseMedia.director,
         TimeSpan.FromSeconds(databaseMedia.length),
         databaseMedia.summary);
 }
Exemplo n.º 4
0
 /// <author>Kenneth Søhrmann</author>
 /// <summary>
 /// 
 /// </summary>
 /// <param name="databaseMedia"></param>
 /// <param name="rating"></param>
 /// <returns></returns>
 internal static BookInfo ValueOf(RentItDatabase.Book databaseMedia, MediaRating rating)
 {
     return new BookInfo(
         databaseMedia.media_id,
         databaseMedia.Media.title,
         Util.MediaTypeOfValue(databaseMedia.Media.Media_type.name),
         databaseMedia.Media.Genre.name,
         databaseMedia.Media.price,
         databaseMedia.Media.release_date,
         databaseMedia.Media.Publisher.title,
         rating,
         databaseMedia.author,
         databaseMedia.pages,
         databaseMedia.summary);
 }
Exemplo n.º 5
0
 protected MediaInfo(int id, string title, MediaType type, string genre, int price, System.DateTime releaseDate, string publisher, MediaRating rating)
 {
     Id = id;
     Title = title;
     Type = type;
     Genre = genre;
     Price = price;
     ReleaseDate = releaseDate;
     Publisher = publisher;
     Rating = rating;
 }
Exemplo n.º 6
0
 public BookInfo(int id, string title, MediaType type, string genre, int price, System.DateTime releaseDate, string publisher, MediaRating rating, string author, int pages, string summary)
     : base(id, title, type, genre, price, releaseDate, publisher, rating)
 {
     Author = author;
     Pages = pages;
     Summary = summary;
 }
Exemplo n.º 7
0
        /// <author>Kenneth Søhrmann</author>
        /// <summary>
        /// 
        /// </summary>
        /// <param name="databaseMedia"></param>
        /// <param name="albumSongs"></param>
        /// <param name="rating"></param>
        /// <returns></returns>
        internal static AlbumInfo ValueOf(RentItDatabase.Album databaseMedia, List<SongInfo> albumSongs, MediaRating rating)
        {
            int albumDuration = 0;

            foreach (RentItDatabase.Album_song song in databaseMedia.Album_songs)
            {
                albumDuration += song.Song.length;
            }

            return new AlbumInfo(
                databaseMedia.media_id,
                databaseMedia.Media.title,
                Util.MediaTypeOfValue(databaseMedia.Media.Media_type.name),
                databaseMedia.Media.Genre.name,
                databaseMedia.Media.price,
                databaseMedia.Media.release_date,
                databaseMedia.Media.Publisher.title,
                rating,
                databaseMedia.album_artist,
                System.TimeSpan.FromSeconds(albumDuration),
                databaseMedia.description,
                albumSongs);
        }
Exemplo n.º 8
0
 public AlbumInfo(int id, string title, MediaType type, string genre, int price, System.DateTime releaseDate, string publisher, MediaRating rating, string albumArtist, System.TimeSpan totalDuration, string description, System.Collections.Generic.List<SongInfo> songs)
     : base(id, title, type, genre, price, releaseDate, publisher, rating)
 {
     AlbumArtist = albumArtist;
     TotalDuration = totalDuration;
     Description = description;
     Songs = songs;
 }
Exemplo n.º 9
0
 /// <author>Kenneth Søhrmann</author>
 /// <summary>
 /// 
 /// </summary>
 /// <param name="databaseMedia"></param>
 /// <param name="rating"></param>
 /// <returns></returns>
 internal static SongInfo ValueOf(RentItDatabase.Song databaseMedia, MediaRating rating)
 {
     return new SongInfo(
         databaseMedia.media_id,
         databaseMedia.Media.title,
         Util.MediaTypeOfValue(databaseMedia.Media.Media_type.name),
         databaseMedia.Media.Genre.name,
         databaseMedia.Media.price,
         databaseMedia.Media.release_date,
         databaseMedia.Media.Publisher.title,
         rating,
         databaseMedia.artist,
         System.TimeSpan.FromSeconds((int)databaseMedia.length),
         databaseMedia.Album_songs.First().album_id);
 }
Exemplo n.º 10
0
        /// <author>Kenneth Søhrmann</author>
        /// <summary>
        /// Collects all the user reviews registered for the specified media item.
        /// </summary>
        /// <param name="mediaId">
        /// The id of the media item to collect reviews for.
        /// </param>
        /// <param name="rating">
        /// Value holding the review counts and the average rating.
        /// Used for building the return value of this method.
        /// </param>
        /// <param name="db">
        /// The database context to retrieve the data from.
        /// </param>
        /// <returns>
        /// A MediaRating-object holding all review data of the specified
        /// media item.
        /// </returns>
        public static RentIt.MediaRating CollectMediaReviews(
            int mediaId, RentItDatabase.Rating rating, DatabaseDataContext db)
        {
            // Get all the user reviews of the book.
            List<Review> reviews = (from r in db.Reviews where r.media_id.Equals(mediaId) select r).ToList();

            var mediaReviews = new List<MediaReview>();

            foreach (Review review in reviews)
            {
                mediaReviews.Add(
                    new MediaReview(
                        review.media_id,
                        review.user_name,
                        review.review1,
                        RatingOfValue(review.rating),
                        review.timestamp));
            }

            int rcount = rating == null ? 0 : rating.ratings_count;
            float rrate = (float)(rating == null ? 0.0 : rating.avg_rating);
            var mediaRating = new MediaRating(rcount, rrate, mediaReviews);

            return mediaRating;
        }