Exemple #1
0
		public static SongTagUsage SongTagUsage(Song song, Tag tag, User vote = null) {
			
			var usage = new SongTagUsage(song, tag);
			song.Tags.Usages.Add(usage);
			usage.CreateVote(vote);
			return usage;

		}
Exemple #2
0
        /// <summary>
        /// Adds a tag to the song.
        /// First checks if the tag has already been added.
        /// </summary>
        /// <param name="tag">Tag to be added. Cannot be null.</param>
        /// <returns>The created tag usage. Can be null if the tag has already been added.</returns>
        public virtual CollectionAddResult <SongTagUsage> AddTag(Tag tag)
        {
            ParamIs.NotNull(() => tag);

            if (Tags.HasTag(tag))
            {
                return(CollectionAddResult.Create(Tags.GetTagUsage(tag), false));
            }

            var usage = new SongTagUsage(this, tag);

            Tags.Usages.Add(usage);
            return(CollectionAddResult.Create(usage, true));
        }
Exemple #3
0
        public override TagUsage Move(Tag target)
        {
            ParamIs.NotNull(() => target);

            if (target.Equals(Tag))
            {
                return(this);
            }

            // TODO: have to make a clone because of NH reparenting issues, see http://stackoverflow.com/questions/28114508/nhibernate-change-parent-deleted-object-would-be-re-saved-by-cascade
            Tag.AllSongTagUsages.Remove(this);
            Song.Tags.Usages.Remove(this);

            var newUsage = new SongTagUsage(Song, target);

            target.AllSongTagUsages.Add(newUsage);
            Song.Tags.Usages.Add(newUsage);

            return(newUsage);
        }
Exemple #4
0
 public SongTagVote(SongTagUsage usage, User user)
     : base(user)
 {
     Usage = usage;
 }
Exemple #5
0
 public SongTagVote(SongTagUsage usage, User user)
     : base(user)
 {
     Usage = usage;
 }
 public SongTagUsageContract(SongTagUsage tagUsage, ContentLanguagePreference languagePreference)
     : base(tagUsage)
 {
     Song = new SongWithAdditionalNamesContract(tagUsage.Song, languagePreference);
 }