using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; namespace MileageTraker.Web.ViewModels.Vehicle { public class VehicleMileageItem { public string VehicleId { get; set; } public int Miles { get; set; } public double GasPurchased { get; set; } public string Prog { get; set; } public IEnumerable> LogPairs { get; set; } public int TripCount { get { return LogPairs.Count(); } } [DisplayFormat(DataFormatString = "{0:0.000}")] public double MilesPerGallon { get { return GasPurchased == 0 || Miles == 0 ? 0 : Miles / GasPurchased; } } } }