public UserMessagesContract(User user, int maxCount, bool unread, IUserIconFactory iconFactory) {

			ReceivedMessages = user.ReceivedMessages.Where(m => !unread || !m.Read).Take(maxCount).Select(m => new UserMessageContract(m, iconFactory)).ToArray();

			if (!unread)
				SentMessages = user.SentMessages.Take(maxCount).Select(m => new UserMessageContract(m, iconFactory)).ToArray();		

		}
		public CommentForApiContract(Comment comment, IUserIconFactory iconFactory) {
			
			ParamIs.NotNull(() => comment);

			Author = comment.Author != null ? new UserWithIconContract(comment.Author, iconFactory) : null;
			AuthorName = comment.AuthorName;
			Created = comment.Created;
			Id = comment.Id;
			Message = comment.Message;

		}
		public UserMessageContract(UserMessage message, IUserIconFactory iconFactory, bool includeBody = false) {

			ParamIs.NotNull(() => message);

			Body = (includeBody ? message.Message : string.Empty);
			Created = message.Created;
			CreatedFormatted = Created.ToUniversalTime().ToString("g");
			HighPriority = message.HighPriority;
			Id = message.Id;
			Read = message.Read;
			Receiver = new UserWithIconContract(message.Receiver, iconFactory);
			Sender = (message.Sender != null ? new UserWithIconContract(message.Sender, iconFactory) : null);
			Subject = message.Subject;

		}
Exemple #4
0
        public ArchivedAlbumVersionDetailsContract(ArchivedAlbumVersion archived, ArchivedAlbumVersion comparedVersion,
                                                   IUserPermissionContext permissionContext, IUserIconFactory userIconFactory)
        {
            ParamIs.NotNull(() => archived);

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

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

            Versions = ComparedAlbumsContract.Create(archived, comparedVersion);

            ComparedVersionId = Versions.SecondId;
        }
Exemple #5
0
 public TagQueries(ITagRepository repository, IUserPermissionContext permissionContext,
                   IEntryLinkFactory entryLinkFactory, IEntryImagePersisterOld imagePersister, IUserIconFactory userIconFactory,
                   IEnumTranslations enumTranslations)
     : base(repository, permissionContext)
 {
     this.entryLinkFactory = entryLinkFactory;
     this.imagePersister   = imagePersister;
     this.userIconFactory  = userIconFactory;
     this.enumTranslations = enumTranslations;
 }
Exemple #6
0
 public AlbumService(ISessionFactory sessionFactory, IUserPermissionContext permissionContext, IEntryLinkFactory entryLinkFactory,
                     IUserIconFactory userIconFactory)
     : base(sessionFactory, permissionContext, entryLinkFactory)
 {
     this.userIconFactory = userIconFactory;
 }
		public UserWithIconContract(User user, IUserIconFactory iconFactory)
			: this(user, iconFactory != null ? iconFactory.GetIconUrl(user) : string.Empty) {}
Exemple #8
0
 public DiscussionApiController(DiscussionQueries queries, IUserIconFactory userIconFactory)
 {
     this.queries         = queries;
     this.userIconFactory = userIconFactory;
 }
Exemple #9
0
        public SongListForApiContract(SongList list, ContentLanguagePreference languagePreference, IUserIconFactory userIconFactory, IAggregatedEntryImageUrlFactory imagePersister,
                                      SongListOptionalFields fields) : base(list)
        {
            ParamIs.NotNull(() => list);

            Author    = new UserForApiContract(list.Author, userIconFactory, UserOptionalFields.None);
            Deleted   = list.Deleted;
            EventDate = list.EventDate;
            Status    = list.Status;

            if (fields.HasFlag(SongListOptionalFields.Description))
            {
                Description = list.Description;
            }

            if (fields.HasFlag(SongListOptionalFields.Events))
            {
                Events = list.Events.Select(e => new ReleaseEventForApiContract(e, languagePreference, ReleaseEventOptionalFields.Venue, imagePersister)).OrderBy(e => e.Date).ThenBy(e => e.Name).ToArray();
            }

            if (fields.HasFlag(SongListOptionalFields.MainPicture))
            {
                MainPicture = list.Thumb != null ? new EntryThumbForApiContract(list.Thumb, imagePersister) : null;
            }

            if (fields.HasFlag(SongListOptionalFields.Tags))
            {
                Tags = list.Tags.ActiveUsages.Select(u => new TagUsageForApiContract(u, languagePreference)).OrderByDescending(u => u.Count).ToArray();
            }
        }
