/// <summary>
        /// Makes a preview of a song.
        /// </summary>
        /// <param name="song">The song.</param>
        /// <returns></returns>
        public async Task <ISong> PreviewAsync(ISong song)
        {
            string songFileName = SongHelper.SongFileName(song);

            await SongHelper.CreatePdfAsync(song, SongHelper.Hash(songFileName), false);

            return(song);
        }
        /// <summary>
        /// Inserts a song.
        /// </summary>
        /// <param name="song">The song.</param>
        /// <returns></returns>
        public async Task <ISong> InsertAsync(ISong song)
        {
            await SongHelper.CreatePdfAsync(song, Path.GetRandomFileName(), true);

            SongEntity songEntity = Mapper.Map <SongEntity>(song);

            using (IUnitOfWork unitOfWork = Repository.CreateUnitOfWork())
            {
                foreach (int liturgy in song.LiturgyCategories)
                {
                    SongLiturgyEntity songLiturgy = new SongLiturgyEntity();
                    songLiturgy.SongId    = songEntity.Id;
                    songLiturgy.LiturgyId = liturgy;
                    await unitOfWork.InsertAsync <SongLiturgyEntity>(songLiturgy);
                }

                foreach (int theme in song.ThemeCategories)
                {
                    SongThemeEntity songTheme = new SongThemeEntity();
                    songTheme.SongId  = songEntity.Id;
                    songTheme.ThemeId = theme;
                    await unitOfWork.InsertAsync <SongThemeEntity>(songTheme);
                }

                if (song.Arranger != null)
                {
                    songEntity.Arranger   = null;
                    songEntity.ArrangerId = song.Arranger.Id;
                }

                if (song.Composer != null)
                {
                    songEntity.Composer   = null;
                    songEntity.ComposerId = song.Composer.Id;
                }

                songEntity = await unitOfWork.InsertAsync <SongEntity>(songEntity);

                await unitOfWork.CommitAsync();
            }

            return(Mapper.Map <ISong>(songEntity));
        }