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); } } } }
public BookingService(IPriceCalculation calculation) { db = new HotelContext(); calc = calculation; }
public ManagementService() { db = new HotelContext(); }