public async Task <CreateOfferResult> Handle(CreateOfferCommand request, CancellationToken cancellationToken) { //calculate price var priceParams = ConstructPriceParams(request); var price = await pricingService.CalculatePrice(priceParams); var o = Offer.ForPrice( priceParams.ProductCode, priceParams.PolicyFrom, priceParams.PolicyTo, null, price ); //create and save offer using (var uow = uowProvider.Create()) { uow.Offers.Add(o); uow.CommitChanges(); //return result return(ConstructResult(o)); } }
public AvailabilityResponse ProcessAvailability(HotelAvailabilityResponse response) { var result = new AvailabilityResponse(); result.CheckIn = response.CheckIn; result.CheckOut = response.CheckOut; var availableHotels = new List <AvailableHotel>(); foreach (var hotels in response.AvailableHotels) { var hotel = new AvailableHotel(); hotel.Code = hotels.Code; var rooms = new List <AvailableRoom>(); foreach (var room in hotels.AvailableRooms) { var data = new AvailableRoom(); data.Id = room.Id; data.Code = room.Code; data.Price = room.Price; data.NewPrice = _pricingService.CalculatePrice(response.CheckIn, response.CheckOut, room.Price); rooms.Add(data); } hotel.AvailableRooms = rooms; availableHotels.Add(hotel); } result.AvailableHotels = availableHotels; return(result); }
public float GetRoomPricing(int roomId) { var roomType = roomsRepository.GetRoomsType(roomId); var roomPrice = pricingService.CalculatePrice(roomType, ""); return(roomPrice); }
//DocSection:DisplayProduct /// <summary> /// Displays a product detail page of a product specified by ID of the product's page. /// </summary> /// <param name="id">Node ID of the product's page.</param> /// <param name="productAlias">Node alias of the product's page.</param> public ActionResult BasicDetail(int id, string productAlias) { // Gets the product from Kentico SKUTreeNode product = GetProduct(id); // If the product is not found or if it is not allowed for sale, redirects to error 404 if ((product == null) || (product.SKU == null) || !product.SKU.SKUEnabled) { return(HttpNotFound()); } // Redirects if the specified page alias does not match if (!string.IsNullOrEmpty(productAlias) && !product.NodeAlias.Equals(productAlias, StringComparison.InvariantCultureIgnoreCase)) { return(RedirectToActionPermanent("Detail", new { id = product.NodeID, productAlias = product.NodeAlias })); } // Initializes the view model of the product with a calculated price ShoppingCart cart = shoppingService.GetCurrentShoppingCart(); ProductViewModel viewModel = new ProductViewModel(product, pricingService.CalculatePrice(product.SKU, cart)); // Displays the product detail page return(View(viewModel)); }
private void ProcessShipment(Shipment shipment) { shipment.Price = _pricingService.CalculatePrice(shipment); (decimal? price, decimal? discount) = _pricingService.CalculatePriceDiscount(shipment); if (discount.HasValue) { shipment.Price = price; shipment.Discount = discount; _dataService.IncrementAccumulatedDiscounts(shipment.Date.RemoveDays(), shipment.Discount.Value); } else { shipment.Discount = 0; } }
/// <summary> /// Displays a product listing page of the class's product page type. /// </summary> public ActionResult Index() { // Gets products of the product page type (via the generated page type code) List <LearningProductType> products = LearningProductTypeProvider.GetLearningProductTypes() .LatestVersion(false) .Published(true) .OnSite(siteName) .Culture("en-US") .CombineWithDefaultCulture() .WhereTrue("SKUEnabled") .OrderByDescending("SKUInStoreFrom") .ToList(); // Displays the action's view with an initialized view model return(View(products.Select( product => new ProductListItemViewModel( product, pricingService.CalculatePrice(product.SKU, shoppingService.GetCurrentShoppingCart()), product.Product.PublicStatus?.PublicStatusDisplayName)) )); }
/// <summary> /// Loads pages from the current site of the LearningProductType product page type based on the specified where condition. /// </summary> /// <param name="where">Where condition that restricts the returned products.</param> /// <returns>List of view models representing a products, its prices and public status display name.</returns> private List <ProductListItemViewModel> LoadProducts(WhereCondition where) { // Gets products of the product page type List <LearningProductType> products = LearningProductTypeProvider.GetLearningProductTypes() .LatestVersion(false) .Published(true) .OnSite(SiteContext.CurrentSiteName) .Culture("en-US") .CombineWithDefaultCulture() .WhereTrue("SKUEnabled") .Where(where) .OrderByDescending("SKUInStoreFrom") .ToList(); // Displays an initialized view model return(products.Select( product => new ProductListItemViewModel( product, pricingService.CalculatePrice(product.SKU, shoppingService.GetCurrentShoppingCart()), product.Product.PublicStatus?.PublicStatusDisplayName) ).ToList()); }
public async Task <CreateOfferResult> Handle(CreateOfferByAgentCommand request, CancellationToken cancellationToken) { //calculate price var priceParams = ConstructPriceParams(request); var price = await pricingService.CalculatePrice(priceParams); var o = Offer.ForPriceAndAgent( priceParams.ProductCode, priceParams.PolicyFrom, priceParams.PolicyTo, null, price, request.AgentLogin ); //create and save offer uow.Offers.Add(o); await uow.CommitChanges(); //return result return(ConstructResult(o)); }
//EndDocSection:DifferentShippingAddress private object DummyEcommerceMethod() { IPricingService pricingService = null; ShoppingCart shoppingCart = null; SKUInfo productSku = null; Variant variant = null; IVariantRepository mVariantRepository = null; SKUTreeNode product = null; SKUInfo sku = null; DummyViewModel model = null; Order order = null; PaymentResultInfo result = null; //DocSection:CalculatePriceOptions ProductPrice productPrice = pricingService.CalculatePrice(productSku, shoppingCart); //EndDocSection:CalculatePriceOptions //DocSection:FormatPriceOptions decimal price = 5.50M; string formattedPrice = shoppingCart.Currency.FormatPrice(price); //EndDocSection:FormatPriceOptions //DocSection:VariantDisplayImg var response = new { // ... imagePath = Url.Content(variant.ImagePath) }; //EndDocSection:VariantDisplayImg //DocSection:DisplayAttributeSelection // Gets the cheapest variant from the product List <Variant> variants = mVariantRepository.GetByProductId(product.NodeSKUID).OrderBy(v => v.VariantPrice).ToList(); Variant cheapestVariant = variants.FirstOrDefault(); // Gets the product's option categories. IEnumerable <ProductOptionCategory> categories = mVariantRepository.GetVariantOptionCategories(sku.SKUID); // Gets the cheapest variant's selected attributes IEnumerable <ProductOptionCategoryViewModel> variantCategories = cheapestVariant?.ProductAttributes.Select( option => new ProductOptionCategoryViewModel(option.SKUID, categories.FirstOrDefault(c => c.ID == option.SKUOptionCategoryID))); //EndDocSection:DisplayAttributeSelection //DocSection:ShippingIsDifferent if (model.ShippingAddressIsDifferent) { // ... } //EndDocSection:ShippingIsDifferent //DocSection:DifferentPaymentMethods if (shoppingCart.PaymentMethod.PaymentOptionName.Equals("PaymentMethodCodeName")) { return(RedirectToAction("ActionForPayment", "MyPaymentGateway")); } //EndDocSection:DifferentPaymentMethods //DocSection:SetPaymentResult order.SetPaymentResult(result); //EndDocSection:SetPaymentResult //DocSection:RedirectForManualPayment return(RedirectToAction("ThankYou", new { orderID = order.OrderID })); //EndDocSection:RedirectForManualPayment }
/// <summary> /// Calculates product prices to be displayed on a listing page. /// </summary> /// <param name="product">Product to calculate prices for.</param> public ProductPrice CalculateListingPrice(SKUInfo product) { return(mPricingService.CalculatePrice(product, mShoppingService.GetCurrentShoppingCart())); }
public IActionResult CalculatePrice([FromBody] RequestData requestData) { var result = ipricingservice.CalculatePrice(requestData.RoomType, requestData.mock); return(Ok(result)); }