/************ * BOOKINGS * ************/ public Booking CreateBooking(string hotelName, BookingConstraints constraints, string guestName) { var hotel = GetHotel(hotelName); if (hotel == null) { throw new ArgumentException("There exists no hotel with the given name."); } foreach (RoomDetails rd in hotel.GetFreeRooms(constraints.StartDate, constraints.EndDate)) { if (rd.SmokingAllowed.Equals(constraints.SmokingAllowed) && constraints.NbOfBeds <= rd.NbOfBeds && constraints.MaxPricePerNight >= rd.PricePerNight) { return(new Booking { Guest = guestName, StartDate = constraints.StartDate, EndDate = constraints.EndDate, RoomNb = rd.RoomNb, HotelName = hotel.Name, Price = calc.CalculatePrice(rd.PricePerNight, constraints.StartDate, constraints.EndDate) }); } } throw new BookingException("No room to satisfy the given booking constraints."); }
public async Task <ApiResult <List <PriceSelectDto> > > CalculatePrice(AttributeDto dto, CancellationToken cancellationToken) { var attribute = dto.ToEntity(_mapper); var resultDto = await _priceCalculation.CalculatePrice(attribute, dto.CategoryId, cancellationToken); return(resultDto); }
public ActionResult ReserveGun(int gunId) { var ggun = gunrepo.GetGun(gunId); var date = DateTime.Now; var parameters = new PriceCalculationParameters() { gun = ggun }; var reservation = resserv.Reserve(ggun); var model = new ReservationViewModel() { Reservation = reservation, gun = ggun, PriceComponents = price.CalculatePrice(parameters), Date = date, }; return(View(model)); }
protected override IEnumerable <ProductPrice> GetProductPrice(IList <PriceMatrix> priceMatrixList, PricingServiceParameter pricingServiceParameter, PriceMatrix selectedPriceMatrix, bool regularPrice) { List <ProductPrice> productPriceList = new List <ProductPrice>(); List <PriceBracket> matrixBrackets = this.GetMatrixBrackets(selectedPriceMatrix); CurrencyDto currency = this.GetCurrency(selectedPriceMatrix.CurrencyCode); Decimal basePrice = this.GetBasePrice(pricingServiceParameter); foreach (PriceBracket priceBracket1 in matrixBrackets) { PriceData priceData1 = new PriceData(); priceData1.PricingServiceParameter = pricingServiceParameter; Product product = this.Product; priceData1.Product = product; Customer billTo = this.BillTo; priceData1.BillTo = billTo; Customer shipTo = GetSiteContextShipTo();//BUSA-42 : Duplicate Customers on Production. priceData1.ShipTo = shipTo; List <PriceBracket> priceBracketList = matrixBrackets; priceData1.MatrixBrackets = priceBracketList; PriceBracket priceBracket2 = priceBracket1; priceData1.PriceBracket = priceBracket2; if (selectedPriceMatrix.RecordType.EqualsIgnoreCase("Product")) { var priceBracket = GetAllCustomerItemPriceBracket(); if (priceBracket != null) { priceData1.PriceBracket.AdjustmentType = priceBracket.AdjustmentType; priceData1.PriceBracket.PriceBasis = priceBracket.PriceBasis; priceData1.PriceBracket.Amount = priceBracket.Amount; priceData1.PriceBracket.AltAmount = priceBracket.AltAmount; } } Decimal num = basePrice; priceData1.BasePrice = num; string calculationFlags = selectedPriceMatrix.CalculationFlags; priceData1.CalculationFlags = calculationFlags; if (selectedPriceMatrix.RecordType.EqualsIgnoreCase("Product")) { priceData1.TempBasis = priceData1.PriceBracket.AltAmount; } else { priceData1.TempBasis = this.GetTempBasisValue(priceBracket1.PriceBasis, priceMatrixList, pricingServiceParameter, regularPrice); } PriceData priceData = priceData1; IPriceCalculation priceCalculation = this.PriceCalculations.FirstOrDefault <IPriceCalculation>((Func <IPriceCalculation, bool>)(r => r.IsMatch(priceData))); if (priceCalculation != null) { ProductPrice productPrice = new ProductPrice(); productPrice.BreakQty = priceData.PriceBracket.BreakQty; if (regularPrice) { //Start:Revert BUSA 682 :The Base price of the product in ERP and the base price of the same product on the PDP are different.Revert BUSA: 696 Acct #78803:1076826 - Product (5011768U0) price differs in ERP and on the PDP. var price = GetPriceListAmount("P2"); productPrice.Price = !string.IsNullOrEmpty(price) ? Convert.ToDecimal(price) : this.GetBasePrice(pricingServiceParameter); //productPrice.Price = !string.IsNullOrEmpty(price) ? Convert.ToDecimal(price) : this.Product.BasicListPrice; //End:Revert BUSA 682 :The Base price of the product in ERP and the base price of the same product on the PDP are different.Revert BUSA: 696 Acct #78803:1076826 - Product (5011768U0) price differs in ERP and on the PDP. } else { productPrice.Price = priceCalculation.CalculatePrice(priceData); } productPrice.Price = this.ApplyProductMultiplier(pricingServiceParameter, productPrice.Price); productPrice.Price = selectedPriceMatrix.UnitOfMeasure == pricingServiceParameter.UnitOfMeasure || selectedPriceMatrix.UnitOfMeasure.IsBlank() && pricingServiceParameter.UnitOfMeasure == this.Product.UnitOfMeasure || priceBracket1.PriceBasis.Equals("CLM", StringComparison.OrdinalIgnoreCase) ? productPrice.Price : this.AdjustForUnitOfMeasure(pricingServiceParameter, productPrice.Price); productPrice.PriceDisplay = this.CurrencyFormatProvider.GetString(productPrice.Price, currency); productPriceList.Add(productPrice); } } return(productPriceList); }