Vehicle Recall integrated into Vehicle Service
This commit is contained in:
@@ -1,9 +1,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using MileageTraker.Web.Attributes;
|
using MileageTraker.Web.Attributes;
|
||||||
using MileageTraker.Web.DAL;
|
using MileageTraker.Web.Models;
|
||||||
using MileageTraker.Web.Utility;
|
|
||||||
using MileageTraker.Web.ViewModels.ServiceReminder;
|
|
||||||
using MileageTraker.Web.ViewModels.VehicleRecall;
|
using MileageTraker.Web.ViewModels.VehicleRecall;
|
||||||
|
|
||||||
namespace MileageTraker.Web.Controllers
|
namespace MileageTraker.Web.Controllers
|
||||||
@@ -11,14 +9,21 @@ namespace MileageTraker.Web.Controllers
|
|||||||
[Authorize(Roles = "Administrator, Developer")]
|
[Authorize(Roles = "Administrator, Developer")]
|
||||||
public class VehicleRecallController : ControllerBase
|
public class VehicleRecallController : ControllerBase
|
||||||
{
|
{
|
||||||
public ActionResult Index()
|
public ActionResult Index(bool completed = false)
|
||||||
{
|
{
|
||||||
var vehicleRecalls = DataService.GetOpenVehicleRecalls().ToList();
|
var vehicleRecalls =
|
||||||
|
DataService.GetVehicleRecalls()
|
||||||
|
.Where(vr =>
|
||||||
|
completed
|
||||||
|
? vr.CompletedService != null
|
||||||
|
: vr.CompletedService == null).ToList();
|
||||||
|
|
||||||
if (vehicleRecalls.Count == 0)
|
if (vehicleRecalls.Count == 0)
|
||||||
return View("Empty");
|
return View("Empty");
|
||||||
|
|
||||||
var viewModel = vehicleRecalls.Select(vr => new VehicleRecallViewModel(vr));
|
var recalls = vehicleRecalls.Select(vr => new VehicleRecallViewModel(vr));
|
||||||
|
|
||||||
|
var viewModel = new VehicleRecallResultsViewModel(recalls, completed);
|
||||||
|
|
||||||
return View(viewModel);
|
return View(viewModel);
|
||||||
}
|
}
|
||||||
@@ -49,12 +54,22 @@ namespace MileageTraker.Web.Controllers
|
|||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
{
|
{
|
||||||
var vehicleRecall = viewModel.GetVehicleRecall();
|
var vehicleRecall = viewModel.GetVehicleRecall();
|
||||||
|
var vehicle = DataService.GetVehicle(viewModel.VehicleId);
|
||||||
|
|
||||||
vehicleRecall.Vehicle = DataService.GetVehicle(viewModel.VehicleId);
|
vehicleRecall.Vehicle = vehicle;
|
||||||
DataService.AddVehicleRecall(vehicleRecall);
|
DataService.AddVehicleRecall(vehicleRecall);
|
||||||
|
|
||||||
SetStatusMessage(
|
var serviceReminder
|
||||||
string.Format("Vehicle Recall for vehicle {0} created", viewModel.VehicleId), StatusType.Success);
|
= new ServiceReminder
|
||||||
|
{
|
||||||
|
Vehicle = vehicle,
|
||||||
|
TargetOdometer = vehicle.CurrentOdometer ?? 0,
|
||||||
|
Description = $"Recall: {vehicleRecall.Identifier}, {vehicleRecall.Description}"
|
||||||
|
};
|
||||||
|
|
||||||
|
DataService.AddServiceReminder(serviceReminder);
|
||||||
|
|
||||||
|
SetStatusMessage($"Vehicle Recall for vehicle {viewModel.VehicleId} created, Service Reminder also created", StatusType.Success);
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,9 +94,12 @@ namespace MileageTraker.Web.Controllers
|
|||||||
[ActionLog]
|
[ActionLog]
|
||||||
public ActionResult DeleteConfirmed(int id)
|
public ActionResult DeleteConfirmed(int id)
|
||||||
{
|
{
|
||||||
DataService.DeleteVehicleRecall(id);
|
var vehicleRecall = DataService.GetVehicleRecall(id);
|
||||||
|
var vehicleVehicleId = vehicleRecall.Vehicle.VehicleId;
|
||||||
|
|
||||||
SetStatusMessage("Vehicle Recall deleted");
|
DataService.DeleteVehicleRecall(id);
|
||||||
|
|
||||||
|
SetStatusMessage($"Vehicle Recall \"{vehicleRecall.Identifier}\" for Vehicle ID {vehicleVehicleId} deleted");
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,10 @@ namespace MileageTraker.Web.Controllers
|
|||||||
// default parameter processing
|
// default parameter processing
|
||||||
query.SetDefaultParameters(validVehicleServiceYearMonths);
|
query.SetDefaultParameters(validVehicleServiceYearMonths);
|
||||||
|
|
||||||
var vehicleServices = DataService.FilterVehicleServices(DataService.GetVehicleServices(), query).ToList();
|
var vehicleServices =
|
||||||
|
DataService
|
||||||
|
.FilterVehicleServices(DataService.GetVehicleServices(), query)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
var upcomingServiceReminders =
|
var upcomingServiceReminders =
|
||||||
DataService.GetUpcomingServiceReminders().ToList()
|
DataService.GetUpcomingServiceReminders().ToList()
|
||||||
@@ -35,7 +38,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
upcomingServiceReminders.Sort();
|
upcomingServiceReminders.Sort();
|
||||||
|
|
||||||
var viewModel = new VehicleServiceResultsViewModel(
|
var viewModel = new VehicleServiceResultsViewModel(
|
||||||
vehicleServices.Select(s => new VehicleServiceViewModel(s)),
|
vehicleServices.Select(s => HydrateViewModel(new VehicleServiceViewModel(s), s.VehicleServiceId)),
|
||||||
upcomingServiceReminders,
|
upcomingServiceReminders,
|
||||||
query,
|
query,
|
||||||
CustomExtensions.YearMonthList(validVehicleServiceYearMonths));
|
CustomExtensions.YearMonthList(validVehicleServiceYearMonths));
|
||||||
@@ -56,7 +59,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
query.SetDefaultParameters(validVehicleServiceYearMonths);
|
query.SetDefaultParameters(validVehicleServiceYearMonths);
|
||||||
|
|
||||||
var vehicleServices = DataService.FilterVehicleServices(DataService.GetVehicleServices(), query).ToList();
|
var vehicleServices = DataService.FilterVehicleServices(DataService.GetVehicleServices(), query).ToList();
|
||||||
var filteredServices = vehicleServices.Select(vs => new VehicleServiceViewModel(vs));
|
var filteredServices = vehicleServices.Select(vs => HydrateViewModel(new VehicleServiceViewModel(vs), vs.VehicleServiceId));
|
||||||
|
|
||||||
var name = string.Format("VehicleServices_{0}", query);
|
var name = string.Format("VehicleServices_{0}", query);
|
||||||
|
|
||||||
@@ -73,18 +76,31 @@ namespace MileageTraker.Web.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Authorize(Roles = "Administrator, Developer")]
|
[Authorize(Roles = "Administrator, Developer")]
|
||||||
public ActionResult Create()
|
public ActionResult SelectVehicle()
|
||||||
{
|
{
|
||||||
return View(HydrateViewModel(new VehicleServiceViewModel()));
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Authorize(Roles = "Administrator, Developer")]
|
[Authorize(Roles = "Administrator, Developer")]
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[RequireRequestValue("vehicleId")]
|
[RequireRequestValue("vehicleId")]
|
||||||
public ActionResult Create(string vehicleId)
|
public ActionResult Create(string vehicleId, string vehicleRecallId)
|
||||||
{
|
{
|
||||||
return View(HydrateViewModel(new VehicleServiceViewModel(), vehicleId: vehicleId));
|
var viewModel = HydrateViewModel(new VehicleServiceViewModel(), vehicleId: vehicleId);
|
||||||
}
|
|
||||||
|
var recall = viewModel.VehicleRecall.Available.FirstOrDefault(r => r.Value == vehicleRecallId);
|
||||||
|
if (recall != null)
|
||||||
|
{
|
||||||
|
foreach (var selectListItem in viewModel.VehicleRecall.Available)
|
||||||
|
{
|
||||||
|
selectListItem.Selected = false;
|
||||||
|
}
|
||||||
|
recall.Selected = true;
|
||||||
|
viewModel.VehicleRecall.Selected = int.Parse(recall.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return View(viewModel);
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[RequireRequestValue("serviceVehicleId")]
|
[RequireRequestValue("serviceVehicleId")]
|
||||||
@@ -97,25 +113,15 @@ namespace MileageTraker.Web.Controllers
|
|||||||
int vehicleServiceId = Int32.MinValue, string vehicleId = null)
|
int vehicleServiceId = Int32.MinValue, string vehicleId = null)
|
||||||
{
|
{
|
||||||
if (vehicleId != null)
|
if (vehicleId != null)
|
||||||
{
|
|
||||||
viewModel.VehicleId = vehicleId;
|
viewModel.VehicleId = vehicleId;
|
||||||
}
|
|
||||||
viewModel.VehicleRecall
|
viewModel.VehicleRecall
|
||||||
= new SelectListViewModel
|
= GetVehicleRecallSelectList(viewModel.VehicleId, vehicleServiceId);
|
||||||
{
|
|
||||||
Available = GetVehicleRecallSelectList(
|
|
||||||
viewModel.VehicleId,
|
|
||||||
vehicleServiceId)
|
|
||||||
};
|
|
||||||
viewModel.VehicleRecall.Selected =
|
|
||||||
viewModel.VehicleRecall.Available.SelectedValue != null
|
|
||||||
? (int?) int.Parse((string)viewModel.VehicleRecall.Available.SelectedValue)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
return viewModel;
|
return viewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SelectList GetVehicleRecallSelectList(string vehicleId = null, int vehicleServiceId = Int32.MinValue)
|
private SelectListViewModel GetVehicleRecallSelectList(string vehicleId = null, int vehicleServiceId = Int32.MinValue)
|
||||||
{
|
{
|
||||||
var availableRecalls =
|
var availableRecalls =
|
||||||
DataService.GetOpenVehicleRecalls(vehicleId).Union(DataService.GetVehicleRecallByServiceId(vehicleServiceId))
|
DataService.GetOpenVehicleRecalls(vehicleId).Union(DataService.GetVehicleRecallByServiceId(vehicleServiceId))
|
||||||
@@ -130,7 +136,16 @@ namespace MileageTraker.Web.Controllers
|
|||||||
var selectedValue = availableRecalls.FirstOrDefault(vr => vr.Selected)?.Value ?? "0";
|
var selectedValue = availableRecalls.FirstOrDefault(vr => vr.Selected)?.Value ?? "0";
|
||||||
|
|
||||||
var selectList = new SelectList(availableRecalls, "Value", "Text", selectedValue);
|
var selectList = new SelectList(availableRecalls, "Value", "Text", selectedValue);
|
||||||
return selectList;
|
|
||||||
|
var slvm = new SelectListViewModel
|
||||||
|
{
|
||||||
|
Available = selectList,
|
||||||
|
Selected =
|
||||||
|
selectList.SelectedValue != null
|
||||||
|
? (int?)int.Parse((string)selectList.SelectedValue)
|
||||||
|
: null
|
||||||
|
};
|
||||||
|
return slvm;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
@@ -189,7 +204,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
serviceReminder.Vehicle = vehicle;
|
serviceReminder.Vehicle = vehicle;
|
||||||
|
|
||||||
DataService.AddServiceReminder(serviceReminder);
|
DataService.AddServiceReminder(serviceReminder);
|
||||||
status.Add(string.Format("Service Reminder at {0} miles created", viewModel.TargetOdometer));
|
status.Add($"Service Reminder at {viewModel.TargetOdometer} miles created");
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle any deletion
|
// handle any deletion
|
||||||
@@ -206,7 +221,9 @@ namespace MileageTraker.Web.Controllers
|
|||||||
{
|
{
|
||||||
DataService.DeleteServiceReminder(serviceReminders[selected].id);
|
DataService.DeleteServiceReminder(serviceReminders[selected].id);
|
||||||
}
|
}
|
||||||
status.Add(string.Format("Selected {0} service reminders deleted", viewModel.DeleteServiceReminders.Selected.Count()));
|
status.Add(
|
||||||
|
$"Selected {viewModel.DeleteServiceReminders.Selected.Count()} " + $"" +
|
||||||
|
$"service reminder{(viewModel.DeleteServiceReminders.Selected.Count() > 2 ? "s" : "")} deleted");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status.Count > 0)
|
if (status.Count > 0)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using System.Linq;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using ExcelLibrary.SpreadSheet;
|
using ExcelLibrary.SpreadSheet;
|
||||||
using MileageTraker.Web.Models;
|
using MileageTraker.Web.Models;
|
||||||
|
using MileageTraker.Web.ViewModels;
|
||||||
|
|
||||||
namespace MileageTraker.Web.Utility
|
namespace MileageTraker.Web.Utility
|
||||||
{
|
{
|
||||||
@@ -108,21 +109,25 @@ namespace MileageTraker.Web.Utility
|
|||||||
if (p.Name == "GasPurchased") // format to the .000 place
|
if (p.Name == "GasPurchased") // format to the .000 place
|
||||||
formatString = "#,##0.000";
|
formatString = "#,##0.000";
|
||||||
|
|
||||||
int intValue; // write int-looking values as numbers
|
if (value is string valInt && int.TryParse(valInt, out var intValue))
|
||||||
if (value is string && int.TryParse((string) value, out intValue))
|
|
||||||
value = intValue;
|
value = intValue;
|
||||||
|
|
||||||
double doubleValue; // write double-looking values as numbers
|
if (value is string valDbl && double.TryParse(valDbl, out var doubleValue))
|
||||||
if (value is string && double.TryParse((string) value, out doubleValue))
|
|
||||||
value = doubleValue;
|
value = doubleValue;
|
||||||
|
|
||||||
if (value is MileageLogTypeWrapper)
|
if (value is MileageLogTypeWrapper valMt)
|
||||||
value = ((MileageLogTypeWrapper) value).Enum.GetDisplayName();
|
value = valMt.Enum.GetDisplayName();
|
||||||
|
|
||||||
|
if (value is SelectListViewModel valSelList)
|
||||||
|
value = valSelList.ToString();
|
||||||
|
|
||||||
if (value == null)
|
if (value == null)
|
||||||
value = p.GetNullDisplayText(item);
|
value = p.GetNullDisplayText(item);
|
||||||
|
|
||||||
var cell = formatString != null ? new Cell(value, formatString) : new Cell(value);
|
var cell =
|
||||||
|
formatString != null
|
||||||
|
? new Cell(value, formatString)
|
||||||
|
: new Cell(value);
|
||||||
worksheet.Cells[r, c] = cell;
|
worksheet.Cells[r, c] = cell;
|
||||||
|
|
||||||
return (string) null;
|
return (string) null;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Web.Mvc;
|
using System.Linq;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
|
||||||
namespace MileageTraker.Web.ViewModels
|
namespace MileageTraker.Web.ViewModels
|
||||||
{
|
{
|
||||||
@@ -9,7 +10,15 @@ namespace MileageTraker.Web.ViewModels
|
|||||||
|
|
||||||
public override string ToString()
|
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.ComponentModel.DataAnnotations;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
@@ -29,11 +29,15 @@ namespace MileageTraker.Web.ViewModels.VehicleRecall
|
|||||||
[StringLength(128, MinimumLength = 3, ErrorMessage = "Minimum 3 characters")]
|
[StringLength(128, MinimumLength = 3, ErrorMessage = "Minimum 3 characters")]
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
|
|
||||||
[HiddenInput(DisplayValue = false)]
|
[ScaffoldColumn(false)]
|
||||||
[Display(Name = "Vehicle Service")]
|
[Display(Name = "Vehicle Service")]
|
||||||
[UIHint("VehicleServiceLink")]
|
[UIHint("VehicleServiceLink")]
|
||||||
public int CompletedService_VehicleServiceId { get; set; }
|
public int CompletedService_VehicleServiceId { get; set; }
|
||||||
|
|
||||||
|
[ScaffoldColumn(false)]
|
||||||
|
[Display(Name = "Completed Date")]
|
||||||
|
public DateTime CompletedService_InvoiceDate { get; set; }
|
||||||
|
|
||||||
static VehicleRecallViewModel()
|
static VehicleRecallViewModel()
|
||||||
{
|
{
|
||||||
Mapper.CreateMap<VehicleRecallViewModel, Models.VehicleRecall>();
|
Mapper.CreateMap<VehicleRecallViewModel, Models.VehicleRecall>();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using MileageTraker.Web.Attributes;
|
using MileageTraker.Web.Attributes;
|
||||||
@@ -13,12 +14,7 @@ namespace MileageTraker.Web.ViewModels.VehicleService
|
|||||||
[HiddenInput(DisplayValue = false)]
|
[HiddenInput(DisplayValue = false)]
|
||||||
public int? VehicleServiceId { get; set; }
|
public int? VehicleServiceId { get; set; }
|
||||||
|
|
||||||
[Required]
|
[HiddenInput(DisplayValue = true)]
|
||||||
[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; }
|
public string VehicleId { get; set; }
|
||||||
|
|
||||||
[DataType(DataType.DateTime)]
|
[DataType(DataType.DateTime)]
|
||||||
@@ -43,15 +39,15 @@ namespace MileageTraker.Web.ViewModels.VehicleService
|
|||||||
[Currency]
|
[Currency]
|
||||||
public decimal Price { get; set; }
|
public decimal Price { get; set; }
|
||||||
|
|
||||||
|
[StringLength(64, MinimumLength = 3, ErrorMessage = "Minimum 3 characters")]
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
[Display(Name = "Vehicle Recall")]
|
[Display(Name = "Vehicle Recall")]
|
||||||
[OptionLabel("Not a recall")]
|
[OptionLabel("Not a recall")]
|
||||||
[UIHint("VehicleRecallSelectListViewModel")]
|
[UIHint("VehicleRecallSelectListViewModel")]
|
||||||
public SelectListViewModel VehicleRecall { get; set; }
|
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<VehicleServiceViewModel, Models.VehicleService>();
|
||||||
Mapper.CreateMap<Models.VehicleService, VehicleServiceViewModel>()
|
Mapper.CreateMap<Models.VehicleService, VehicleServiceViewModel>()
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@Html.Partial("VehicleSelect", new VehicleSelectViewModel())
|
@Html.Partial("EditorTemplates/VehicleSelect", new VehicleSelectViewModel())
|
||||||
|
|
||||||
<div class="center-content" style="text-align: center">
|
<div class="center-content" style="text-align: center">
|
||||||
@Html.ActionLink("Import", "ImportUpload", new {}, new { @class = "btn"})
|
@Html.ActionLink("Import", "ImportUpload", new {}, new { @class = "btn"})
|
||||||
|
|||||||
@@ -9,4 +9,8 @@
|
|||||||
@Html.ActionLink(selected.Text, "Details", "VehicleRecall", new { id = selected.Value }, null)
|
@Html.ActionLink(selected.Text, "Details", "VehicleRecall", new { id = selected.Value }, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<text>Not a recall</text>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
@model MileageTraker.Web.ViewModels.SelectListViewModel
|
|
||||||
@{
|
|
||||||
Layout = "~/Views/Shared/EditorTemplates/_FieldLayout.cshtml";
|
|
||||||
}
|
|
||||||
@Html.DropDownList("", new List<SelectListItem>(new List<SelectListItem>{new SelectListItem{Text = "Not a recall", Value = "None"}}))
|
|
||||||
@@ -18,11 +18,11 @@
|
|||||||
</div>
|
</div>
|
||||||
@if (!completed)
|
@if (!completed)
|
||||||
{
|
{
|
||||||
<div class="center-content">Completed? @Html.ActionLink("Add Service", "Create", "VehicleService", new { VehicleId = Model.VehicleId }, new { @class = "btn" })</div>
|
<div class="center-content">Completed? @Html.ActionLink("Add Service", "Create", "VehicleService", new { VehicleId = Model.VehicleId, VehicleRecallId = Model.VehicleRecallId}, new { @class = "btn" })</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
<div class="center-content btn-toolbar">
|
<div class="center-content btn-toolbar">
|
||||||
@Html.ActionLink("Edit", "Edit", new { id = Model.VehicleRecallId }, new { @class = "btn" })
|
@Html.ActionLink("Edit", "Edit", new { id = Model.VehicleRecallId }, new { @class = "btn" })
|
||||||
@Html.ActionLink("Delete", "Delete", new { id = Model.VehicleId }, new { @class = "btn" })
|
@Html.ActionLink("Delete", "Delete", new { id = Model.VehicleRecallId }, new { @class = "btn" })
|
||||||
@Html.ActionLink("Vehicle Details", "Details", "Vehicle", new { id = Model.VehicleId }, new{@class="btn"})
|
@Html.ActionLink("Vehicle Details", "Details", "Vehicle", new { id = Model.VehicleId }, new{@class="btn"})
|
||||||
</div>
|
</div>
|
||||||
@@ -1,8 +1,22 @@
|
|||||||
@model IEnumerable<MileageTraker.Web.ViewModels.VehicleRecall.VehicleRecallViewModel>
|
@model MileageTraker.Web.ViewModels.VehicleRecall.VehicleRecallResultsViewModel
|
||||||
|
|
||||||
@{
|
@{
|
||||||
ViewBag.Title = "Vehicle Recalls";
|
ViewBag.Title = string.Format("Vehicle Recalls ({0})", Model.Completed ? "Completed" : "Open");
|
||||||
var grid = new WebGrid(Model, rowsPerPage: 45);
|
var grid = new WebGrid(Model.Recalls, rowsPerPage: 45);
|
||||||
|
var columns = grid.Columns(
|
||||||
|
grid.Column("VehicleId", "Vehicle ID", item => Html.ActionLink((string) item.VehicleId, "DetailsPartial", "Vehicle", new {id = item.VehicleId}, new {@class = "qtip-modal"})),
|
||||||
|
grid.Column("Identifier", "Identifier", item => item.Identifier),
|
||||||
|
grid.Column("Description", "Description"),
|
||||||
|
grid.Column(format:
|
||||||
|
@<div class='btn-group'>
|
||||||
|
@Html.ActionLink("Details", "Details", new {id = item.VehicleRecallId}, new {@class = "btn btn-mini"})
|
||||||
|
@Html.ActionLink("Delete", "Delete", new {id = item.VehicleRecallId}, new {@class = "btn btn-mini"})
|
||||||
|
</div>)
|
||||||
|
).ToList();
|
||||||
|
if (Model.Completed)
|
||||||
|
{
|
||||||
|
columns.Insert(3, grid.Column("CompletedService_InvoiceDate", "Completed Date", item => ((DateTime)item.CompletedService_InvoiceDate).ToShortDateString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Html.Partial("_StatusMessage")
|
@Html.Partial("_StatusMessage")
|
||||||
@@ -11,20 +25,10 @@
|
|||||||
|
|
||||||
<div class="btn-toolbar pull-left">
|
<div class="btn-toolbar pull-left">
|
||||||
@Html.ActionLink("Add Recall", "Create", null, new { @class = "btn" })
|
@Html.ActionLink("Add Recall", "Create", null, new { @class = "btn" })
|
||||||
<a class="qtip-show-next-div btn">Open Recalls @Model.Count()</a>
|
@Html.ActionLink(Model.Completed ? "Show Open" : "Show Completed", "Index", new { completed = !Model.Completed }, new { @class = "btn" })
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@grid.GetHtml(columns:
|
@grid.GetHtml(columns: columns,
|
||||||
grid.Columns(
|
|
||||||
grid.Column("VehicleId", "Vehicle ID", item => Html.ActionLink((string)item.VehicleId, "DetailsPartial", "Vehicle", new { id = item.VehicleId }, new { @class = "qtip-modal" })),
|
|
||||||
grid.Column("Identifier", "Identifier", item => item.Identifier),
|
|
||||||
grid.Column("Description", "Description"),
|
|
||||||
grid.Column(format:
|
|
||||||
@<div class='btn-group'>
|
|
||||||
@Html.ActionLink("Details", "Details", new { id = item.VehicleRecallId }, new { @class = "btn btn-mini" })
|
|
||||||
@Html.ActionLink("Delete", "Delete", new { id = item.VehicleRecallId }, new { @class = "btn btn-mini" })
|
|
||||||
</div>)
|
|
||||||
),
|
|
||||||
htmlAttributes: new { @class = "table table-striped table-bordered table-hover table-condensed"},
|
htmlAttributes: new { @class = "table table-striped table-bordered table-hover table-condensed"},
|
||||||
numericLinksCount: 20
|
numericLinksCount: 20
|
||||||
)
|
)
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
@model MileageTraker.Web.ViewModels.VehicleService.VehicleServiceViewModel
|
@model MileageTraker.Web.ViewModels.VehicleService.VehicleServiceViewModel
|
||||||
|
|
||||||
@{
|
@{
|
||||||
ViewBag.Title = "Record Vehicle Service";
|
ViewBag.Title = "Record Vehicle Service";
|
||||||
}
|
}
|
||||||
@@ -12,9 +11,17 @@
|
|||||||
@Html.Partial("_ValidationSummary")
|
@Html.Partial("_ValidationSummary")
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend></legend>
|
<legend></legend>
|
||||||
|
<div class="control-group">
|
||||||
|
<div class="control-label">
|
||||||
|
<label>Vehicle ID</label>
|
||||||
|
</div>
|
||||||
|
<div class="controls">
|
||||||
|
<b>@Model.VehicleId</b>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@Html.EditorForModel()
|
@Html.EditorForModel()
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<input type="submit" value="Create" class="btn btn-primary" />
|
<input type="submit" value="Create" class="btn btn-primary" />
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
}
|
}
|
||||||
@@ -1,62 +1,82 @@
|
|||||||
@model MileageTraker.Web.ViewModels.VehicleService.VehicleServiceResultsViewModel
|
@using MileageTraker.Web.ViewModels
|
||||||
|
@model MileageTraker.Web.ViewModels.VehicleService.VehicleServiceResultsViewModel
|
||||||
|
|
||||||
@{
|
@{
|
||||||
ViewBag.Title = "Vehicle Service";
|
ViewBag.Title = "Vehicle Service";
|
||||||
var grid = new WebGrid(Model.ServiceItems, rowsPerPage: 45);
|
var grid = new WebGrid(Model.ServiceItems, rowsPerPage: 45);
|
||||||
var queryParams = new { Model.Year, Model.Month, Model.MonthRange, Model.VehicleId };
|
var queryParams = new { Model.Year, Model.Month, Model.MonthRange, Model.VehicleId };
|
||||||
var serviceOverdueBadge = Model.UpcomingServiceReminders.Any(sr => sr.IsServiceOverdue) ? "badge-warning" : "";
|
var serviceOverdueBadge = Model.UpcomingServiceReminders.Any(sr => sr.IsServiceOverdue) ? "badge-warning" : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@section Scripts {
|
@section Scripts {
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var availableLogYearMonths = @Html.Raw(Json.Encode(Model.AvailableYearMonths));
|
var availableLogYearMonths = @Html.Raw(Json.Encode(Model.AvailableYearMonths));
|
||||||
@if (Model.Year != null)
|
@if (Model.Year != null)
|
||||||
{
|
{
|
||||||
<text>var selectedYear = "@Model.Year";</text>
|
<text>var selectedYear = "@Model.Year";</text>
|
||||||
<text>var selectedMonth = "@Model.Month";</text>
|
<text>var selectedMonth = "@Model.Month";</text>
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Html.Partial("_StatusMessage")
|
@Html.Partial("_StatusMessage")
|
||||||
|
|
||||||
<div class="btn-toolbar pull-right" style="width:600px">
|
<div class="btn-toolbar pull-right" style="width:600px">
|
||||||
@using (Html.BeginForm("Index", "VehicleService", FormMethod.Get, new { id = "filter", @class = "form" }))
|
@using (Html.BeginForm("Index", "VehicleService", FormMethod.Get, new { id = "filter", @class = "form" }))
|
||||||
{
|
{
|
||||||
@Html.EditorForModel()
|
@Html.EditorForModel()
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h2 id="vehicle-title"><i class="fa fa-wrench"></i> @ViewBag.Title</h2>
|
<h2 id="vehicle-title"><i class="fa fa-wrench"></i> @ViewBag.Title</h2>
|
||||||
|
|
||||||
<div class="btn-toolbar pull-left">
|
<div class="btn-toolbar pull-left">
|
||||||
@Html.ActionLink("Add Service", "Create", null, new { @class = "btn" })
|
@Html.ActionLink("Add Service", "SelectVehicle", null, new { @class = "btn" })
|
||||||
@Html.ActionLink("Export", "Export", queryParams, new { @class = "btn" })
|
@Html.ActionLink("Export", "Export", queryParams, new { @class = "btn" })
|
||||||
<a class="qtip-show-next-div btn">Upcoming Services <span class="badge @serviceOverdueBadge">@Model.UpcomingServiceReminders.Count</span></a>
|
<a class="qtip-show-next-div btn">Upcoming Services <span class="badge @serviceOverdueBadge">@Model.UpcomingServiceReminders.Count</span></a>
|
||||||
<div class="hidden">
|
<div class="hidden">
|
||||||
@if (@Model.UpcomingServiceReminders.Count > 0)
|
@if (@Model.UpcomingServiceReminders.Count > 0)
|
||||||
{
|
{
|
||||||
@Html.Partial("UpcomingServiceReminders", Model.UpcomingServiceReminders)
|
@Html.Partial("UpcomingServiceReminders", Model.UpcomingServiceReminders)
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
<h5>No upcoming services currently scheduled</h5>
|
{
|
||||||
}
|
<h5>No upcoming services currently scheduled</h5>
|
||||||
</div>
|
}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@grid.GetHtml(columns:
|
@grid.GetHtml(columns:
|
||||||
grid.Columns(
|
grid.Columns(
|
||||||
grid.Column("InvoiceDate", "Invoice Date", item => item.InvoiceDate.ToString("d")),
|
grid.Column("InvoiceDate", "Invoice Date", item => item.InvoiceDate.ToString("d")),
|
||||||
grid.Column("VehicleId", "Vehicle ID", item => Html.ActionLink((string)item.VehicleId, "DetailsPartial", "Vehicle", new { id = item.VehicleId }, new { @class = "qtip-modal" })),
|
grid.Column("VehicleId", "Vehicle ID", item => Html.ActionLink((string)item.VehicleId, "DetailsPartial", "Vehicle", new { id = item.VehicleId }, new { @class = "qtip-modal" })),
|
||||||
grid.Column("ServiceCenterName", "Service Center Name"),
|
grid.Column("ServiceCenterName", "Service Center Name"),
|
||||||
grid.Column("Price", "Price", @<text>@String.Format("{0:C}", item.Price)</text>),
|
grid.Column("Price", "Price", @<text>@String.Format("{0:C}", item.Price)</text>),
|
||||||
grid.Column("Description", "Description"),
|
grid.Column("Description", "Description"),
|
||||||
grid.Column(format:
|
grid.Column("VehicleRecall", "Vehicle Recall", item => Recall(item.VehicleRecall)),
|
||||||
@<div class='btn-group'>
|
grid.Column(format:
|
||||||
@Html.ActionLink("Details", "Details", new { id = item.VehicleServiceId }, new { @class = "btn btn-mini" })
|
@<div class='btn-group'>
|
||||||
@Html.ActionLink("Delete", "Delete", new { id = item.VehicleServiceId }, new { @class = "btn btn-mini" })
|
@Html.ActionLink("Details", "Details", new { id = item.VehicleServiceId }, new { @class = "btn btn-mini" })
|
||||||
</div>)
|
@Html.ActionLink("Delete", "Delete", new { id = item.VehicleServiceId }, new { @class = "btn btn-mini" })
|
||||||
),
|
</div> )
|
||||||
htmlAttributes: new { @class = "table table-striped table-bordered table-hover table-condensed"},
|
),
|
||||||
numericLinksCount: 20
|
htmlAttributes: new { @class = "table table-striped table-bordered table-hover table-condensed" },
|
||||||
)
|
numericLinksCount: 20
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@helper Recall(SelectListViewModel selectList)
|
||||||
|
{
|
||||||
|
if (selectList != null && selectList.Selected > 0)
|
||||||
|
{
|
||||||
|
var selected = selectList.Available.FirstOrDefault(i => i.Value == selectList.Selected.ToString());
|
||||||
|
if (selected != null)
|
||||||
|
{
|
||||||
|
@Html.ActionLink(selected.Text, "Details", "VehicleRecall", new { id = selected.Value }, null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<span class="muted">(Not a recall)</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
@using MileageTraker.Web.ViewModels.VehicleService
|
||||||
|
@model MileageTraker.Web.ViewModels.VehicleService.VehicleServiceViewModel
|
||||||
|
|
||||||
|
@{
|
||||||
|
ViewBag.Title = "Record Vehicle Service";
|
||||||
|
}
|
||||||
|
|
||||||
|
<h2 class="center-content"><i class="fa fa-wrench"></i> @ViewBag.Title</h2>
|
||||||
|
<h4 class="center-content">Track completed service for a vehicle</h4>
|
||||||
|
|
||||||
|
@Html.Partial("EditorTemplates/VehicleSelect", new VehicleSelectViewModel())
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
@model MileageTraker.Web.ViewModels.SelectListViewModel
|
||||||
|
@Html.EditorForModel()
|
||||||
+4
-2
@@ -175,6 +175,7 @@
|
|||||||
<Compile Include="ViewModels\DriverMileageFlattenedViewModel.cs" />
|
<Compile Include="ViewModels\DriverMileageFlattenedViewModel.cs" />
|
||||||
<Compile Include="ViewModels\User\UserResultsViewModel.cs" />
|
<Compile Include="ViewModels\User\UserResultsViewModel.cs" />
|
||||||
<Compile Include="ViewModels\VehicleRecall\VehicleRecallViewModel.cs" />
|
<Compile Include="ViewModels\VehicleRecall\VehicleRecallViewModel.cs" />
|
||||||
|
<Compile Include="ViewModels\VehicleRecall\VehicleRecallResultsViewModel.cs" />
|
||||||
<Compile Include="ViewModels\VehicleService\VehicleSelectViewModel.cs" />
|
<Compile Include="ViewModels\VehicleService\VehicleSelectViewModel.cs" />
|
||||||
<Compile Include="ViewModels\VehicleService\UpdateServiceRemindersViewModel.cs" />
|
<Compile Include="ViewModels\VehicleService\UpdateServiceRemindersViewModel.cs" />
|
||||||
<Compile Include="Controllers\FuelLogController.cs" />
|
<Compile Include="Controllers\FuelLogController.cs" />
|
||||||
@@ -398,7 +399,7 @@
|
|||||||
<Content Include="Views\Shared\PageTitle.cshtml" />
|
<Content Include="Views\Shared\PageTitle.cshtml" />
|
||||||
<Content Include="Views\VehicleService\Delete.cshtml" />
|
<Content Include="Views\VehicleService\Delete.cshtml" />
|
||||||
<Content Include="Views\ServiceReminder\Delete.cshtml" />
|
<Content Include="Views\ServiceReminder\Delete.cshtml" />
|
||||||
<Content Include="Views\CreateLog\VehicleSelect.cshtml" />
|
<Content Include="Views\Shared\EditorTemplates\VehicleSelect.cshtml" />
|
||||||
<Content Include="Views\VehicleRecall\Index.cshtml" />
|
<Content Include="Views\VehicleRecall\Index.cshtml" />
|
||||||
<Content Include="Views\VehicleRecall\Empty.cshtml" />
|
<Content Include="Views\VehicleRecall\Empty.cshtml" />
|
||||||
<Content Include="Views\VehicleRecall\Create.cshtml" />
|
<Content Include="Views\VehicleRecall\Create.cshtml" />
|
||||||
@@ -406,10 +407,11 @@
|
|||||||
<Content Include="Views\VehicleRecall\Delete.cshtml" />
|
<Content Include="Views\VehicleRecall\Delete.cshtml" />
|
||||||
<Content Include="Views\Vehicle\DetailsQuickPartial.cshtml" />
|
<Content Include="Views\Vehicle\DetailsQuickPartial.cshtml" />
|
||||||
<Content Include="Views\VehicleRecall\Edit.cshtml" />
|
<Content Include="Views\VehicleRecall\Edit.cshtml" />
|
||||||
<Content Include="Views\Shared\EditorTemplates\VehicleRecallIdSelect.cshtml" />
|
|
||||||
<Content Include="Views\Shared\DisplayTemplates\Details.cshtml" />
|
<Content Include="Views\Shared\DisplayTemplates\Details.cshtml" />
|
||||||
<Content Include="Views\Shared\DisplayTemplates\VehicleRecallSelectListViewModel.cshtml" />
|
<Content Include="Views\Shared\DisplayTemplates\VehicleRecallSelectListViewModel.cshtml" />
|
||||||
<Content Include="Views\Shared\DisplayTemplates\VehicleServiceLink.cshtml" />
|
<Content Include="Views\Shared\DisplayTemplates\VehicleServiceLink.cshtml" />
|
||||||
|
<Content Include="Views\VehicleService\VehicleRecallSelect.cshtml" />
|
||||||
|
<Content Include="Views\VehicleService\SelectVehicle.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Content\Account.Login.css" />
|
<Content Include="Content\Account.Login.css" />
|
||||||
|
|||||||
Reference in New Issue
Block a user