Fuel Log Import basic functionality
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using AutoMapper;
|
||||
|
||||
namespace MileageTraker.Web.ViewModels.FuelLog
|
||||
{
|
||||
public class ImportFuelLogViewModel
|
||||
{
|
||||
public int FuelLogId { get; set; }
|
||||
|
||||
[Required]
|
||||
[DataType(DataType.Date)]
|
||||
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:d}")]
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(128)]
|
||||
public string DriverFullName { get; set; }
|
||||
|
||||
[Required]
|
||||
[Display(Name = "Tag#")]
|
||||
public string TagNumber { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Odometer { get; set; }
|
||||
|
||||
[StringLength(64)]
|
||||
public string CityName { get; set; }
|
||||
|
||||
public double MPG { get; set; }
|
||||
|
||||
[Required]
|
||||
public double GasPurchased { get; set; }
|
||||
|
||||
[Required]
|
||||
public decimal TotalPrice { get; set; }
|
||||
|
||||
public bool PreviouslyAdded { get; set; }
|
||||
|
||||
public int? LogId { get; set; }
|
||||
|
||||
static ImportFuelLogViewModel()
|
||||
{
|
||||
Mapper.CreateMap<ImportFuelLogViewModel, Models.FuelLog>();
|
||||
Mapper.CreateMap<Models.FuelLog, ImportFuelLogViewModel>()
|
||||
.ForMember(dest => dest.LogId,
|
||||
opt => opt.ResolveUsing(
|
||||
fl => fl.Log != null ? (int?)fl.Log.LogId : null
|
||||
));
|
||||
}
|
||||
|
||||
public ImportFuelLogViewModel(Models.FuelLog fuelLog)
|
||||
{
|
||||
Mapper.Map(fuelLog, this);
|
||||
}
|
||||
|
||||
public ImportFuelLogViewModel()
|
||||
{
|
||||
}
|
||||
|
||||
public Models.FuelLog GetFuelLog()
|
||||
{
|
||||
var log = new Models.FuelLog();
|
||||
Mapper.Map(this, log);
|
||||
return log;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace MileageTraker.Web.ViewModels.FuelLog
|
||||
{
|
||||
public class ImportMatchedLogViewModel
|
||||
{
|
||||
public int LogId { get; set; }
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -3,10 +3,10 @@ using System.Web;
|
||||
|
||||
namespace MileageTraker.Web.ViewModels.FuelLog
|
||||
{
|
||||
public class FuelLogImportUploadViewModel
|
||||
public class ImportUploadViewModel
|
||||
{
|
||||
[Required]
|
||||
[Display(Name = "FuelMan CSV File")]
|
||||
[Display(Name = @"FuelMan CSV/Text Data File")]
|
||||
public HttpPostedFileBase File { get; set; }
|
||||
}
|
||||
}
|
||||
+5
-6
@@ -1,10 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using MileageTraker.Web.Models;
|
||||
using MileageTraker.Web.ViewModels.Log;
|
||||
using System.Globalization;
|
||||
|
||||
namespace MileageTraker.Web.ViewModels.FuelLog
|
||||
{
|
||||
public class FuelLogResultsViewModel
|
||||
public class ResultsViewModel
|
||||
{
|
||||
public IEnumerable<Models.FuelLog> Logs { get; set; }
|
||||
public Dictionary<string, List<string>> AvailableYearMonths { get; set; }
|
||||
@@ -19,12 +18,12 @@ namespace MileageTraker.Web.ViewModels.FuelLog
|
||||
public string Year { get; set; }
|
||||
public string Month { get; set; }
|
||||
|
||||
public FuelLogResultsViewModel(IEnumerable<Models.FuelLog> logs, FuelLogQueryViewModel query, Dictionary<string, List<string>> availableYearMonths)
|
||||
public ResultsViewModel(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;
|
||||
Year = query.Year.HasValue ? query.Year.Value.ToString(CultureInfo.InvariantCulture) : string.Empty;
|
||||
Month = query.Month.HasValue ? query.Month.Value.ToString(CultureInfo.InvariantCulture) : string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user