コード例 #1
0
        public ActionResult BookingCalculateDiscount(BookingViewModel bookingvm)
        {
            decimal initalPrice = _rooms.Find(bookingvm.Room.Id).Price;
            var     date        = bookingvm.Date;

            var newPrice = _discountRepo.MondayAndTuesdayDiscount(date, initalPrice);

            newPrice = _discountRepo.WeekOfTheYearDiscount(date, newPrice);
            newPrice = _discountRepo.NumberOfRoomsDiscount(_rooms.GetAll().Count(), newPrice);
            newPrice = _discountRepo.AlphabeticDiscount(newPrice, bookingvm.Guests);

            newPrice = _discountRepo.DiceDubbelerDiscount(newPrice, initalPrice);
            newPrice = _discountRepo.CheckDiscount(newPrice, initalPrice);

            bookingvm.Room     = _rooms.Find(bookingvm.Room.Id);
            bookingvm.Price    = newPrice;
            bookingvm.Discount = Math.Round(_discountRepo.CurrentDiscountCalculator(newPrice, initalPrice), 2);

            return(View(bookingvm));
        }