Advertisement
Guest User

Untitled

a guest
Jan 4th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASP 1.33 KB | None | 0 0
  1. public class CarViewModel
  2.     {
  3.         public int Id { get; set; }
  4.  
  5.         [Required(AllowEmptyStrings = false)]
  6.         public string Color { get; set; }
  7.  
  8.         [Required(AllowEmptyStrings = false)]
  9.         public DateTime PurchaseDate { get; set; }
  10.  
  11.         [Required(AllowEmptyStrings = false)]
  12.         public string LicensePlate { get; set; }
  13.  
  14.         public int? OwnerId { get; set; }
  15.         public List<SelectListItem> Owners { get; set; }
  16.         public string OwnerLabel {
  17.             get
  18.             {
  19.                 if (OwnerId == null || Owners == null || Owners.All(x => x.Value != $"{OwnerId}"))
  20.                 {
  21.                     return null;
  22.                 }
  23.                 //else is niet expliciet nodig
  24.                 return Owners.FirstOrDefault(x => x.Value == $"{OwnerId}")?.Text;
  25.             }
  26.         }
  27.  
  28.         public int? TypeId { get; set; }
  29.         public List<SelectListItem> Types { get; set; }
  30.         public string TypeLabel {
  31.             get
  32.             {
  33.                 if (TypeId == null || Types == null || Types.All(x => x.Value != $"{TypeId}"))
  34.                 {
  35.                     return null;
  36.                 }
  37.                 //else is niet expliciet nodig
  38.                 return Types.FirstOrDefault(x => x.Value == $"{TypeId}")?.Text;
  39.             }
  40.         }
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement