Skip to content

Instantly share code, notes, and snippets.

@tusmester
Created February 8, 2018 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tusmester/2e905ae1595372dbf15bfbe2a75d310a to your computer and use it in GitHub Desktop.
Save tusmester/2e905ae1595372dbf15bfbe2a75d310a to your computer and use it in GitHub Desktop.
#sn #mvc #viewmodel #task
using System;
using System.ComponentModel.DataAnnotations;
using SenseNet.ContentRepository;
using SenseNet.ContentRepository.Storage.Security;
namespace SnWebApplication.Models
{
public class TaskViewModel
{
public readonly Task Task;
private string _displayName;
[Required]
[Display(Name = "Short description")]
public string DisplayName => Task?.DisplayName;
[Display(Name = "Assigned to")]
public string AssignedToText => SystemAccount.Execute(() => Task?.GetReference<User>("AssignedTo")?.DisplayName) ?? string.Empty;
public DateTime DueDate => (DateTime)(Task?["DueDate"] ?? DateTime.MaxValue);
public TaskViewModel(Task task)
{
Task = task;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment