Set date datatypes in model.

This commit is contained in:
2019-05-19 21:02:57 +01:00
parent 4e3558e045
commit 0cc03e93f1
5 changed files with 8 additions and 2 deletions

View File

@@ -52,7 +52,8 @@ namespace Cicm.Database.Models
[Required]
public string Name { get; set; }
[DisplayFormat(DataFormatString = "{0:d}")]
[DisplayFormat(DataFormatString = "{0:d}", ApplyFormatInEditMode = true)]
[DataType(DataType.Date)]
public DateTime? Founded { get; set; }
[Url]
[StringLength(255)]
@@ -62,6 +63,7 @@ namespace Cicm.Database.Models
[StringLength(45)]
public string Facebook { get; set; }
[DisplayFormat(DataFormatString = "{0:d}")]
[DataType(DataType.Date)]
public DateTime? Sold { get; set; }
public int? SoldToId { get; set; }
[StringLength(80)]
@@ -105,6 +107,6 @@ namespace Cicm.Database.Models
: Sold.Value.ToShortDateString();
[NotMapped]
public CompanyDescription Description => Descriptions.FirstOrDefault();
public CompanyDescription Description => Descriptions?.FirstOrDefault();
}
}

View File

@@ -53,6 +53,7 @@ namespace Cicm.Database.Models
[StringLength(45)]
public string ModelCode { get; set; }
[DisplayFormat(DataFormatString = "{0:d}")]
[DataType(DataType.Date)]
public DateTime? Introduced { get; set; }
[StringLength(45)]
public string Package { get; set; }

View File

@@ -55,6 +55,7 @@ namespace Cicm.Database.Models
[Required]
public MachineType Type { get; set; }
[DisplayFormat(DataFormatString = "{0:d}")]
[DataType(DataType.Date)]
public DateTime? Introduced { get; set; }
public int? FamilyId { get; set; }
[StringLength(50)]

View File

@@ -53,6 +53,7 @@ namespace Cicm.Database.Models
[StringLength(45)]
public string ModelCode { get; set; }
[DisplayFormat(DataFormatString = "{0:d}")]
[DataType(DataType.Date)]
public DateTime? Introduced { get; set; }
[DisplayName("Instruction set")]
public int? InstructionSetId { get; set; }

View File

@@ -51,6 +51,7 @@ namespace Cicm.Database.Models
[StringLength(45)]
public string ModelCode { get; set; }
[DisplayFormat(DataFormatString = "{0:d}")]
[DataType(DataType.Date)]
public DateTime? Introduced { get; set; }
[DisplayName("PCM voices")]
[Range(1, int.MaxValue)]