public StatsDTO RetrieveBlogStats()
{
StatsDTO model = new StatsDTO();
model.TotalPosts = PostRepository.GetCount();
model.TotalTags = TagRepository.GetCount();
model.TotalAlbums = AlbumRepository.GetCount();
model.TotalCategories = CategoryRepository.GetCount();
model.TotalImages = ImageRepository.GetCount();
model.TotalUsers = UserRepository.GetCount();
model.TotalComments = CommentRepository.GetCount();
model.TotalRoles = RoleRepository.GetCount();
model.TopRatedPosts = PostRepository.Get(p => p.Ratings.Any(), o => o.OrderByDescending(p => p.Ratings.Average(r => r.Value)), "Ratings").Take(10);
model.MostVisitedPosts = PostRepository.Get(p=>p.Visits > 0, o => o.OrderByDescending(p => p.Visits)).Take(10);
model.MostCommentedPosts = PostRepository.Get(p => p.Comments.Any(), o => o.OrderByDescending(c => c.Comments.Count()), "Comments").Take(10);
model.PostWritenByUser = UserRepository.Get(u => u.Roles.Any(r => r.RoleName == "admin"));
return model;
}