Vehicle Service added for drivers
This commit is contained in:
@@ -75,9 +75,12 @@ namespace MileageTraker.Web.Controllers
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
public JsonResult Exists(string vehicleId)
|
||||
public JsonResult Exists(string vehicleId, string serviceVehicleId)
|
||||
{
|
||||
var vehicle = DataService.GetVehicle(vehicleId);
|
||||
var vehicle =
|
||||
vehicleId != null
|
||||
? DataService.GetVehicle(vehicleId)
|
||||
: DataService.GetVehicle(serviceVehicleId);
|
||||
return Json(vehicle != null, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,9 +12,10 @@ using MileageTraker.Web.ViewModels.VehicleService;
|
||||
|
||||
namespace MileageTraker.Web.Controllers
|
||||
{
|
||||
[Authorize(Roles = "Administrator, Developer")]
|
||||
[Authorize(Roles = "Administrator, Developer, Driver")]
|
||||
public class VehicleServiceController : ControllerBase
|
||||
{
|
||||
[Authorize(Roles = "Administrator, Developer")]
|
||||
public ActionResult Index(VehicleServiceQueryViewModel query)
|
||||
{
|
||||
var validVehicleServiceYearMonths = DataService.GetValidVehicleServiceMonths();
|
||||
@@ -41,6 +42,7 @@ namespace MileageTraker.Web.Controllers
|
||||
return View(viewModel);
|
||||
}
|
||||
|
||||
[Authorize(Roles = "Administrator, Developer")]
|
||||
[ActionLog]
|
||||
public ActionResult Export(VehicleServiceQueryViewModel query)
|
||||
{
|
||||
@@ -61,6 +63,7 @@ namespace MileageTraker.Web.Controllers
|
||||
return File(export, "application/ms-excel", name + ".xls");
|
||||
}
|
||||
|
||||
[Authorize(Roles = "Administrator, Developer")]
|
||||
public ViewResult Details(int id)
|
||||
{
|
||||
var vehicleService = DataService.GetVehicleService(id);
|
||||
@@ -68,11 +71,13 @@ namespace MileageTraker.Web.Controllers
|
||||
return View(viewModel);
|
||||
}
|
||||
|
||||
[Authorize(Roles = "Administrator, Developer")]
|
||||
public ActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[Authorize(Roles = "Administrator, Developer")]
|
||||
[HttpGet]
|
||||
[RequireRequestValue("vehicleId")]
|
||||
public ActionResult Create(string vehicleId)
|
||||
@@ -80,6 +85,13 @@ namespace MileageTraker.Web.Controllers
|
||||
return View(new VehicleServiceViewModel{VehicleId = vehicleId});
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[RequireRequestValue("serviceVehicleId")]
|
||||
public ActionResult CreateDriver(string serviceVehicleId)
|
||||
{
|
||||
return View ("Create", new VehicleServiceViewModel{VehicleId = serviceVehicleId });
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ActionLog]
|
||||
public ActionResult Create(VehicleServiceViewModel viewModel)
|
||||
@@ -158,12 +170,19 @@ namespace MileageTraker.Web.Controllers
|
||||
{
|
||||
SetStatusMessage(string.Join(", ", status), StatusType.Success);
|
||||
}
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
if (User.IsInRole("Administrator") || User.IsInRole("Developer"))
|
||||
{
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
return RedirectToAction("Index", "CreateLog"); // for the drivers
|
||||
}
|
||||
|
||||
return View(viewModel);
|
||||
}
|
||||
|
||||
[Authorize(Roles = "Administrator, Developer")]
|
||||
private void RefreshServiceReminderViewModel(
|
||||
UpdateServiceRemindersViewModel viewModel, Vehicle vehicle, bool setDefaultSelectedServiceReminders = false)
|
||||
{
|
||||
@@ -186,6 +205,7 @@ namespace MileageTraker.Web.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[Authorize(Roles = "Administrator, Developer")]
|
||||
public ActionResult Edit(int id)
|
||||
{
|
||||
var vehicleService = DataService.GetVehicleService(id);
|
||||
@@ -193,6 +213,7 @@ namespace MileageTraker.Web.Controllers
|
||||
return View(viewModel);
|
||||
}
|
||||
|
||||
[Authorize(Roles = "Administrator, Developer")]
|
||||
public ActionResult Delete(int id)
|
||||
{
|
||||
var vehicleService = DataService.GetVehicleService(id);
|
||||
@@ -200,6 +221,7 @@ namespace MileageTraker.Web.Controllers
|
||||
return View(viewModel);
|
||||
}
|
||||
|
||||
[Authorize(Roles = "Administrator, Developer")]
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ActionLog]
|
||||
public ActionResult DeleteConfirmed(int id)
|
||||
@@ -210,6 +232,7 @@ namespace MileageTraker.Web.Controllers
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
[Authorize(Roles = "Administrator, Developer")]
|
||||
[HttpPost]
|
||||
[ActionLog]
|
||||
public ActionResult Edit(VehicleServiceViewModel viewModel)
|
||||
|
||||
Reference in New Issue
Block a user