Vehicle Recall integrated into Vehicle Service

This commit is contained in:
2020-09-30 21:44:38 -04:00
parent 6f031c5cb6
commit 4b44128d62
18 changed files with 236 additions and 126 deletions
+13 -4
View File
@@ -1,4 +1,5 @@
using System.Web.Mvc;
using System.Linq;
using System.Web.Mvc;
namespace MileageTraker.Web.ViewModels
{
@@ -9,7 +10,15 @@ namespace MileageTraker.Web.ViewModels
public override string ToString()
{
return Selected.ToString();
}
}
if (Selected > 0)
{
var selected = Available.FirstOrDefault(i => i.Value == Selected.ToString());
if (selected != null)
{
return selected.Text;
}
}
return string.Empty;
}
}
}
@@ -0,0 +1,16 @@
using System.Collections.Generic;
namespace MileageTraker.Web.ViewModels.VehicleRecall
{
public class VehicleRecallResultsViewModel
{
public IEnumerable<VehicleRecallViewModel> Recalls { get; set; }
public bool Completed { get; set; }
public VehicleRecallResultsViewModel(IEnumerable<VehicleRecallViewModel> vehicles, bool completed)
{
Recalls = vehicles;
Completed = completed;
}
}
}
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using AutoMapper;
@@ -29,11 +29,15 @@ namespace MileageTraker.Web.ViewModels.VehicleRecall
[StringLength(128, MinimumLength = 3, ErrorMessage = "Minimum 3 characters")]
public string Description { get; set; }
[HiddenInput(DisplayValue = false)]
[ScaffoldColumn(false)]
[Display(Name = "Vehicle Service")]
[UIHint("VehicleServiceLink")]
public int CompletedService_VehicleServiceId { get; set; }
[ScaffoldColumn(false)]
[Display(Name = "Completed Date")]
public DateTime CompletedService_InvoiceDate { get; set; }
static VehicleRecallViewModel()
{
Mapper.CreateMap<VehicleRecallViewModel, Models.VehicleRecall>();
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web.Mvc;
using AutoMapper;
using MileageTraker.Web.Attributes;
@@ -13,12 +14,7 @@ namespace MileageTraker.Web.ViewModels.VehicleService
[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")]
[HiddenInput(DisplayValue = true)]
public string VehicleId { get; set; }
[DataType(DataType.DateTime)]
@@ -43,15 +39,15 @@ namespace MileageTraker.Web.ViewModels.VehicleService
[Currency]
public decimal Price { get; set; }
[StringLength(64, MinimumLength = 3, ErrorMessage = "Minimum 3 characters")]
public string Description { get; set; }
[Display(Name = "Vehicle Recall")]
[OptionLabel("Not a recall")]
[UIHint("VehicleRecallSelectListViewModel")]
public SelectListViewModel VehicleRecall { get; set; }
[StringLength(64, MinimumLength = 3, ErrorMessage = "Minimum 3 characters")]
public string Description { get; set; }
static VehicleServiceViewModel()
static VehicleServiceViewModel()
{
Mapper.CreateMap<VehicleServiceViewModel, Models.VehicleService>();
Mapper.CreateMap<Models.VehicleService, VehicleServiceViewModel>()