Ejemplo n.º 1
0
 public double CalculatePrice(double pricePerNight, DateTime startDate, DateTime endDate)
 {
     using (var db = new HotelContext())
     {
         var normalPrice = pricePerNight * endDate.Subtract(startDate).Days;
         // TODO use authentication service
         // User user =
         string userId = null;
         if (userId == null)
             return normalPrice;
         else
         {
             UserProfile up = db.UserProfiles.Find(userId);
             if (up == null)
                 return normalPrice;
             else
             {
                 int discountPercentage = up.Discount.Value;
                 return normalPrice * (1.0 - discountPercentage / 100);
             }
         }
     }
 }
Ejemplo n.º 2
0
 public BookingService(IPriceCalculation calculation)
 {
     db = new HotelContext();
     calc = calculation;
 }
Ejemplo n.º 3
0
 public ManagementService()
 {
     db = new HotelContext();
 }