using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using MileageTraker.Web.Attributes;

namespace MileageTraker.Web.Models
{
	public class Vehicle
	{
		[Required]
		[InputSize("mini")]
		public int Key { get; set; }

		[Key]
		[Required]
		[StringLength(6, MinimumLength = 4, ErrorMessage = "Must be at least a 4 digit number")]
		[Display(Name = "EHTRA ID")]
		[RegularExpression(@"\d+", ErrorMessage = "Vehicle ID must be all numbers")]
		[InputSize("mini")]
		public string VehicleId { get; set; }

		[Required]
		[RegularExpression(@"\d{4}", ErrorMessage = "Must be 4 numbers")]
		[InputSize("mini")]
		public string ModelYear { get; set; }

		[Required]
		[InputSize("medium")]
		public string Make { get; set; }

		[Display(Name = "Model")]
		[Required]
		[InputSize("medium")]
		public string CarModel { get; set; }

		[InputSize("small")]
		public string Color { get; set; }

		[Required]
		[RegularExpression(@"Car|Truck|SUV|Van", ErrorMessage = "Must be Car, Truck, SUV, or Van")]
		[FormatHint("Car, Truck, SUV or Van")]
		[InputSize("mini")]
		public string Type { get; set; }

		[Required]
		[Display(Name = "VIN")]
		[RegularExpression(@"[0-9A-HJ-NPR-Z]{17}", ErrorMessage = "VIN must be 17-characters, not including letters I, O or Q")]
		[InputSize("large")]
		public string Vin { get; set; }

		[Required]
		[InputSize("small")]
		public decimal Price { get; set; }

		[Required]
		[RegularExpression(@"\d{1,2}/\d{2}", ErrorMessage = "PurDate must be in mm/yy format")]
		[InputSize("small")]
		[FormatHint("mm/yy")]
		public string PurDate { get; set; }

		[Required]
		[Display(Name = "Tag#")]
		[InputSize("small")]
		public string TagNumber { get; set; }

		[Required]
		[InputSize("medium")]
		public string Prog { get; set; }

		[RegularExpression(@"Unassigned|[A-Za-z().]+(\s+[A-Za-z().]+)+", ErrorMessage = "Please enter the full name")]
		[DisplayFormat(NullDisplayText = "Unassigned")]
		[FormatHint("Blank for Unassigned")]
		public string Assigned { get; set; }

		[InputSize("medium")]
		public string Notes { get; set; }

		[Display(Name = "Current Odometer", ShortName= "ODO")]
		[DisplayFormat(NullDisplayText = "?")]
		[InputSize("small")]
		public int? CurrentOdometer { get; set; }

		public virtual ICollection<Log> Logs { get; set; }
	}
}