public ParkingInput(int days, int hours, int minutes, EparkRate eParkRate) { Days = days; Hours = hours; Minutes = minutes; ParkRate = eParkRate; }
public ParkRate(EparkRate eparkRate) { Name = eparkRate.ToDescriptionString(); switch (eparkRate) { case EparkRate.ParkRate0: throw new Exception("Le Forfait n'est pas défini"); case EparkRate.ParkRate1: PriceFor20Minutes = 6; MaxPricePerDay = 37; break; case EparkRate.ParkRate2: PriceFor20Minutes = 6; MaxPricePerDay = 30; break; case EparkRate.ParkRate3: PriceFor20Minutes = 12; MaxPricePerDay = 42; break; default: throw new Exception("Le Forfait n'est pas défini"); } }
public static string ToDescriptionString(this EparkRate val) { DescriptionAttribute[] attributes = (DescriptionAttribute[])val.GetType().GetField(val.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false); return(attributes.Length > 0 ? attributes[0].Description : string.Empty); }