Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CarViewModel
- {
- public int Id { get; set; }
- [Required(AllowEmptyStrings = false)]
- public string Color { get; set; }
- [Required(AllowEmptyStrings = false)]
- public DateTime PurchaseDate { get; set; }
- [Required(AllowEmptyStrings = false)]
- public string LicensePlate { get; set; }
- public int? OwnerId { get; set; }
- public List<SelectListItem> Owners { get; set; }
- public string OwnerLabel {
- get
- {
- if (OwnerId == null || Owners == null || Owners.All(x => x.Value != $"{OwnerId}"))
- {
- return null;
- }
- //else is niet expliciet nodig
- return Owners.FirstOrDefault(x => x.Value == $"{OwnerId}")?.Text;
- }
- }
- public int? TypeId { get; set; }
- public List<SelectListItem> Types { get; set; }
- public string TypeLabel {
- get
- {
- if (TypeId == null || Types == null || Types.All(x => x.Value != $"{TypeId}"))
- {
- return null;
- }
- //else is niet expliciet nodig
- return Types.FirstOrDefault(x => x.Value == $"{TypeId}")?.Text;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement