diff --git a/Web/Controllers/ServiceReminderController.cs b/Web/Controllers/ServiceReminderController.cs index 9215100..166edf2 100644 --- a/Web/Controllers/ServiceReminderController.cs +++ b/Web/Controllers/ServiceReminderController.cs @@ -21,14 +21,6 @@ namespace MileageTraker.Web.Controllers return View(viewModel); } - public ActionResult Delete(int id) - { - var serviceReminder = DataService.GetServiceReminder(id); - var vehicleId = serviceReminder.Vehicle.VehicleId; - DataService.DeleteServiceReminder(id); - return RedirectToAction("Index", new { vehicleId }); - } - [HttpGet] [RequireRequestValue("vehicleId")] public ActionResult Create(string vehicleId) @@ -94,5 +86,24 @@ namespace MileageTraker.Web.Controllers return View(viewModel); } + + public ActionResult Delete(int id) + { + var vehicleService = DataService.GetServiceReminder(id); + var viewModel = new ServiceReminderViewModel(vehicleService); + return View(viewModel); + } + + [HttpPost, ActionName("Delete")] + [ActionLog] + public ActionResult DeleteConfirmed(int id) + { + var serviceReminder = DataService.GetServiceReminder(id); + var vehicleId = serviceReminder.Vehicle.VehicleId; + DataService.DeleteServiceReminder(id); + + SetStatusMessage("Service Reminder deleted"); + return RedirectToAction("Index", new { vehicleId }); + } } } \ No newline at end of file diff --git a/Web/Controllers/VehicleServiceController.cs b/Web/Controllers/VehicleServiceController.cs index 7e5eeb4..f6ac88c 100644 --- a/Web/Controllers/VehicleServiceController.cs +++ b/Web/Controllers/VehicleServiceController.cs @@ -193,6 +193,23 @@ namespace MileageTraker.Web.Controllers return View(viewModel); } + public ActionResult Delete(int id) + { + var vehicleService = DataService.GetVehicleService(id); + var viewModel = new VehicleServiceViewModel(vehicleService); + return View(viewModel); + } + + [HttpPost, ActionName("Delete")] + [ActionLog] + public ActionResult DeleteConfirmed(int id) + { + DataService.DeleteVehicleService(id); + + SetStatusMessage("Vehicle Service deleted"); + return RedirectToAction("Index"); + } + [HttpPost] [ActionLog] public ActionResult Edit(VehicleServiceViewModel viewModel) diff --git a/Web/Views/ServiceReminder/Delete.cshtml b/Web/Views/ServiceReminder/Delete.cshtml new file mode 100644 index 0000000..6760a05 --- /dev/null +++ b/Web/Views/ServiceReminder/Delete.cshtml @@ -0,0 +1,24 @@ +@model MileageTraker.Web.ViewModels.ServiceReminder.ServiceReminderViewModel + +@{ + ViewBag.Title = "Delete Service Reminder"; +} + +@Html.Partial("_StatusMessage") + +

@ViewBag.Title

+ +
Are you sure you wish to delete this service reminder?
+ +
+ + @Html.DisplayForModel() + + @using (Html.BeginForm("Delete", "ServiceReminder", FormMethod.Post, new { @class = "form-horizontal" })) + { +
+ + @Html.ActionLink("Cancel", "Index", new { id = Model.VehicleId }, new { @class = "btn" }) +
+ } +
\ No newline at end of file diff --git a/Web/Views/ServiceReminder/Details.cshtml b/Web/Views/ServiceReminder/Details.cshtml index fa77e42..2a18922 100644 --- a/Web/Views/ServiceReminder/Details.cshtml +++ b/Web/Views/ServiceReminder/Details.cshtml @@ -13,4 +13,5 @@
@Html.ActionLink("Edit", "Edit", new { id = Model.ServiceReminderId }, new { @class = "btn" }) + @Html.ActionLink("Delete", "Delete", new { id = Model.ServiceReminderId }, new { @class = "btn" })
\ No newline at end of file diff --git a/Web/Views/VehicleService/Delete.cshtml b/Web/Views/VehicleService/Delete.cshtml new file mode 100644 index 0000000..c46386d --- /dev/null +++ b/Web/Views/VehicleService/Delete.cshtml @@ -0,0 +1,24 @@ +@model MileageTraker.Web.ViewModels.VehicleService.VehicleServiceViewModel + +@{ + ViewBag.Title = "Delete Vehicle Service"; +} + +@Html.Partial("_StatusMessage") + +

@ViewBag.Title

+ +
Are you sure you wish to delete this service?
+ +
+ + @Html.DisplayForModel() + + @using (Html.BeginForm("Delete", "VehicleService", FormMethod.Post, new { @class = "form-horizontal" })) + { +
+ + @Html.ActionLink("Cancel", "Details", new { id = Model.VehicleServiceId }, new { @class = "btn" }) +
+ } +
\ No newline at end of file diff --git a/Web/Views/VehicleService/Details.cshtml b/Web/Views/VehicleService/Details.cshtml index 53c49f9..6c56b56 100644 --- a/Web/Views/VehicleService/Details.cshtml +++ b/Web/Views/VehicleService/Details.cshtml @@ -13,5 +13,6 @@
@Html.ActionLink("Edit", "Edit", new { id = Model.VehicleServiceId }, new { @class = "btn" }) + @Html.ActionLink("Delete", "Delete", new { id = Model.VehicleServiceId }, new { @class = "btn" }) @Html.ActionLink("Vehicle Details", "Details", "Vehicle", new { id = Model.VehicleId }, new{@class="btn"})
\ No newline at end of file diff --git a/Web/Views/VehicleService/Index.cshtml b/Web/Views/VehicleService/Index.cshtml index 75dfc0e..9487ecd 100644 --- a/Web/Views/VehicleService/Index.cshtml +++ b/Web/Views/VehicleService/Index.cshtml @@ -54,6 +54,7 @@ grid.Column(format: @
@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" })
) ), htmlAttributes: new { @class = "table table-striped table-bordered table-hover table-condensed"}, diff --git a/Web/Web.csproj b/Web/Web.csproj index 7b4c440..b911a53 100644 --- a/Web/Web.csproj +++ b/Web/Web.csproj @@ -394,6 +394,8 @@ + +