Replace previous log search for log detail page
This commit is contained in:
@@ -85,11 +85,10 @@ namespace MileageTraker.Web.Controllers
|
|||||||
public ActionResult PreviousDetails(int id)
|
public ActionResult PreviousDetails(int id)
|
||||||
{
|
{
|
||||||
var log = _dataService.GetLog(id);
|
var log = _dataService.GetLog(id);
|
||||||
var previousLog = _dataService.SearchPreviousLog(log);
|
|
||||||
int logId;
|
int logId;
|
||||||
if (previousLog != null)
|
if (log.VehiclePreviousLog != null)
|
||||||
{
|
{
|
||||||
logId = previousLog.LogId;
|
logId = log.VehiclePreviousLog.LogId;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -101,8 +100,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
|
|
||||||
public ActionResult NextDetails(int id)
|
public ActionResult NextDetails(int id)
|
||||||
{
|
{
|
||||||
var log = _dataService.GetLog(id);
|
var nextLog = _dataService.GetNextLog(id);
|
||||||
var nextLog = _dataService.SearchNextLog(log);
|
|
||||||
int logId;
|
int logId;
|
||||||
if (nextLog != null)
|
if (nextLog != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -73,10 +73,7 @@ namespace MileageTraker.Web.DAL
|
|||||||
{
|
{
|
||||||
var log = _db.Logs.Find(id);
|
var log = _db.Logs.Find(id);
|
||||||
|
|
||||||
var nextLog =
|
var nextLog = GetNextLog(log.LogId);
|
||||||
(from l in _db.Logs
|
|
||||||
where l.VehiclePreviousLogId == log.LogId
|
|
||||||
select l).FirstOrDefault();
|
|
||||||
if (nextLog != null)
|
if (nextLog != null)
|
||||||
nextLog.VehiclePreviousLog = log.VehiclePreviousLog;
|
nextLog.VehiclePreviousLog = log.VehiclePreviousLog;
|
||||||
|
|
||||||
@@ -96,6 +93,14 @@ namespace MileageTraker.Web.DAL
|
|||||||
return _db.Logs.Find(id);
|
return _db.Logs.Find(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Log GetNextLog(int id)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
(from l in _db.Logs
|
||||||
|
where l.VehiclePreviousLogId == id
|
||||||
|
select l).FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerable<int> GetValidLogYears()
|
public IEnumerable<int> GetValidLogYears()
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user