How to obtain list price for a product

Following methods obtain the list price of an article and a product published on a website. Note how the IPriceCalculator implementation is used to get the price.

using System;
using System.Collections.Generic;
using System.Globalization;
using Litium.Globalization;
using Litium.Products;
using Litium.Products.PriceCalculator;
using Litium.Security;

namespace Litium.Studio.KC.Samples.ProductCatalog
{
    /// <summary>
    /// Pricing
    /// </summary>
    public class Pricing
    {
        private readonly IPriceCalculator _priceCalculator;
        private readonly SecurityContextService _securityContextService;

        public Pricing(IPriceCalculator priceCalculator, SecurityContextService securityContextService)
        {
            _priceCalculator = priceCalculator;
            _securityContextService = securityContextService;
        }

        /// <summary>
        ///  Gets the list prices for <paramref name="variant"/>   
        /// </summary>
        /// <param name="variant">The variant.</param>
        /// <param name="quantity">The quantity</param>
        /// <param name="currency">The currency</param>
        /// <param name="channel">The channel.</param>
        /// <param name="country">The country.</param>
        /// <returns>List<string></returns>
        public List<string> GetListPrices(Variant variant, decimal quantity, Currency currency, Channel channel, Country country)
        {
            List<string> listPrices = new List<string>();

            var priceCalculatorArgs = new PriceCalculatorArgs
            {
                CurrencySystemId = currency.SystemId,
                DateTimeUtc = DateTimeOffset.UtcNow,
                UserSystemId = _securityContextService.GetIdentityUserSystemId().GetValueOrDefault(),
                ChannelSystemId = channel.SystemId,
                CountrySystemId = country.SystemId
            };
            var priceCalculatorItemArgs = new PriceCalculatorItemArgs
            {
                VariantSystemId = variant.SystemId,
                Quantity = quantity
            };

            if (_priceCalculator.GetListPrices(priceCalculatorArgs, priceCalculatorItemArgs).TryGetValue(priceCalculatorItemArgs.VariantSystemId, out PriceCalculatorResult priceListResult)
                && priceListResult is not null)
            {
                listPrices.Add(currency.Format(priceListResult.PriceExcludingVat, false, CultureInfo.CurrentUICulture));
            }

            return listPrices;
        }

        /// <summary>
        ///  Gets the price lists.   
        /// </summary>
        /// <param name="currency">The currency.</param>
        /// <param name="channel">The channel.</param>
        /// <param name="country">The country</param>
        /// <returns>IDictionary<Guid, PriceCalculatorResult></returns>
        public IDictionary<Guid, PriceCalculatorResult> GetListPrice(Currency currency, Channel channel, Country country)
        {
            // get price from price calculator.
            var priceCalculatorArgs = new PriceCalculatorArgs
            {
                CurrencySystemId = currency.SystemId,
                DateTimeUtc = DateTimeOffset.UtcNow,
                UserSystemId = _securityContextService.GetIdentityUserSystemId().GetValueOrDefault(),
                ChannelSystemId = channel.SystemId,
                CountrySystemId = country.SystemId
            };

            return _priceCalculator.GetListPrices(priceCalculatorArgs);
        }
    }
}

Obtaining Campaign prices

The campaign price for an article is determined by the price engine also. IPriceCalculator.GetListPrices() method returns the campaign prices for a set of articles. The usage is similar to the example presented above.