Skip to content

Instantly share code, notes, and snippets.

@tusmester
Created February 8, 2018 12:51
Show Gist options
  • Save tusmester/1a98133c0048dc7df5c58a87e3d9ae66 to your computer and use it in GitHub Desktop.
Save tusmester/1a98133c0048dc7df5c58a87e3d9ae66 to your computer and use it in GitHub Desktop.
#sn #mvc #viewmodel #dashboard
using SenseNet.ContentRepository;
using SenseNet.Search;
using System.Collections.Generic;
using System.Linq;
namespace SnWebApplication.Models
{
public class DashboardViewModel
{
public IEnumerable<TaskViewModel> MyTasks => Content.All
.Where(c => c.TypeIs("Task") && (User) c["AssignedTo"] == (User)User.Current).Take(20).AsEnumerable()
.Select(t => new TaskViewModel((Task)t.ContentHandler));
public IEnumerable<TaskViewModel> OthersTasks => ContentQuery
.Query("+TypeIs:Task -AssignedTo:@@CurrentUser@@ .TOP:20").Nodes.Cast<Task>()
.Select(t => new TaskViewModel(t));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment