vehicles, bool activeInactive)
+ {
+ Vehicles = vehicles;
+ Inactive = activeInactive;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Web/Views/Shared/DisplayTemplates/DateTime.cshtml b/Web/Views/Shared/DisplayTemplates/DateTime.cshtml
index 1cc93a6..30875ff 100644
--- a/Web/Views/Shared/DisplayTemplates/DateTime.cshtml
+++ b/Web/Views/Shared/DisplayTemplates/DateTime.cshtml
@@ -1,10 +1,21 @@
@using System.Globalization
-@model DateTime
+@model DateTime?
@{
Layout = "~/Views/Shared/DisplayTemplates/_FieldLayout.cshtml";
var val =
- ViewData.ModelMetadata.DisplayFormatString != null
- ?string.Format(ViewData.ModelMetadata.DisplayFormatString, Model)
- : Model.ToString(CultureInfo.InvariantCulture);
+ Model.HasValue
+ ?
+ ViewData.ModelMetadata.DisplayFormatString != null
+ ? string.Format(ViewData.ModelMetadata.DisplayFormatString, Model)
+ : Model.Value.ToString(CultureInfo.InvariantCulture)
+ : string.Empty;
}
-@Html.Encode(val)
\ No newline at end of file
+@if (Model == null)
+{
+ @Html.Encode(@ViewData.ModelMetadata.NullDisplayText)
+}
+else
+{
+ @Html.Encode(val)
+}
+
diff --git a/Web/Views/Shared/DisplayTemplates/Object.cshtml b/Web/Views/Shared/DisplayTemplates/Object.cshtml
index b8d84ef..cbb7912 100644
--- a/Web/Views/Shared/DisplayTemplates/Object.cshtml
+++ b/Web/Views/Shared/DisplayTemplates/Object.cshtml
@@ -2,7 +2,11 @@
@{
Layout = null;
}
-@foreach (var prop in ViewData.ModelMetadata.Properties.Where(pm => pm.ShowForDisplay && !pm.HideSurroundingHtml && !pm.ModelType.IsCollection()))
+@foreach (var prop in ViewData.ModelMetadata.Properties.Where(
+ pm => pm.ShowForDisplay
+ && !pm.HideSurroundingHtml
+ && !pm.ModelType.IsCollection()
+ ))
{
@Html.Display(prop.PropertyName)
}
\ No newline at end of file
diff --git a/Web/Views/Shared/EditorTemplates/DateTime.cshtml b/Web/Views/Shared/EditorTemplates/DateTime.cshtml
index 523a06a..5d0ce76 100644
--- a/Web/Views/Shared/EditorTemplates/DateTime.cshtml
+++ b/Web/Views/Shared/EditorTemplates/DateTime.cshtml
@@ -1,13 +1,17 @@
-@model DateTime
+@model DateTime?
@{
Layout = "~/Views/Shared/EditorTemplates/_FieldLayout.cshtml";
var inputSize = (string)ViewData.ModelMetadata.AdditionalValues["InputSize"];
+ var val =
+ Model.HasValue
+ ? Model.Value.ToShortDateString()
+ : string.Empty;
}
@if (!string.IsNullOrEmpty(inputSize))
{
- @Html.TextBox("", (Model != DateTime.MinValue ? Model.ToShortDateString() : string.Empty ), new { @class = inputSize})
+ @Html.TextBox("", (Model != DateTime.MinValue ? val : string.Empty ), new { @class = inputSize})
}
else
{
- @Html.TextBox("", (Model != DateTime.MinValue ? Model.ToShortDateString() : string.Empty ))
+ @Html.TextBox("", (Model != DateTime.MinValue ? val : string.Empty ))
}
diff --git a/Web/Views/Vehicle/Details.cshtml b/Web/Views/Vehicle/Details.cshtml
index 5d7cdcb..c120c3d 100644
--- a/Web/Views/Vehicle/Details.cshtml
+++ b/Web/Views/Vehicle/Details.cshtml
@@ -1,7 +1,7 @@
@model MileageTraker.Web.Models.Vehicle
@{
- ViewBag.Title = "Vehicle Details";
+ ViewBag.Title = "Vehicle Details " + (!Model.InactiveDate.HasValue ? "(Active)" : "(Inactive)");
}
@section Styles {
@@ -20,5 +20,13 @@
@Html.ActionLink("Edit", "Edit", new { id = Model.VehicleId }, new { @class = "btn" })
+ @if (!Model.InactiveDate.HasValue)
+ {
+ @Html.ActionLink("Set Inactive", "SetInactive", new {id = Model.VehicleId}, new {@class = "btn"})
+ }
+ else
+ {
+ @Html.ActionLink("Reactivate", "SetActive", new {id = Model.VehicleId}, new {@class = "btn"})
+ }
@Html.ActionLink("Logs", "Index", "Log", new { Model.VehicleId}, new { @class = "btn" })
\ No newline at end of file
diff --git a/Web/Views/Vehicle/Index.cshtml b/Web/Views/Vehicle/Index.cshtml
index 6fe8807..3bbf538 100644
--- a/Web/Views/Vehicle/Index.cshtml
+++ b/Web/Views/Vehicle/Index.cshtml
@@ -1,7 +1,7 @@
-@model IEnumerable
+@model MileageTraker.Web.ViewModels.Vehicle.VehicleResultsViewModel
@{
- ViewBag.Title = "Vehicles";
+ ViewBag.Title = "Vehicles " + (!Model.Inactive ? "(Active)" : "(Inactive)");
}
@section Styles {
@@ -14,7 +14,8 @@
@Html.ActionLink("Add Another Vehicle", "Create", null, new{@class="btn"})
- @Html.ActionLink("Export", "Export", null, new { @class = "btn" })
+ @Html.ActionLink("Export All", "Export", null, new { @class = "btn" })
+ @Html.ActionLink(Model.Inactive ? "Show Active" : "Show Inactive", "Index", new {inactive = !Model.Inactive}, new { @class = "btn" })
@@ -51,7 +52,7 @@
|
-@foreach (var item in Model) {
+@foreach (var item in Model.Vehicles) {
|
@Html.DisplayTextFor(m => item.Key)
diff --git a/Web/Web.csproj b/Web/Web.csproj
index 0cb4d87..2f78ce7 100644
--- a/Web/Web.csproj
+++ b/Web/Web.csproj
@@ -188,6 +188,10 @@
201405210016138_CityFieldsRequired.cs
+
+
+ 201506181329243_VehicleInactiveDate.cs
+
@@ -210,6 +214,7 @@
+
|