Exemple #1
0
        private static void WriteReviews(RecordingDto recordingDto, RecordingDataSet.Recording recording)
        {
            recordingDto.reviews = new ReviewDto[recording.GetReviews().Length];
            int index = 0;

            foreach (RecordingDataSet.Review review in recording.GetReviews())
            {
                recordingDto.reviews[index++] = WriteReview(review);
            }
        }
Exemple #2
0
        private static void WriteTotalRuntime(RecordingDto dto, RecordingDataSet.Recording recording)
        {
            int runTime = 0;

            foreach (RecordingDataSet.Track track in recording.GetTracks())
            {
                runTime += track.Duration;
            }

            dto.totalRunTime = runTime;
        }
Exemple #3
0
        WriteTracks(RecordingDto recordingDto,
                    RecordingDataSet.Recording recording)
        {
            recordingDto.tracks = new TrackDto[recording.GetTracks().Length];

            int index = 0;

            foreach (RecordingDataSet.Track track in recording.GetTracks())
            {
                recordingDto.tracks[index++] = WriteTrack(track);
            }
        }
Exemple #4
0
 private static void WriteAverageRating(RecordingDto recordingDto, RecordingDataSet.Recording recording)
 {
     if (recording.GetReviews().Length == 0)
     {
         recordingDto.averageRating = 0;
     }
     else
     {
         int totalRating = 0;
         foreach (RecordingDataSet.Review review in recording.GetReviews())
         {
             totalRating += review.Rating;
         }
         recordingDto.averageRating = totalRating / recording.GetReviews().Length;
     }
 }
Exemple #5
0
        WriteDto(RecordingDataSet.Recording recording)
        {
            RecordingDto dto = new RecordingDto();

            dto.id          = recording.Id;
            dto.title       = recording.Title;
            dto.releaseDate = recording.ReleaseDate.ToShortDateString();
            dto.artistName  = recording.Artist.Name;
            dto.labelName   = recording.Label.Name;

            WriteTracks(dto, recording);
            WriteTotalRuntime(dto, recording);

            WriteReviews(dto, recording);
            WriteAverageRating(dto, recording);

            return(dto);
        }