Add vehicle service controller and view
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Web.Mvc;
|
||||
using AutoMapper;
|
||||
using MileageTraker.Web.Attributes;
|
||||
|
||||
namespace MileageTraker.Web.ViewModels.VehicleService
|
||||
{
|
||||
public class VehicleServiceViewModel
|
||||
{
|
||||
[HiddenInput(DisplayValue = false)]
|
||||
public int? VehicleServiceId { get; set; }
|
||||
|
||||
[Required]
|
||||
[Remote("Exists", "Vehicle", ErrorMessage = "ID not found")]
|
||||
[StringLength(6, MinimumLength = 4, ErrorMessage = "Must be at least a 4 digit number")]
|
||||
[Display(Name = "Vehicle ID")]
|
||||
[RegularExpression(@"\d+", ErrorMessage = "Vehicle ID must be all numbers")]
|
||||
[InputSize("mini")]
|
||||
public string VehicleId { get; set; }
|
||||
|
||||
[DataType(DataType.DateTime)]
|
||||
[DisplayFormatAttribute(ApplyFormatInEditMode = true, DataFormatString = "{0:d}")]
|
||||
[FormatHint("mm/dd/yyyy")]
|
||||
[InputSize("small")]
|
||||
public DateTime? InvoiceDate { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(64, MinimumLength = 3, ErrorMessage = "Minimum 3 characters")]
|
||||
public string ServiceCenterName { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(32)]
|
||||
[InputSize("small")]
|
||||
public string InvoiceNumber { get; set; }
|
||||
|
||||
[Required]
|
||||
[InputSize("small")]
|
||||
[Units("$")]
|
||||
public decimal Price { get; set; }
|
||||
|
||||
[StringLength(64, MinimumLength = 3, ErrorMessage = "Minimum 3 characters")]
|
||||
public string Description { get; set; }
|
||||
|
||||
static VehicleServiceViewModel()
|
||||
{
|
||||
Mapper.CreateMap<VehicleServiceViewModel, Models.VehicleService>();
|
||||
Mapper.CreateMap<Models.VehicleService, VehicleServiceViewModel>();
|
||||
}
|
||||
|
||||
public VehicleServiceViewModel(Models.VehicleService vehicleService)
|
||||
{
|
||||
Mapper.Map(vehicleService, this);
|
||||
}
|
||||
|
||||
public VehicleServiceViewModel()
|
||||
{
|
||||
}
|
||||
|
||||
public Models.VehicleService GetVehicleService()
|
||||
{
|
||||
var vehicleService = new Models.VehicleService();
|
||||
Mapper.Map(this, vehicleService);
|
||||
return vehicleService;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user