Add filtering
Improve matching
This commit is contained in:
@@ -5,27 +5,28 @@ namespace MileageTraker.Web.ViewModels.FuelLog
|
||||
{
|
||||
public class FuelLogQueryViewModel
|
||||
{
|
||||
public int? Year { get; set; }
|
||||
public int? FiscalYear { get; set; }
|
||||
public int? Month { get; set; }
|
||||
public bool Unmatched { get; set; }
|
||||
|
||||
public string YearMonthStart {get
|
||||
{
|
||||
return string.Format("{0}-{1:00}", Year, Month);
|
||||
return string.Format("{0}-{1:00}", FiscalYear, Month);
|
||||
}}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
var v = new List<string>();
|
||||
|
||||
if (Year.HasValue && Month.HasValue)
|
||||
if (FiscalYear.HasValue && Month.HasValue)
|
||||
{
|
||||
var str = YearMonthStart;
|
||||
|
||||
v.Add(str);
|
||||
}
|
||||
else if (Year.HasValue)
|
||||
else if (FiscalYear.HasValue)
|
||||
{
|
||||
v.Add(Year.ToString());
|
||||
v.Add(FiscalYear.ToString());
|
||||
}
|
||||
|
||||
return String.Join("_", v).Replace(' ', '-');
|
||||
@@ -33,7 +34,7 @@ namespace MileageTraker.Web.ViewModels.FuelLog
|
||||
|
||||
public bool HasParameters()
|
||||
{
|
||||
return Year.HasValue;
|
||||
return FiscalYear.HasValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-6
@@ -3,27 +3,29 @@ using System.Globalization;
|
||||
|
||||
namespace MileageTraker.Web.ViewModels.FuelLog
|
||||
{
|
||||
public class ResultsViewModel
|
||||
public class FuelLogResultsViewModel
|
||||
{
|
||||
public IEnumerable<FuelLogIndexViewModel> FuelLogs { get; set; }
|
||||
public Dictionary<string, List<string>> AvailableYearMonths { get; set; }
|
||||
public IEnumerable<string> SelectedYearMonths{get
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Year))
|
||||
return AvailableYearMonths[Year];
|
||||
if (!string.IsNullOrEmpty(FiscalYear))
|
||||
return AvailableYearMonths[FiscalYear];
|
||||
return new List<string>();
|
||||
}}
|
||||
|
||||
// filter parameters
|
||||
public string Year { get; set; }
|
||||
public string FiscalYear { get; set; }
|
||||
public string Month { get; set; }
|
||||
public bool Unmatched { get; set; }
|
||||
|
||||
public ResultsViewModel(IEnumerable<FuelLogIndexViewModel> fuelLogs, FuelLogQueryViewModel query, Dictionary<string, List<string>> availableYearMonths)
|
||||
public FuelLogResultsViewModel(IEnumerable<FuelLogIndexViewModel> fuelLogs, FuelLogQueryViewModel query, Dictionary<string, List<string>> availableYearMonths)
|
||||
{
|
||||
FuelLogs = fuelLogs;
|
||||
AvailableYearMonths = availableYearMonths;
|
||||
Year = query.Year.HasValue ? query.Year.Value.ToString(CultureInfo.InvariantCulture) : string.Empty;
|
||||
FiscalYear = query.FiscalYear.HasValue ? query.FiscalYear.Value.ToString(CultureInfo.InvariantCulture) : string.Empty;
|
||||
Month = query.Month.HasValue ? query.Month.Value.ToString(CultureInfo.InvariantCulture) : string.Empty;
|
||||
Unmatched = query.Unmatched;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace MileageTraker.Web.ViewModels.FuelLog
|
||||
{
|
||||
public class ImportMatchedLogViewModel
|
||||
{
|
||||
public int LogId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace MileageTraker.Web.ViewModels.FuelLog
|
||||
{
|
||||
public class MatchLinkViewModel
|
||||
{
|
||||
public int FuelLogId { get; set; }
|
||||
public int? LogId { get; set; }
|
||||
|
||||
public MatchLinkViewModel(Models.FuelLog fuelLog)
|
||||
{
|
||||
FuelLogId = fuelLog.FuelLogId;
|
||||
if (fuelLog.Log != null)
|
||||
LogId = fuelLog.Log.LogId;
|
||||
}
|
||||
|
||||
public MatchLinkViewModel(ImportFuelLogViewModel viewModel)
|
||||
{
|
||||
FuelLogId = viewModel.FuelLogId;
|
||||
if (viewModel.LogId != null)
|
||||
LogId = viewModel.LogId;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using MiscUtil.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MileageTraker.Web.ViewModels.Log
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user