public EntryReportContract(EntryReport report, EntryForApiContract entry, IEnumTranslations enumTranslations) { ParamIs.NotNull(() => report); Created = report.Created; Entry = entry; Hostname = report.Hostname; Id = report.Id; Notes = report.Notes; ReportTypeName = enumTranslations != null?report.TranslatedReportTypeName(enumTranslations) : null; User = (report.User != null ? new UserWithEmailContract(report.User) : null); Version = (report.VersionBase != null ? new ArchivedObjectVersionContract(report.VersionBase) : null); }
public EntryReportContract(EntryReport report, EntryForApiContract entry, IEnumTranslations enumTranslations, IUserIconFactory userIconFactory) { ParamIs.NotNull(() => report); ClosedAt = report.ClosedAt; ClosedBy = report.ClosedBy != null ? new UserForApiContract(report.ClosedBy, userIconFactory, UserOptionalFields.MainPicture) : null; Created = report.Created; Entry = entry; Hostname = report.Hostname; Id = report.Id; Notes = report.Notes; ReportTypeName = enumTranslations != null?report.TranslatedReportTypeName(enumTranslations) : null; User = (report.User != null ? new UserForApiContract(report.User, userIconFactory, UserOptionalFields.MainPicture) : null); Version = (report.VersionBase != null ? new ArchivedObjectVersionContract(report.VersionBase) : null); }
private EntryWithCommentsContract[] GetRecentComments(ISession session, int maxComments, bool ssl) { var albumComments = session.Query <AlbumComment>().Where(c => !c.Album.Deleted).OrderByDescending(c => c.Created).Take(maxComments).ToArray(); var artistComments = session.Query <ArtistComment>().Where(c => !c.Artist.Deleted).OrderByDescending(c => c.Created).Take(maxComments).ToArray(); var songComments = session.Query <SongComment>().Where(c => !c.Song.Deleted).OrderByDescending(c => c.Created).Take(maxComments).ToArray(); var discussionComments = session.Query <DiscussionComment>().Where(c => !c.Topic.Deleted).OrderByDescending(c => c.Created).Take(maxComments).ToArray(); var discussionTopics = session.Query <DiscussionTopic>().Where(c => !c.Deleted).OrderByDescending(c => c.Created).Take(maxComments).ToArray(); var discussionTopicsAsComments = discussionTopics.Select(t => new DiscussionComment(t, t.Content, new AgentLoginData(t.Author, t.AuthorName ?? t.Author.Name)) { Created = t.Created }); var combined = albumComments.Cast <Comment>().Concat(artistComments).Concat(songComments).Concat(discussionComments).Concat(discussionTopicsAsComments) .OrderByDescending(c => c.Created) .Take(maxComments); var contracts = CreateEntryWithCommentsContract(combined, c => EntryForApiContract.Create(c.Entry, LanguagePreference, thumbPersister, null, ssl, EntryOptionalFields.MainPicture)) .ToArray(); return(contracts); }
public ActivityEntryForApiContract(ActivityEntry activityEntry, EntryForApiContract entryForApiContract, IUserIconFactory userIconFactory, IUserPermissionContext permissionContext, ActivityEntryOptionalFields fields) { CreateDate = activityEntry.CreateDate.ToUniversalTime(); EditEvent = activityEntry.EditEvent; if (activityEntry.Author != null && ((permissionContext.IsLoggedIn && (permissionContext.LoggedUserId == activityEntry.Author.Id || permissionContext.HasPermission(PermissionToken.DisableUsers))) || !activityEntry.Author.AnonymousActivity)) { Author = new UserForApiContract(activityEntry.Author, userIconFactory, UserOptionalFields.MainPicture); } if (fields.HasFlag(ActivityEntryOptionalFields.ArchivedVersion) && activityEntry.ArchivedVersionBase != null) { ArchivedVersion = new ArchivedObjectVersionForApiContract(activityEntry.ArchivedVersionBase); } Entry = entryForApiContract; }
public static string EntryDetails(this UrlHelper urlHelper, EntryForApiContract entry) { ParamIs.NotNull(() => entry); return(EntryDetails(urlHelper, entry.EntryType, entry.Id, entry.UrlSlug)); }
public EntryWithCommentsContract(EntryForApiContract entry, CommentContract[] comments) { Comments = comments; Entry = entry; }
public CommentEntryItemViewModel(EntryForApiContract entry) { Entry = entry; }