Vehicle Recall integrated into Vehicle Service
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using MileageTraker.Web.Attributes;
|
||||
using MileageTraker.Web.DAL;
|
||||
using MileageTraker.Web.Utility;
|
||||
using MileageTraker.Web.ViewModels.ServiceReminder;
|
||||
using MileageTraker.Web.Models;
|
||||
using MileageTraker.Web.ViewModels.VehicleRecall;
|
||||
|
||||
namespace MileageTraker.Web.Controllers
|
||||
@@ -11,14 +9,21 @@ namespace MileageTraker.Web.Controllers
|
||||
[Authorize(Roles = "Administrator, Developer")]
|
||||
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)
|
||||
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);
|
||||
}
|
||||
@@ -49,12 +54,22 @@ namespace MileageTraker.Web.Controllers
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
var vehicleRecall = viewModel.GetVehicleRecall();
|
||||
var vehicle = DataService.GetVehicle(viewModel.VehicleId);
|
||||
|
||||
vehicleRecall.Vehicle = DataService.GetVehicle(viewModel.VehicleId);
|
||||
vehicleRecall.Vehicle = vehicle;
|
||||
DataService.AddVehicleRecall(vehicleRecall);
|
||||
|
||||
SetStatusMessage(
|
||||
string.Format("Vehicle Recall for vehicle {0} created", viewModel.VehicleId), StatusType.Success);
|
||||
var serviceReminder
|
||||
= 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");
|
||||
}
|
||||
|
||||
@@ -79,9 +94,12 @@ namespace MileageTraker.Web.Controllers
|
||||
[ActionLog]
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,10 @@ namespace MileageTraker.Web.Controllers
|
||||
// default parameter processing
|
||||
query.SetDefaultParameters(validVehicleServiceYearMonths);
|
||||
|
||||
var vehicleServices = DataService.FilterVehicleServices(DataService.GetVehicleServices(), query).ToList();
|
||||
var vehicleServices =
|
||||
DataService
|
||||
.FilterVehicleServices(DataService.GetVehicleServices(), query)
|
||||
.ToList();
|
||||
|
||||
var upcomingServiceReminders =
|
||||
DataService.GetUpcomingServiceReminders().ToList()
|
||||
@@ -35,7 +38,7 @@ namespace MileageTraker.Web.Controllers
|
||||
upcomingServiceReminders.Sort();
|
||||
|
||||
var viewModel = new VehicleServiceResultsViewModel(
|
||||
vehicleServices.Select(s => new VehicleServiceViewModel(s)),
|
||||
vehicleServices.Select(s => HydrateViewModel(new VehicleServiceViewModel(s), s.VehicleServiceId)),
|
||||
upcomingServiceReminders,
|
||||
query,
|
||||
CustomExtensions.YearMonthList(validVehicleServiceYearMonths));
|
||||
@@ -56,7 +59,7 @@ namespace MileageTraker.Web.Controllers
|
||||
query.SetDefaultParameters(validVehicleServiceYearMonths);
|
||||
|
||||
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);
|
||||
|
||||
@@ -73,18 +76,31 @@ namespace MileageTraker.Web.Controllers
|
||||
}
|
||||
|
||||
[Authorize(Roles = "Administrator, Developer")]
|
||||
public ActionResult Create()
|
||||
{
|
||||
return View(HydrateViewModel(new VehicleServiceViewModel()));
|
||||
}
|
||||
public ActionResult SelectVehicle()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[Authorize(Roles = "Administrator, Developer")]
|
||||
[HttpGet]
|
||||
[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]
|
||||
[RequireRequestValue("serviceVehicleId")]
|
||||
@@ -97,25 +113,15 @@ namespace MileageTraker.Web.Controllers
|
||||
int vehicleServiceId = Int32.MinValue, string vehicleId = null)
|
||||
{
|
||||
if (vehicleId != null)
|
||||
{
|
||||
viewModel.VehicleId = vehicleId;
|
||||
}
|
||||
viewModel.VehicleRecall
|
||||
= new SelectListViewModel
|
||||
{
|
||||
Available = GetVehicleRecallSelectList(
|
||||
viewModel.VehicleId,
|
||||
vehicleServiceId)
|
||||
};
|
||||
viewModel.VehicleRecall.Selected =
|
||||
viewModel.VehicleRecall.Available.SelectedValue != null
|
||||
? (int?) int.Parse((string)viewModel.VehicleRecall.Available.SelectedValue)
|
||||
: null;
|
||||
|
||||
|
||||
viewModel.VehicleRecall
|
||||
= GetVehicleRecallSelectList(viewModel.VehicleId, vehicleServiceId);
|
||||
|
||||
return viewModel;
|
||||
}
|
||||
|
||||
private SelectList GetVehicleRecallSelectList(string vehicleId = null, int vehicleServiceId = Int32.MinValue)
|
||||
private SelectListViewModel GetVehicleRecallSelectList(string vehicleId = null, int vehicleServiceId = Int32.MinValue)
|
||||
{
|
||||
var availableRecalls =
|
||||
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 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]
|
||||
@@ -189,7 +204,7 @@ namespace MileageTraker.Web.Controllers
|
||||
serviceReminder.Vehicle = vehicle;
|
||||
|
||||
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
|
||||
@@ -206,7 +221,9 @@ namespace MileageTraker.Web.Controllers
|
||||
{
|
||||
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)
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using ExcelLibrary.SpreadSheet;
|
||||
using MileageTraker.Web.Models;
|
||||
using MileageTraker.Web.ViewModels;
|
||||
|
||||
namespace MileageTraker.Web.Utility
|
||||
{
|
||||
@@ -108,21 +109,25 @@ namespace MileageTraker.Web.Utility
|
||||
if (p.Name == "GasPurchased") // format to the .000 place
|
||||
formatString = "#,##0.000";
|
||||
|
||||
int intValue; // write int-looking values as numbers
|
||||
if (value is string && int.TryParse((string) value, out intValue))
|
||||
if (value is string valInt && int.TryParse(valInt, out var intValue))
|
||||
value = intValue;
|
||||
|
||||
double doubleValue; // write double-looking values as numbers
|
||||
if (value is string && double.TryParse((string) value, out doubleValue))
|
||||
if (value is string valDbl && double.TryParse(valDbl, out var doubleValue))
|
||||
value = doubleValue;
|
||||
|
||||
if (value is MileageLogTypeWrapper)
|
||||
value = ((MileageLogTypeWrapper) value).Enum.GetDisplayName();
|
||||
if (value is MileageLogTypeWrapper valMt)
|
||||
value = valMt.Enum.GetDisplayName();
|
||||
|
||||
if (value is SelectListViewModel valSelList)
|
||||
value = valSelList.ToString();
|
||||
|
||||
if (value == null)
|
||||
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;
|
||||
|
||||
return (string) null;
|
||||
|
||||
@@ -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>()
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
</div>
|
||||
|
||||
@Html.Partial("VehicleSelect", new VehicleSelectViewModel())
|
||||
@Html.Partial("EditorTemplates/VehicleSelect", new VehicleSelectViewModel())
|
||||
|
||||
<div class="center-content" style="text-align: center">
|
||||
@Html.ActionLink("Import", "ImportUpload", new {}, new { @class = "btn"})
|
||||
|
||||
@@ -9,4 +9,8 @@
|
||||
@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>
|
||||
@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">
|
||||
@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"})
|
||||
</div>
|
||||
@@ -1,8 +1,22 @@
|
||||
@model IEnumerable<MileageTraker.Web.ViewModels.VehicleRecall.VehicleRecallViewModel>
|
||||
@model MileageTraker.Web.ViewModels.VehicleRecall.VehicleRecallResultsViewModel
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Vehicle Recalls";
|
||||
var grid = new WebGrid(Model, rowsPerPage: 45);
|
||||
ViewBag.Title = string.Format("Vehicle Recalls ({0})", Model.Completed ? "Completed" : "Open");
|
||||
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")
|
||||
@@ -11,20 +25,10 @@
|
||||
|
||||
<div class="btn-toolbar pull-left">
|
||||
@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>
|
||||
|
||||
@grid.GetHtml(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>)
|
||||
),
|
||||
@grid.GetHtml(columns: columns,
|
||||
htmlAttributes: new { @class = "table table-striped table-bordered table-hover table-condensed"},
|
||||
numericLinksCount: 20
|
||||
)
|
||||
@@ -1,5 +1,4 @@
|
||||
@model MileageTraker.Web.ViewModels.VehicleService.VehicleServiceViewModel
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Record Vehicle Service";
|
||||
}
|
||||
@@ -12,9 +11,17 @@
|
||||
@Html.Partial("_ValidationSummary")
|
||||
<fieldset>
|
||||
<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()
|
||||
<div class="form-actions">
|
||||
<input type="submit" value="Create" class="btn btn-primary" />
|
||||
</div>
|
||||
</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";
|
||||
var grid = new WebGrid(Model.ServiceItems, rowsPerPage: 45);
|
||||
var queryParams = new { Model.Year, Model.Month, Model.MonthRange, Model.VehicleId };
|
||||
var serviceOverdueBadge = Model.UpcomingServiceReminders.Any(sr => sr.IsServiceOverdue) ? "badge-warning" : "";
|
||||
ViewBag.Title = "Vehicle Service";
|
||||
var grid = new WebGrid(Model.ServiceItems, rowsPerPage: 45);
|
||||
var queryParams = new { Model.Year, Model.Month, Model.MonthRange, Model.VehicleId };
|
||||
var serviceOverdueBadge = Model.UpcomingServiceReminders.Any(sr => sr.IsServiceOverdue) ? "badge-warning" : "";
|
||||
}
|
||||
|
||||
@section Scripts {
|
||||
<script type="text/javascript">
|
||||
<script type="text/javascript">
|
||||
var availableLogYearMonths = @Html.Raw(Json.Encode(Model.AvailableYearMonths));
|
||||
@if (Model.Year != null)
|
||||
{
|
||||
<text>var selectedYear = "@Model.Year";</text>
|
||||
<text>var selectedMonth = "@Model.Month";</text>
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
}
|
||||
|
||||
@Html.Partial("_StatusMessage")
|
||||
|
||||
<div class="btn-toolbar pull-right" style="width:600px">
|
||||
@using (Html.BeginForm("Index", "VehicleService", FormMethod.Get, new { id = "filter", @class = "form" }))
|
||||
{
|
||||
@Html.EditorForModel()
|
||||
}
|
||||
@using (Html.BeginForm("Index", "VehicleService", FormMethod.Get, new { id = "filter", @class = "form" }))
|
||||
{
|
||||
@Html.EditorForModel()
|
||||
}
|
||||
</div>
|
||||
|
||||
<h2 id="vehicle-title"><i class="fa fa-wrench"></i> @ViewBag.Title</h2>
|
||||
|
||||
<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" })
|
||||
<a class="qtip-show-next-div btn">Upcoming Services <span class="badge @serviceOverdueBadge">@Model.UpcomingServiceReminders.Count</span></a>
|
||||
<div class="hidden">
|
||||
@if (@Model.UpcomingServiceReminders.Count > 0)
|
||||
{
|
||||
@Html.Partial("UpcomingServiceReminders", Model.UpcomingServiceReminders)
|
||||
}
|
||||
else {
|
||||
<h5>No upcoming services currently scheduled</h5>
|
||||
}
|
||||
</div>
|
||||
<a class="qtip-show-next-div btn">Upcoming Services <span class="badge @serviceOverdueBadge">@Model.UpcomingServiceReminders.Count</span></a>
|
||||
<div class="hidden">
|
||||
@if (@Model.UpcomingServiceReminders.Count > 0)
|
||||
{
|
||||
@Html.Partial("UpcomingServiceReminders", Model.UpcomingServiceReminders)
|
||||
}
|
||||
else
|
||||
{
|
||||
<h5>No upcoming services currently scheduled</h5>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@grid.GetHtml(columns:
|
||||
grid.Columns(
|
||||
grid.Column("InvoiceDate", "Invoice Date", item => item.InvoiceDate.ToString("d")),
|
||||
grid.Columns(
|
||||
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("ServiceCenterName", "Service Center Name"),
|
||||
grid.Column("Price", "Price", @<text>@String.Format("{0:C}", item.Price)</text>),
|
||||
grid.Column("Description", "Description"),
|
||||
grid.Column(format:
|
||||
@<div class='btn-group'>
|
||||
@Html.ActionLink("Details", "Details", new { id = item.VehicleServiceId }, new { @class = "btn btn-mini" })
|
||||
@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
|
||||
)
|
||||
grid.Column("ServiceCenterName", "Service Center Name"),
|
||||
grid.Column("Price", "Price", @<text>@String.Format("{0:C}", item.Price)</text>),
|
||||
grid.Column("Description", "Description"),
|
||||
grid.Column("VehicleRecall", "Vehicle Recall", item => Recall(item.VehicleRecall)),
|
||||
grid.Column(format:
|
||||
@<div class='btn-group'>
|
||||
@Html.ActionLink("Details", "Details", new { id = item.VehicleServiceId }, new { @class = "btn btn-mini" })
|
||||
@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
|
||||
)
|
||||
|
||||
|
||||
@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\User\UserResultsViewModel.cs" />
|
||||
<Compile Include="ViewModels\VehicleRecall\VehicleRecallViewModel.cs" />
|
||||
<Compile Include="ViewModels\VehicleRecall\VehicleRecallResultsViewModel.cs" />
|
||||
<Compile Include="ViewModels\VehicleService\VehicleSelectViewModel.cs" />
|
||||
<Compile Include="ViewModels\VehicleService\UpdateServiceRemindersViewModel.cs" />
|
||||
<Compile Include="Controllers\FuelLogController.cs" />
|
||||
@@ -398,7 +399,7 @@
|
||||
<Content Include="Views\Shared\PageTitle.cshtml" />
|
||||
<Content Include="Views\VehicleService\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\Empty.cshtml" />
|
||||
<Content Include="Views\VehicleRecall\Create.cshtml" />
|
||||
@@ -406,10 +407,11 @@
|
||||
<Content Include="Views\VehicleRecall\Delete.cshtml" />
|
||||
<Content Include="Views\Vehicle\DetailsQuickPartial.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\VehicleRecallSelectListViewModel.cshtml" />
|
||||
<Content Include="Views\Shared\DisplayTemplates\VehicleServiceLink.cshtml" />
|
||||
<Content Include="Views\VehicleService\VehicleRecallSelect.cshtml" />
|
||||
<Content Include="Views\VehicleService\SelectVehicle.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Content\Account.Login.css" />
|
||||
|
||||
Reference in New Issue
Block a user