Combine layouts
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using MileageTraker.Web.Attributes;
|
||||
using MileageTraker.Web.DAL;
|
||||
using MileageTraker.Web.Models;
|
||||
using MileageTraker.Web.Utility;
|
||||
@@ -13,24 +14,22 @@ namespace MileageTraker.Web.Controllers
|
||||
[Authorize(Roles = "Administrator, Developer")]
|
||||
public class LogController : ControllerBase
|
||||
{
|
||||
private readonly DataService _dataService = new DataService();
|
||||
|
||||
public ViewResult Index(LogQueryViewModel query)
|
||||
{
|
||||
var logs = _dataService.GetLogs();
|
||||
var logs = DataService.GetLogs();
|
||||
|
||||
var validLogYears = _dataService.GetValidLogYears().ToList();
|
||||
var validLogYears = DataService.GetValidLogYears().ToList();
|
||||
if (!validLogYears.Any())
|
||||
return View("Empty");
|
||||
if (!query.Year.HasValue)
|
||||
query.Year = validLogYears.FirstOrDefault();
|
||||
|
||||
var validLogMonths = _dataService.GetValidLogMonths(query.Year.Value).ToList();
|
||||
var validLogMonths = DataService.GetValidLogMonths(query.Year.Value).ToList();
|
||||
if (!query.Month.HasValue)
|
||||
query.Month = validLogMonths.FirstOrDefault();
|
||||
|
||||
var filteredLogs =
|
||||
from log in _dataService.GetLogIndexViewModels(DataService.FilterLogs(logs, query))
|
||||
from log in DataService.GetLogIndexViewModels(DataService.FilterLogs(logs, query))
|
||||
orderby log.Created descending
|
||||
select log;
|
||||
|
||||
@@ -53,7 +52,7 @@ namespace MileageTraker.Web.Controllers
|
||||
[ActionLog]
|
||||
public ActionResult Export(LogQueryViewModel query)
|
||||
{
|
||||
var logs = _dataService.GetLogs();
|
||||
var logs = DataService.GetLogs();
|
||||
var name = string.Format(
|
||||
"MileageLogs{0}-{1}{2}",
|
||||
query.Year,
|
||||
@@ -66,7 +65,7 @@ namespace MileageTraker.Web.Controllers
|
||||
|
||||
public ViewResult MonthlyVehicleMileage(LogQueryViewModel query)
|
||||
{
|
||||
var items = _dataService.GetMonthlyVehicleMileageItems(query);
|
||||
var items = DataService.GetMonthlyVehicleMileageItems(query);
|
||||
|
||||
var report = new VehicleMileageViewModel (items, query);
|
||||
|
||||
@@ -75,7 +74,7 @@ namespace MileageTraker.Web.Controllers
|
||||
|
||||
public ActionResult MonthlyEmployeeMileage(LogQueryViewModel query)
|
||||
{
|
||||
var items = _dataService.GetMonthlyEmployeeMileageItems(query);
|
||||
var items = DataService.GetMonthlyEmployeeMileageItems(query);
|
||||
|
||||
var report = new EmployeeMileageViewModel(items, query);
|
||||
|
||||
@@ -84,13 +83,13 @@ namespace MileageTraker.Web.Controllers
|
||||
|
||||
public ViewResult Details(int id)
|
||||
{
|
||||
var log = _dataService.GetLog(id);
|
||||
var log = DataService.GetLog(id);
|
||||
return View(log);
|
||||
}
|
||||
|
||||
public ActionResult PreviousDetails(int id)
|
||||
{
|
||||
var log = _dataService.GetLog(id);
|
||||
var log = DataService.GetLog(id);
|
||||
int logId;
|
||||
if (log.VehiclePreviousLog != null)
|
||||
{
|
||||
@@ -106,7 +105,7 @@ namespace MileageTraker.Web.Controllers
|
||||
|
||||
public ActionResult NextDetails(int id)
|
||||
{
|
||||
var nextLog = _dataService.GetNextLog(id);
|
||||
var nextLog = DataService.GetNextLog(id);
|
||||
int logId;
|
||||
if (nextLog != null)
|
||||
{
|
||||
@@ -142,7 +141,7 @@ namespace MileageTraker.Web.Controllers
|
||||
log.UserHostAddress = HttpContext.Request.UserHostAddress;
|
||||
log.UserAgent = HttpContext.Request.UserAgent;
|
||||
|
||||
_dataService.AddLog(log);
|
||||
DataService.AddLog(log);
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
@@ -151,7 +150,7 @@ namespace MileageTraker.Web.Controllers
|
||||
|
||||
public ActionResult Edit(int id)
|
||||
{
|
||||
var log = _dataService.GetLog(id);
|
||||
var log = DataService.GetLog(id);
|
||||
return View(log);
|
||||
}
|
||||
|
||||
@@ -162,7 +161,7 @@ namespace MileageTraker.Web.Controllers
|
||||
RemoveModelStateErrors();
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_dataService.UpdateLog(log);
|
||||
DataService.UpdateLog(log);
|
||||
return RedirectToAction("Details", new{id = log.LogId});
|
||||
}
|
||||
return View(log);
|
||||
@@ -179,7 +178,7 @@ namespace MileageTraker.Web.Controllers
|
||||
|
||||
public ActionResult Delete(int id)
|
||||
{
|
||||
var log = _dataService.GetLog(id);
|
||||
var log = DataService.GetLog(id);
|
||||
return View(log);
|
||||
}
|
||||
|
||||
@@ -187,7 +186,7 @@ namespace MileageTraker.Web.Controllers
|
||||
[ActionLog]
|
||||
public ActionResult DeleteConfirmed(int id)
|
||||
{
|
||||
_dataService.DeleteLog(id);
|
||||
DataService.DeleteLog(id);
|
||||
|
||||
if (Session["LogPage"] != null)
|
||||
return Redirect((string) Session["LogPage"]);
|
||||
@@ -196,20 +195,14 @@ namespace MileageTraker.Web.Controllers
|
||||
|
||||
public JsonResult GetValidLogMonths(int year)
|
||||
{
|
||||
var validLogMonths = _dataService.GetValidLogMonths(year);
|
||||
var validLogMonths = DataService.GetValidLogMonths(year);
|
||||
return Json(validLogMonths, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
public PartialViewResult DetailsPartial(int id)
|
||||
{
|
||||
var log = _dataService.GetLog(id);
|
||||
var log = DataService.GetLog(id);
|
||||
return PartialView(new LogPartialDetails(log));
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
_dataService.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user