using System.ComponentModel.DataAnnotations; 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 int TripCount { get; set; } [DisplayFormat(DataFormatString = "{0:0.000}")] public double MilesPerGallon { get { return GasPurchased == 0 || Miles == 0 ? 0 : Miles / GasPurchased; } } } }