Exemplo n.º 1
0
        public static ArchivedAlbumContract GetAllProperties(ArchivedAlbumVersion version)
        {
            var data        = new ArchivedAlbumContract();
            var xmlCache    = new XmlCache <ArchivedAlbumContract>();
            var thisVersion = xmlCache.Deserialize(version.Version, version.Data);

            data.DiscType        = thisVersion.DiscType;
            data.Id              = thisVersion.Id;
            data.MainPictureMime = thisVersion.MainPictureMime;
            data.TranslatedName  = thisVersion.TranslatedName;

            DoIfExists(version, AlbumEditableFields.Artists, xmlCache, (v, doc) => SetArtists(data, v, doc));
            DoIfExists(version, AlbumEditableFields.Description, xmlCache, v => {
                data.Description    = v.Description;
                data.DescriptionEng = v.DescriptionEng;
            });
            DoIfExists(version, AlbumEditableFields.Identifiers, xmlCache, v => data.Identifiers         = v.Identifiers);
            DoIfExists(version, AlbumEditableFields.OriginalRelease, xmlCache, v => data.OriginalRelease = v.OriginalRelease);
            DoIfExists(version, AlbumEditableFields.Names, xmlCache, v => data.Names       = v.Names);
            DoIfExists(version, AlbumEditableFields.Pictures, xmlCache, v => data.Pictures = v.Pictures);
            DoIfExists(version, AlbumEditableFields.PVs, xmlCache, v => data.PVs           = v.PVs);
            DoIfExists(version, AlbumEditableFields.Tracks, xmlCache, v => data.Songs      = v.Songs);
            DoIfExists(version, AlbumEditableFields.WebLinks, xmlCache, v => data.WebLinks = v.WebLinks);

            return(data);
        }
Exemplo n.º 2
0
        public void Archive(ISession session, Album album, AlbumDiff diff, AlbumArchiveReason reason, string notes = "")
        {
            var agentLoginData = SessionHelper.CreateAgentLoginData(session, PermissionContext);
            var archived       = ArchivedAlbumVersion.Create(album, diff, agentLoginData, reason, notes);

            session.Save(archived);
        }
Exemplo n.º 3
0
        public void Archive(IRepositoryContext <Album> ctx, Album album, AlbumDiff diff, AlbumArchiveReason reason, string notes = "")
        {
            var agentLoginData = ctx.CreateAgentLoginData(PermissionContext);
            var archived       = ArchivedAlbumVersion.Create(album, diff, agentLoginData, reason, notes);

            ctx.OfType <ArchivedAlbumVersion>().Save(archived);
        }
Exemplo n.º 4
0
        public async Task <ArchivedAlbumVersion> ArchiveAsync(IDatabaseContext <Album> ctx, Album album, AlbumDiff diff, AlbumArchiveReason reason, string notes = "")
        {
            var agentLoginData = ctx.CreateAgentLoginData(PermissionContext);
            var archived       = ArchivedAlbumVersion.Create(album, diff, agentLoginData, reason, notes);
            await ctx.SaveAsync(archived);

            return(archived);
        }
Exemplo n.º 5
0
		private static void DoIfExists(ArchivedAlbumVersion version, AlbumEditableFields field, XmlCache<ArchivedAlbumContract> xmlCache, Action<ArchivedAlbumContract, XDocument> func) {

			var versionWithField = version.GetLatestVersionWithField(field);

			if (versionWithField != null && versionWithField.Data != null) {
				var data = xmlCache.Deserialize(versionWithField.Version, versionWithField.Data);
				func(data, versionWithField.Data);
			}

		}
