Created
February 8, 2018 12:52
-
-
Save tusmester/2e905ae1595372dbf15bfbe2a75d310a to your computer and use it in GitHub Desktop.
#sn #mvc #viewmodel #task
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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