Get export working for Vehicle Service
This commit is contained in:
@@ -60,7 +60,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
var vm = new FuelLogViewModel(fuelLog) { VehicleId = DataService.GetVehicleIdByTag(fuelLog.TagNumber) };
|
var vm = new FuelLogViewModel(fuelLog) { VehicleId = DataService.GetVehicleIdByTag(fuelLog.TagNumber) };
|
||||||
return View(vm);
|
return View(vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ViewResult Match(int id)
|
public ViewResult Match(int id)
|
||||||
{
|
{
|
||||||
var fuelLog = DataService.GetFuelLog(id);
|
var fuelLog = DataService.GetFuelLog(id);
|
||||||
@@ -89,6 +89,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
return View(matchViewModel);
|
return View(matchViewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ActionLog]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public ActionResult Match(int fuelLogId, int logId)
|
public ActionResult Match(int fuelLogId, int logId)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,6 +31,26 @@ namespace MileageTraker.Web.Controllers
|
|||||||
return View(viewModel);
|
return View(viewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ActionLog]
|
||||||
|
public ActionResult Export(VehicleServiceQueryViewModel query)
|
||||||
|
{
|
||||||
|
var validVehicleServiceYearMonths = DataService.GetValidVehicleServiceMonths();
|
||||||
|
|
||||||
|
if (!validVehicleServiceYearMonths.Any()) // this means no logs in DB
|
||||||
|
return View("Empty");
|
||||||
|
|
||||||
|
// default parameter processing
|
||||||
|
query.SetDefaultParameters(validVehicleServiceYearMonths);
|
||||||
|
|
||||||
|
var vehicleServices = DataService.FilterVehicleServices(DataService.GetVehicleServices(), query).ToList();
|
||||||
|
var filteredServices = vehicleServices.Select(vs => new VehicleServiceViewModel(vs));
|
||||||
|
|
||||||
|
var name = string.Format("VehicleServices_{0}", query);
|
||||||
|
|
||||||
|
var export = ExcelWriter<VehicleServiceViewModel>.WriteXls(filteredServices, name, name);
|
||||||
|
return File(export, "application/ms-excel", name + ".xls");
|
||||||
|
}
|
||||||
|
|
||||||
public ViewResult Details(int id)
|
public ViewResult Details(int id)
|
||||||
{
|
{
|
||||||
var vehicleService = DataService.GetVehicleService(id);
|
var vehicleService = DataService.GetVehicleService(id);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
@{
|
@{
|
||||||
ViewBag.Title = "Fuel Logs";
|
ViewBag.Title = "Fuel Logs";
|
||||||
var grid = new WebGrid(Model.FuelLogs, rowsPerPage: 45);
|
var grid = new WebGrid(Model.FuelLogs, rowsPerPage: 45);
|
||||||
var parameters = new {FiscalYear = Model.Year, Model.Month, Model.Unmatched};
|
var queryParams = new {FiscalYear = Model.Year, Model.Month, Model.Unmatched};
|
||||||
}
|
}
|
||||||
|
|
||||||
@section Scripts {
|
@section Scripts {
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
<div class="btn-toolbar clearfix">
|
<div class="btn-toolbar clearfix">
|
||||||
@Html.ActionLink("Import", "ImportUpload", null, new { @class = "btn" })
|
@Html.ActionLink("Import", "ImportUpload", null, new { @class = "btn" })
|
||||||
@Html.ActionLink("Export", "Export", parameters, new { @class = "btn" })
|
@Html.ActionLink("Export", "Export", queryParams, new { @class = "btn" })
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
@{
|
@{
|
||||||
ViewBag.Title = "Logs";
|
ViewBag.Title = "Logs";
|
||||||
var grid = new WebGrid(Model.Logs, rowsPerPage: 45);
|
var grid = new WebGrid(Model.Logs, rowsPerPage: 45);
|
||||||
var parameters = new {Model.Year, Model.Month, Model.LogType, Model.MonthRange, Model.VehicleId, Model.EmployeeName};
|
var queryParams = new {Model.Year, Model.Month, Model.LogType, Model.MonthRange, Model.VehicleId, Model.EmployeeName};
|
||||||
}
|
}
|
||||||
@section Styles {
|
@section Styles {
|
||||||
<link href="@Url.Content("~/Content/VehicleColors.css")" rel="stylesheet" type="text/css" />
|
<link href="@Url.Content("~/Content/VehicleColors.css")" rel="stylesheet" type="text/css" />
|
||||||
@@ -36,16 +36,16 @@
|
|||||||
<div class="btn-toolbar clearfix">
|
<div class="btn-toolbar clearfix">
|
||||||
@Html.ActionLink("Add New Log", "Create", null, new { @class = "btn" })
|
@Html.ActionLink("Add New Log", "Create", null, new { @class = "btn" })
|
||||||
@Html.ActionLink("Import", "ImportUpload", null, new { @class = "btn"})
|
@Html.ActionLink("Import", "ImportUpload", null, new { @class = "btn"})
|
||||||
@Html.ActionLink("Export", "Export", parameters, new { @class = "btn" })
|
@Html.ActionLink("Export", "Export", queryParams, new { @class = "btn" })
|
||||||
|
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">Report <span class="caret"></span></a>
|
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">Report <span class="caret"></span></a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li>
|
<li>
|
||||||
@Html.ActionLink("Vehicle Mileage", "MonthlyVehicleMileage", parameters)
|
@Html.ActionLink("Vehicle Mileage", "MonthlyVehicleMileage", queryParams)
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
@Html.ActionLink("Driver Mileage", "MonthlyDriverMileage", parameters)
|
@Html.ActionLink("Driver Mileage", "MonthlyDriverMileage", queryParams)
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
@{
|
@{
|
||||||
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 };
|
||||||
}
|
}
|
||||||
|
|
||||||
@section Scripts {
|
@section Scripts {
|
||||||
@@ -29,7 +30,7 @@
|
|||||||
|
|
||||||
<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", "Create", null, new{@class="btn"})
|
||||||
@Html.ActionLink("Export", "Export", null, new{@class="btn"})
|
@Html.ActionLink("Export", "Export", queryParams, new{@class="btn"})
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@grid.GetHtml(columns:
|
@grid.GetHtml(columns:
|
||||||
|
|||||||
Reference in New Issue
Block a user