Fuel Log Match

This commit is contained in:
2015-09-22 21:11:47 -04:00
parent 27375bbb65
commit 829d84d73e
18 changed files with 748 additions and 233 deletions
@@ -0,0 +1,53 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using AutoMapper;
namespace MileageTraker.Web.ViewModels.FuelLog
{
public class FuelLogIndexViewModel
{
[HiddenInput(DisplayValue = false)]
public int FuelLogId { get; set; }
[DataType(DataType.Date)]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:d}")]
public DateTime Date { get; set; }
[StringLength(128)]
[Display(Name = "Driver Name")]
public string DriverFullName { get; set; }
[Display(Name = "Tag#")]
public string TagNumber { get; set; }
public int Odometer { get; set; }
[Display(Name = "MPG")]
public double MPG { get; set; }
[Display(Name = "Gas Purchased")]
public double GasPurchased { get; set; }
[Display(Name = "Total Price")]
public decimal TotalPrice { get; set; }
// Matched log
[HiddenInput(DisplayValue = false)]
public int? LogId { get; set; }
static FuelLogIndexViewModel()
{
Mapper.CreateMap<Models.FuelLog, FuelLogIndexViewModel>()
.ForMember(dest => dest.LogId,
opt => opt.ResolveUsing(
fl => fl.Log != null ? (int?)fl.Log.LogId : null
));
}
public FuelLogIndexViewModel(Models.FuelLog fuelLog)
{
Mapper.Map(fuelLog, this);
}
}
}