示例#1
0
        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);
        }
示例#2
0
        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);
            }
        }
示例#3
0
 public double GetPrice(RentType rentType)
 {
     return(rentType.Price);
 }