-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNewestContentModel.cs
41 lines (39 loc) · 1.56 KB
/
NewestContentModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using ULabs.VBulletinEntity;
using ULabs.VBulletinEntity.Models.Forum;
using ULabs.VBulletinEntity.Models.User;
namespace ULabs.VBulletinEntityDemo.Models {
public class NewestContentModel {
public List<VBThread> Threads { get; set; }
public List<VBPost> Posts { get; set; }
public List<VBUser> Users { get; set; }
public List<VBSession> Sessions { get; set; }
public List<VBForum> Forums { get; set; }
public NewestContentModel(VBDbContext db, int limit) {
Threads = db.Threads.OrderByDescending(thread => thread.CreatedTimeRaw)
.Include(thread => thread.Forum)
.Take(limit)
.ToList();
Posts = db.Posts.OrderByDescending(post => post.CreatedTimeRaw)
.Include(post => post.Thread)
.Take(limit)
.ToList();
Users = db.Users.OrderByDescending(user => user.JoinDateRaw)
.Include(user => user.UserGroup)
.Take(limit)
.ToList();
Sessions = db.Sessions.OrderByDescending(session => session.LastActivityRaw)
.Include(session => session.User)
.Include(session => session.InThread)
.Take(limit)
.ToList();
Forums = db.Forums.Include(f => f.Parent)
.Include(f => f.LastPostAuthor)
.Include(f => f.Permissions)
.ToList();
}
}
}