Exemple #10
0
        public ArtistDetailsContract(Artist artist, ContentLanguagePreference languagePreference, IUserPermissionContext userContext,
                                     IAggregatedEntryImageUrlFactory imageStore, IUserIconFactory userIconFactory, Tag artistTypeTag = null)
            : base(artist, languagePreference)
        {
            AllNames           = string.Join(", ", artist.AllNames.Where(n => n != Name));
            ArtistTypeTag      = artistTypeTag != null ? new TagBaseContract(artistTypeTag, languagePreference) : null;
            BaseVoicebank      = artist.BaseVoicebank != null ? new ArtistContract(artist.BaseVoicebank, languagePreference) : null;
            CanRemoveTagUsages = EntryPermissionManager.CanRemoveTagUsages(userContext, artist);
            CreateDate         = artist.CreateDate;
            Description        = artist.Description;
            Draft          = artist.Status == EntryStatus.Draft;
            TranslatedName = new TranslatedStringContract(artist.TranslatedName);
            LatestAlbums   = new AlbumForApiContract[] { };
            LatestSongs    = new SongForApiContract[] { };
            OwnerUsers     = artist.OwnerUsers.Select(u => new UserForApiContract(u.User, userIconFactory, UserOptionalFields.MainPicture)).ToArray();
            Pictures       = artist.Pictures.Select(p => new EntryPictureFileContract(p, imageStore)).ToArray();
            TopAlbums      = new AlbumForApiContract[] { };
            TopSongs       = new SongForApiContract[] { };
            WebLinks       = artist.WebLinks.Select(w => new WebLinkContract(w)).OrderBy(w => w.DescriptionOrUrl).ToArray();

            CharacterDesigner = artist.ArtistLinksOfType(ArtistLinkType.CharacterDesigner, LinkDirection.ManyToOne, allowInheritance: true)
                                .Select(g => new ArtistContract(g, languagePreference)).FirstOrDefault();

            CharacterDesignerOf = artist.ArtistLinksOfType(ArtistLinkType.CharacterDesigner, LinkDirection.OneToMany)
                                  .Select(g => new ArtistContract(g, languagePreference)).OrderBy(a => a.Name).ToArray();

            if (artist.CanHaveChildVoicebanks)
            {
                var children = artist.ChildVoicebanks
                               .Where(c => !c.Deleted)
                               .Select(c => new ArtistContract(c, languagePreference))
                               .ToArray();

                // Show child voicebanks with release date first
                ChildVoicebanks = children
                                  .Where(c => c.ReleaseDate.HasValue)
                                  .OrderBy(c => c.ReleaseDate)
                                  .Concat(children.Where(c => !c.ReleaseDate.HasValue))
                                  .ToArray();
            }
            else
            {
                ChildVoicebanks = new ArtistContract[0];
            }

            Groups = artist.ArtistLinksOfType(ArtistLinkType.Group, LinkDirection.ManyToOne)
                     .Select(g => new ArtistContract(g, languagePreference)).OrderBy(g => g.Name).ToArray();

            Illustrators = artist.ArtistLinksOfType(ArtistLinkType.Illustrator, LinkDirection.ManyToOne, allowInheritance: true)
                           .Select(g => new ArtistContract(g, languagePreference)).ToArray();

            IllustratorOf = artist.ArtistLinksOfType(ArtistLinkType.Illustrator, LinkDirection.OneToMany)
                            .Select(g => new ArtistContract(g, languagePreference)).OrderBy(a => a.Name).ToArray();

            Managers = artist.ArtistLinksOfType(ArtistLinkType.Manager, LinkDirection.ManyToOne, allowInheritance: true)
                       .Select(g => new ArtistContract(g, languagePreference)).OrderBy(a => a.Name).ToArray();

            ManagerOf = artist.ArtistLinksOfType(ArtistLinkType.Manager, LinkDirection.OneToMany)
                        .Select(g => new ArtistContract(g, languagePreference)).OrderBy(a => a.Name).ToArray();

            Members = artist.ArtistLinksOfType(ArtistLinkType.Group, LinkDirection.OneToMany)
                      .Select(g => new ArtistContract(g, languagePreference)).OrderBy(g => g.Name).ToArray();

            Tags = artist.Tags.ActiveUsages
                   .Select(u => new TagUsageForApiContract(u, languagePreference))
                   .OrderByDescending(t => t.Count).ToArray();

            VoiceProviders = artist.ArtistLinksOfType(ArtistLinkType.VoiceProvider, LinkDirection.ManyToOne, allowInheritance: true)
                             .Select(g => new ArtistContract(g, languagePreference)).OrderBy(a => a.Name).ToArray();

            Voicebanks = artist.ArtistLinksOfType(ArtistLinkType.VoiceProvider, LinkDirection.OneToMany)
                         .Select(g => new ArtistContract(g, languagePreference)).OrderBy(a => a.Name).ToArray();
        }
Exemple #11
0
 public CommentQueries(IDatabaseContext ctx, IUserPermissionContext permissionContext, IUserIconFactory userIconFactory, IEntryLinkFactory entryLinkFactory,
                       Func <int, TEntry> entryLoaderFunc = null)
 {
     _ctx = ctx;
     _entryLinkFactory  = entryLinkFactory;
     _permissionContext = permissionContext;
     _userIconFactory   = userIconFactory;
     _entryLoaderFunc   = entryLoaderFunc;
 }
Exemple #12
0
 public ReleaseEventService(ISessionFactory sessionFactory, IUserPermissionContext permissionContext, IEntryLinkFactory entryLinkFactory, IUserIconFactory userIconFactory)
     : base(sessionFactory, permissionContext, entryLinkFactory)
 {
     _userIconFactory = userIconFactory;
 }