Exemple #1
0
        public ArtistForEditContract(Artist artist, ContentLanguagePreference languagePreference)
            : base(artist, languagePreference)
        {
            /*if (artist.Albums.Count() <= MaxAlbums)
             *      AlbumLinks = artist.Albums.Select(a => new AlbumForArtistEditContract(a, languagePreference)).OrderBy(a => a.AlbumName).ToArray();
             * else {
             *      TooManyAlbums = true;
             * }*/

            AllNames         = string.Join(", ", artist.AllNames.Where(n => n != Name));
            Description      = artist.Description;
            Groups           = artist.Groups.Select(g => new GroupForArtistContract(g, languagePreference)).OrderBy(g => g.Group.Name).ToArray();
            TranslatedName   = new TranslatedStringContract(artist.TranslatedName);
            Members          = artist.Members.Select(m => new GroupForArtistContract(m, languagePreference)).OrderBy(a => a.Member.Name).ToArray();
            Names            = new NameManagerEditContract(artist.Names);
            Pictures         = artist.Pictures.Select(p => new EntryPictureFileContract(p)).ToArray();
            UpdateNotes      = string.Empty;
            ValidationResult = ArtistValidator.Validate(artist);
            WebLinks         = artist.WebLinks.Select(w => new WebLinkContract(w)).OrderBy(w => w.DescriptionOrUrl).ToArray();
        }
Exemple #2
0
        public int UpdateEntryStatuses()
        {
            VerifyAdmin();

            SysLog("updating entry statuses");

            return(HandleTransaction(session => {
                int count = 0;

                var artists = session.Query <Artist>().Where(a => !a.Deleted).ToArray();

                foreach (var artist in artists)
                {
                    var result = ArtistValidator.Validate(artist);

                    if (result.Passed && artist.Status == EntryStatus.Draft)
                    {
                        artist.Status = EntryStatus.Finished;
                        session.Update(artist);
                        count++;
                    }
                    else if (!result.Passed && artist.Status == EntryStatus.Finished)
                    {
                        artist.Status = EntryStatus.Draft;
                        session.Update(artist);
                        count++;
                    }
                }

                var albums = session.Query <Album>().Where(a => !a.Deleted).ToArray();

                foreach (var album in albums)
                {
                    var result = AlbumValidator.Validate(album);

                    if (result.Passed && album.Status == EntryStatus.Draft)
                    {
                        album.Status = EntryStatus.Finished;
                        session.Update(album);
                        count++;
                    }
                    else if (!result.Passed && album.Status == EntryStatus.Finished)
                    {
                        album.Status = EntryStatus.Draft;
                        session.Update(album);
                        count++;
                    }
                }

                var songs = session.Query <Song>().Where(a => !a.Deleted).ToArray();

                foreach (var song in songs)
                {
                    var result = SongValidator.Validate(song);

                    if (result.Passed && song.Status == EntryStatus.Draft)
                    {
                        song.Status = EntryStatus.Finished;
                        session.Update(song);
                        count++;
                    }
                    else if (!result.Passed && song.Status == EntryStatus.Finished)
                    {
                        song.Status = EntryStatus.Draft;
                        session.Update(song);
                        count++;
                    }
                }

                return count;
            }));
        }