Exemplo n.º 6
0
        private static void DoIfExists(ArchivedAlbumVersion version, AlbumEditableFields field, XmlCache <ArchivedAlbumContract> xmlCache, Action <ArchivedAlbumContract, XDocument> func)
        {
            var versionWithField = version.GetLatestVersionWithField(field);

            if (versionWithField != null && versionWithField.Data != null)
            {
                var data = xmlCache.Deserialize(versionWithField.Version, versionWithField.Data);
                func(data, versionWithField.Data);
            }
        }
        public static EntryForPictureDisplayContract Create(ArchivedAlbumVersion archivedVersion, 
            ContentLanguagePreference languagePreference)
        {
            ParamIs.NotNull(() => archivedVersion);

            var name = archivedVersion.Album.TranslatedName[languagePreference];
            var versionWithPic = archivedVersion.GetLatestVersionWithField(AlbumEditableFields.Cover);
            PictureContract pic = null;

            if (versionWithPic != null && versionWithPic.CoverPicture != null)
                pic = new PictureContract(versionWithPic.CoverPicture, Size.Empty);

            return new EntryForPictureDisplayContract(
                EntryType.Album, archivedVersion.Album.Id, name, archivedVersion.Version, pic);
        }
        public ArchivedAlbumVersionDetailsContract(ArchivedAlbumVersion archived, ArchivedAlbumVersion comparedVersion, 
            ContentLanguagePreference languagePreference)
        {
            Album = new AlbumContract(archived.Album, languagePreference);
            ArchivedVersion = new ArchivedAlbumVersionContract(archived);
            ComparedVersion = comparedVersion != null ? new ArchivedAlbumVersionContract(comparedVersion) : null;
            Name = Album.Name;

            ComparableVersions = archived.Album.ArchivedVersionsManager.Versions
                .Where(v => v != archived)
                .Select(a => new ArchivedObjectVersionContract(a))
                .ToArray();

            Versions = ComparedAlbumsContract.Create(archived, comparedVersion);

            ComparedVersionId = Versions.SecondId;
        }
        public ArchivedAlbumVersionDetailsContract(ArchivedAlbumVersion archived, ArchivedAlbumVersion comparedVersion,
                                                   ContentLanguagePreference languagePreference)
        {
            Album           = new AlbumContract(archived.Album, languagePreference);
            ArchivedVersion = new ArchivedAlbumVersionContract(archived);
            ComparedVersion = comparedVersion != null ? new ArchivedAlbumVersionContract(comparedVersion) : null;
            Name            = Album.Name;

            ComparableVersions = archived.Album.ArchivedVersionsManager.Versions
                                 .Where(v => v != archived)
                                 .Select(a => new ArchivedObjectVersionContract(a))
                                 .ToArray();

            Versions = ComparedAlbumsContract.Create(archived, comparedVersion);

            ComparedVersionId = Versions.SecondId;
        }
Exemplo n.º 10
0
        public static EntryForPictureDisplayContract Create(ArchivedAlbumVersion archivedVersion,
                                                            ContentLanguagePreference languagePreference)
        {
            ParamIs.NotNull(() => archivedVersion);

            var             name           = archivedVersion.Album.TranslatedName[languagePreference];
            var             versionWithPic = archivedVersion.GetLatestVersionWithField(AlbumEditableFields.Cover);
            PictureContract pic            = null;

            if (versionWithPic != null && versionWithPic.CoverPicture != null)
            {
                pic = new PictureContract(versionWithPic.CoverPicture, versionWithPic.CoverPictureMime);
            }

            return(new EntryForPictureDisplayContract(
                       EntryType.Album, archivedVersion.Album.Id, name, archivedVersion.Version, pic));
        }
        public ArchivedAlbumVersionDetailsContract(ArchivedAlbumVersion archived, ArchivedAlbumVersion comparedVersion,
                                                   ContentLanguagePreference languagePreference)
        {
            ParamIs.NotNull(() => archived);

            Album           = new AlbumContract(archived.Album, languagePreference);
            ArchivedVersion = new ArchivedAlbumVersionContract(archived);
            ComparedVersion = comparedVersion != null ? new ArchivedAlbumVersionContract(comparedVersion) : null;
            Name            = Album.Name;

            ComparableVersions = archived.Album.ArchivedVersionsManager
                                 .GetPreviousVersions(archived)
                                 .Select(a => ArchivedObjectVersionWithFieldsContract.Create(a, a.Diff.ChangedFields.Value, a.Reason))
                                 .ToArray();

            Versions = ComparedAlbumsContract.Create(archived, comparedVersion);

            ComparedVersionId = Versions.SecondId;
        }
