public double GetPriceByRentType(List <RentType> rentType, Rent lapse) { int rentByLapse = (int)lapse; RentType getPriceByRentType = rentType.Where(r => r.RentTypeId == rentByLapse).First(); double getPrice = GetPrice(getPriceByRentType); return(getPrice); }
public BookOrder ApplyFamilyDiscount(BookOrder bookOrder, RentType rentType) { if (IsFamilyDiscount(bookOrder)) { // we change the value of the object bookOrder using reflection to avoid create a new object double bookOrderWithDiscount = (bookOrder.Price * bookOrder.Bikes.Count()) - ((bookOrder.Price * bookOrder.Bikes.Count()) * DISCOUNT); bookOrder.GetType().GetProperty("Price").SetValue(bookOrder, bookOrderWithDiscount, null); //we assign True to field ApplyFamilyDiscount bookOrder.GetType().GetProperty("ApplyFamilyDiscount").SetValue(bookOrder, true, null); return(bookOrder); } else { return(bookOrder); } }
public double GetPrice(RentType rentType) { return(rentType.Price); }