public Models.ui.BookingConfirmUI CreateBooking(Models.ui.BookingCreateUI car, int userId) { var result = new BookingConfirmUI(); var supplierObj = new SupplierBObj(); var carObj = new CarBObj(supplierObj); var booking = new BookingBObj(carObj, supplierObj); var startDate = car.fromDate; var endDate = car.toDate; var car_reg = car.car_reg; var carId = db.getCarIdByReg(car_reg); Car carDb = db.getCar(carId); carObj.setId(carId); carObj.setDailyRate(carDb.cost_per_day); booking.setBookingRange(startDate, endDate); var dbUnavailabilities = db.listUnavailabilitiesForCar(carId); var unavailabilities = new List<UnavailableDateBObj>(); foreach (var u in dbUnavailabilities) { var unavailable = new UnavailableDateBObj { fromDate = u.start_date, toDate = u.end_date }; unavailabilities.Add(unavailable); } car.valid = booking.valid(unavailabilities); if (car.valid) { car.amount = booking.getTotalCost(); UnavailableDateBObj date = booking.create(); var customer_id = userId; result.BookingId = db.createNewBooking(customer_id, carId, startDate, endDate); } result.CarReg = car_reg; result.Cost = booking.getTotalCost(); return result; }
public BookingBObj(CarBObj car, SupplierBObj supplier) { this._car = car; this._supplier = supplier; }
public Models.ui.BookingCreateUI ShowChosenCar(BookingCreateUI car) { var supplierObj = new SupplierBObj(); var carObj = new CarBObj(supplierObj); var booking = new BookingBObj(carObj, supplierObj); var startDate = car.fromDate; var endDate = car.toDate; var car_reg = car.car.car_reg; var carId = db.getCarIdByReg(car_reg); carObj.setId(carId); booking.setBookingRange(startDate, endDate); var dbUnavailabilities = db.listUnavailabilitiesForCar(carId); var unavailabilities = new List<UnavailableDateBObj>(); foreach (var u in dbUnavailabilities) { var unavailable = new UnavailableDateBObj{ fromDate = u.start_date, toDate = u.end_date }; unavailabilities.Add(unavailable); } car.valid = booking.valid(unavailabilities); car.amount = booking.getTotalCost(); return car; }
public CarBObj(SupplierBObj supplier) { _supplier = supplier; }