Add TSV support.
Import Upload
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Web;
|
||||
|
||||
namespace MileageTraker.Web.ViewModels.FuelLog
|
||||
{
|
||||
public class FuelLogImportUploadViewModel
|
||||
{
|
||||
[Required]
|
||||
[Display(Name = "FuelMan CSV File")]
|
||||
public HttpPostedFileBase File { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System.Collections.Generic;
|
||||
using MileageTraker.Web.Models;
|
||||
using MileageTraker.Web.ViewModels.Log;
|
||||
|
||||
namespace MileageTraker.Web.ViewModels.FuelLog
|
||||
{
|
||||
public class FuelLogResultsViewModel
|
||||
{
|
||||
public IEnumerable<Models.FuelLog> Logs { get; set; }
|
||||
public Dictionary<string, List<string>> AvailableYearMonths { get; set; }
|
||||
public IEnumerable<string> SelectedYearMonths{get
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Year))
|
||||
return AvailableYearMonths[Year];
|
||||
return new List<string>();
|
||||
}}
|
||||
|
||||
// filter parameters
|
||||
public string Year { get; set; }
|
||||
public string Month { get; set; }
|
||||
|
||||
public FuelLogResultsViewModel(IEnumerable<Models.FuelLog> logs, FuelLogQueryViewModel query, Dictionary<string, List<string>> availableYearMonths)
|
||||
{
|
||||
Logs = logs;
|
||||
AvailableYearMonths = availableYearMonths;
|
||||
Year = query.Year.HasValue ? query.Year.Value.ToString() : string.Empty;
|
||||
Month = query.Month.HasValue ? query.Month.Value.ToString() : string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MileageTraker.Web.ViewModels.FuelLog
|
||||
{
|
||||
public class FuelLogQueryViewModel
|
||||
{
|
||||
public int? Year { get; set; }
|
||||
public int? Month { get; set; }
|
||||
|
||||
public string YearMonthStart {get
|
||||
{
|
||||
return string.Format("{0}-{1:00}", Year, Month);
|
||||
}}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
var v = new List<string>();
|
||||
|
||||
if (Year.HasValue && Month.HasValue)
|
||||
{
|
||||
var str = YearMonthStart;
|
||||
|
||||
v.Add(str);
|
||||
}
|
||||
else if (Year.HasValue)
|
||||
{
|
||||
v.Add(Year.ToString());
|
||||
}
|
||||
|
||||
return String.Join("_", v).Replace(' ', '-');
|
||||
}
|
||||
|
||||
public bool HasParameters()
|
||||
{
|
||||
return Year.HasValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user