Exemplo n.º 12
0
		public static ArchivedAlbumContract GetAllProperties(ArchivedAlbumVersion version) {

			var data = new ArchivedAlbumContract();
			var xmlCache = new XmlCache<ArchivedAlbumContract>();
			var thisVersion = xmlCache.Deserialize(version.Version, version.Data);

			data.DiscType = thisVersion.DiscType;
			data.Id = thisVersion.Id;
			data.MainPictureMime = thisVersion.MainPictureMime;
			data.TranslatedName = thisVersion.TranslatedName;

			DoIfExists(version, AlbumEditableFields.Artists, xmlCache, (v, doc) => SetArtists(data, v, doc));
			DoIfExists(version, AlbumEditableFields.Description, xmlCache, v => data.Description = v.Description);
			DoIfExists(version, AlbumEditableFields.Identifiers, xmlCache, v => data.Identifiers = v.Identifiers);
			DoIfExists(version, AlbumEditableFields.OriginalRelease, xmlCache, v => data.OriginalRelease = v.OriginalRelease);
			DoIfExists(version, AlbumEditableFields.Names, xmlCache, v => data.Names = v.Names);
			DoIfExists(version, AlbumEditableFields.Pictures, xmlCache, v => data.Pictures = v.Pictures);
			DoIfExists(version, AlbumEditableFields.PVs, xmlCache, v => data.PVs = v.PVs);
			DoIfExists(version, AlbumEditableFields.Tracks, xmlCache, v => data.Songs = v.Songs);
			DoIfExists(version, AlbumEditableFields.WebLinks, xmlCache, v => data.WebLinks = v.WebLinks);

			return data;

		}
Exemplo n.º 13
0
        protected void AddEntryEditedEntry(IDatabaseContext <ActivityEntry> ctx, Album entry, EntryEditEvent editEvent, ArchivedAlbumVersion archivedVersion)
        {
            var user          = ctx.OfType <User>().GetLoggedUser(PermissionContext);
            var activityEntry = new AlbumActivityEntry(entry, editEvent, user, archivedVersion);

            AddActivityfeedEntry(ctx, activityEntry);
        }
Exemplo n.º 14
0
        protected void AddEntryEditedEntry(ISession session, Album entry, EntryEditEvent editEvent, ArchivedAlbumVersion archivedVersion)
        {
            var user          = GetLoggedUser(session);
            var activityEntry = new AlbumActivityEntry(entry, editEvent, user, archivedVersion);

            AddActivityfeedEntry(session, activityEntry);
        }
 public static ComparedAlbumsContract Create(ArchivedAlbumVersion firstData, ArchivedAlbumVersion secondData)
 {
     return(new ComparedAlbumsContract(Create(firstData, secondData, ArchivedAlbumContract.GetAllProperties, d => d.Id)));
 }
 public ArchivedAlbumVersionContract(ArchivedAlbumVersion archivedVersion)
     : base(archivedVersion)
 {
     ChangedFields = (archivedVersion.Diff != null ? archivedVersion.Diff.ChangedFields.Value : AlbumEditableFields.Nothing);
     Reason        = archivedVersion.Reason;
 }
 public ArchivedAlbumVersionContract(ArchivedAlbumVersion archivedVersion)
     : base(archivedVersion)
 {
     ChangedFields = (archivedVersion.Diff != null ? archivedVersion.Diff.ChangedFields : AlbumEditableFields.Nothing);
     Reason = archivedVersion.Reason;
 }
Exemplo n.º 18
0
        protected async Task AddEntryEditedEntryAsync(IDatabaseContext <ActivityEntry> ctx, Album entry, EntryEditEvent editEvent, ArchivedAlbumVersion archivedVersion)
        {
            var user = await ctx.OfType <User>().GetLoggedUserAsync(PermissionContext);

            var activityEntry = new AlbumActivityEntry(entry, editEvent, user, archivedVersion);

            await AddActivityfeedEntryAsync(ctx, activityEntry);
        }