/// <summary> /// Returns the state with the specified code name. /// </summary> /// <param name="stateName">The code name of the state.</param> /// <returns>The state with the specified code name, if found; otherwise, null.</returns> public StateInfo GetState(string stateName) { return(RepositoryCacheHelper.CacheObject(() => { return stateInfoProvider.Get(stateName); }, $"{nameof(KenticoCountryRepository)}|{nameof(GetState)}|{stateName}")); }
/// <summary> /// Returns all states in country with given ID. /// </summary> /// <param name="countryId">Country identifier</param> /// <returns>Collection of all states in county.</returns> public IEnumerable <StateInfo> GetCountryStates(int countryId) { return(RepositoryCacheHelper.CacheObjects(() => { return stateInfoProvider.Get().WhereEquals("CountryID", countryId); }, $"{nameof(KenticoCountryRepository)}|{nameof(GetCountryStates)}|{countryId}")); }
/// <summary> /// Returns an enumerable collection of all personas. /// </summary> public IEnumerable <PersonaInfo> GetAll() { return(RepositoryCacheHelper.CacheObjects(() => { return personaInfoProvider.Get(); }, $"{nameof(KenticoPersonaRepository)}|{nameof(GetAll)}")); }
/// <summary> /// Returns a public status with the specified id. /// </summary> /// <param name="statusId">The id of the public status.</param> public PublicStatusInfo GetById(int statusId) { return(RepositoryCacheHelper.CacheObject(() => { return publicStatusInfoProvider.Get(statusId); }, $"{nameof(KenticoPublicStatusRepository)}|{nameof(GetById)}|{statusId}")); }
/// <summary> /// Returns a customer's address with the specified identifier. /// </summary> /// <param name="addressId">Identifier of the customer's address.</param> /// <returns>Customer's address with the specified identifier. Returns <c>null</c> if not found.</returns> public AddressInfo GetById(int addressId) { return(RepositoryCacheHelper.CacheObject(() => { return addressInfoProvider.Get(addressId); }, $"{nameof(KenticoCustomerAddressRepository)}|{nameof(GetById)}|{addressId}")); }
/// <summary> /// Returns an enumerable collection of a customer's addresses. /// </summary> /// <param name="customerId">Customer's identifier.</param> /// <returns>Collection of customer's addresses. See <see cref="AddressInfo"/> for detailed information.</returns> public IEnumerable <AddressInfo> GetByCustomerId(int customerId) { return(RepositoryCacheHelper.CacheObjects(() => { return addressInfoProvider.GetByCustomer(customerId); }, $"{nameof(KenticoCustomerAddressRepository)}|{nameof(GetByCustomerId)}|{customerId}")); }
/// <summary> /// Returns media file with given identifier and site name. /// </summary> /// <param name="fileIdentifier">Identifier of the media file.</param> /// <param name="siteName">Site ID.</param> public MediaFileInfo GetMediaFile(Guid fileIdentifier, int siteId) { return(RepositoryCacheHelper.CacheObject(() => { return mediaFileInfoProvider.Get(fileIdentifier, siteId); }, $"{nameof(KenticoMediaFileRepository)}|{nameof(GetMediaFile)}|{fileIdentifier}|{siteId}")); }
/// <summary> /// Returns an enumerable collection of all enabled payment methods. /// </summary> /// <returns>Collection of enabled payment methods. See <see cref="PaymentOptionInfo"/> for detailed information.</returns> public IEnumerable <PaymentOptionInfo> GetAll() { return(RepositoryCacheHelper.CacheObjects(() => { return paymentOptionInfoProvider.GetBySite(SiteContext.CurrentSiteID, true); }, $"{nameof(KenticoPaymentMethodRepository)}|{nameof(GetAll)}")); }
/// <summary> /// Returns all available countries. /// </summary> /// <returns>Collection of all available countries</returns> public IEnumerable <CountryInfo> GetAllCountries() { return(RepositoryCacheHelper.CacheObjects(() => { return countryInfoProvider.Get(); }, $"{nameof(KenticoCountryRepository)}|{nameof(GetAllCountries)}")); }
/// <summary> /// Returns instance of <see cref="MediaFileInfo"/> specified by library name. /// </summary> /// <param name="mediaLibraryName">Name of the media library.</param> public MediaLibraryInfo GetByName(string mediaLibraryName) { return(RepositoryCacheHelper.CacheObject(() => { return mediaLibraryInfoProvider.Get(mediaLibraryName, SiteContext.CurrentSiteID); }, $"{nameof(KenticoMediaFileRepository)}|{nameof(GetByName)}|{mediaLibraryName}")); }
/// <summary> /// Returns an enumerable collection of all enabled shipping options. /// </summary> /// <returns>Collection of enabled shipping options. See <see cref="ShippingOptionInfo"/> for detailed information.</returns> public IEnumerable <ShippingOptionInfo> GetAllEnabled() { return(RepositoryCacheHelper.CacheObjects(() => { return shippingOptionInfoProvider.GetBySite(SiteContext.CurrentSiteID, true); }, $"{nameof(KenticoShippingOptionRepository)}|{nameof(GetAllEnabled)}")); }
/// <summary> /// Returns the country with the specified code name. /// </summary> /// <param name="countryName">The code name of the country.</param> /// <returns>The country with the specified code name, if found; otherwise, null.</returns> public CountryInfo GetCountry(string countryName) { return(RepositoryCacheHelper.CacheObject(() => { return countryInfoProvider.Get(countryName); }, $"{nameof(KenticoCountryRepository)}|{nameof(GetCountry)}|{countryName}")); }
/// <summary> /// Returns a public status with the specified name. /// </summary> /// <param name="name">The code name of the public status.</param> public PublicStatusInfo GetByName(string name) { return(RepositoryCacheHelper.CacheObject(() => { return publicStatusInfoProvider.Get(name, SiteContext.CurrentSiteID); }, $"{nameof(KenticoPublicStatusRepository)}|{nameof(GetByName)}|{name}")); }
/// <summary> /// Returns a collection of option categories used in a product's variants. /// </summary> /// <param name="productId">SKU identifier of the variant's parent product.</param> /// <returns>Collection of option categories used in a product's variants. See <see cref="OptionCategoryInfo"/> for detailed information.</returns> public IEnumerable <OptionCategoryInfo> GetVariantOptionCategories(int productId) { return(RepositoryCacheHelper.CacheObjects(() => { // Get a list of option categories return VariantHelper.GetProductVariantsCategories(productId); }, $"{nameof(KenticoVariantRepository)}|{nameof(GetVariantOptionCategories)}|{productId}")); }
/// <summary> /// Returns an enumerable collection of TopN orders of the given customer ordered by OrderDate descending. /// </summary> /// <param name="customerId">Customer's identifier.</param> /// <param name="count">Number of retrieved orders. Using 0 returns all records.</param> /// <returns>Collection of the customer's orders. See <see cref="OrderInfo"/> for detailed information.</returns> public IEnumerable <OrderInfo> GetByCustomerId(int customerId, int count = 0) { return(RepositoryCacheHelper.CacheObjects(() => { return orderInfoProvider.GetBySite(SiteContext.CurrentSiteID) .WhereEquals("OrderCustomerID", customerId) .TopN(count) .OrderByDescending(orderInfo => orderInfo.OrderDate); }, $"{nameof(KenticoOrderRepository)}|{nameof(GetByCustomerId)}|{customerId}|{count}")); }
/// <summary> /// Returns a shipping option with the specified identifier. /// </summary> /// <param name="shippingOptionId">Shipping option's identifier.</param> /// <returns><see cref="ShippingOptionInfo"/> object representing a shipping option with the specified identifier. Returns <c>null</c> if not found.</returns> public ShippingOptionInfo GetById(int shippingOptionId) { return(RepositoryCacheHelper.CacheObject(() => { var shippingInfo = shippingOptionInfoProvider.Get(shippingOptionId); if (shippingInfo == null || shippingInfo.ShippingOptionSiteID != SiteContext.CurrentSiteID) { return null; } return shippingInfo; }, $"{nameof(KenticoShippingOptionRepository)}|{nameof(GetById)}|{shippingOptionId}")); }
/// <summary> /// Returns an order with the specified identifier. /// </summary> /// <param name="orderId">Order's identifier.</param> /// <returns><see cref="OrderInfo"/> object representing an order with the specified identifier. Returns <c>null</c> if not found.</returns> public OrderInfo GetById(int orderId) { return(RepositoryCacheHelper.CacheObject(() => { var orderInfo = orderInfoProvider.Get(orderId); if (orderInfo == null || orderInfo.OrderSiteID != SiteContext.CurrentSiteID) { return null; } return orderInfo; }, $"{nameof(KenticoOrderRepository)}|{nameof(GetById)}|{orderId}")); }
/// <summary> /// Returns all media files in the media library. /// </summary> /// <param name="mediaLibraryName">Name of the media library.</param> public IEnumerable <MediaFileInfo> GetMediaFiles(string mediaLibraryName) { return(RepositoryCacheHelper.CacheObjects(() => { var mediaLibrary = GetByName(mediaLibraryName); if (mediaLibrary == null) { throw new InvalidOperationException("Media library not found."); } return mediaFileInfoProvider.Get() .WhereEquals("FileLibraryID", mediaLibrary.LibraryID); }, $"{nameof(KenticoMediaFileRepository)}|{nameof(GetMediaFiles)}|{mediaLibraryName}")); }
/// <summary> /// Returns an enumerable collection of footer navigation items. /// </summary> public IEnumerable <TreeNode> GetFooterNavigationItems() { return(RepositoryCacheHelper.CachePages(() => { var footerNavigationPage = pageRetriever.Retrieve <FooterNavigation>( query => query .Path(ContentItemIdentifiers.FOOTER_NAVIGATION, PathTypeEnum.Single) .TopN(1)) .First(); return footerNavigationPage.Fields.NavigationItems; }, $"{nameof(KenticoNavigationRepository)}|{nameof(GetFooterNavigationItems)}", new[] { CacheDependencyKeyProvider.GetDependencyCacheKeyForObjectType("cms.adhocrelationship"), $"node|{SiteContext.CurrentSiteName}|/|childnodes" })); }
/// <summary> /// Returns collection of products categorized under Hot tips page. /// </summary> /// <param name="parentAliasPath">Parent node alias path.</param> public IEnumerable <SKUTreeNode> GetHotTipProducts(string parentAliasPath) { return(RepositoryCacheHelper.CachePages(() => { var hotTipsPage = pageRetriever.Retrieve <HotTips>( query => query .Path($"{parentAliasPath}/Hot-tips", PathTypeEnum.Single) .TopN(1)) .FirstOrDefault(); return hotTipsPage?.Fields.HotTips .OfType <SKUTreeNode>() ?? Enumerable.Empty <SKUTreeNode>(); }, $"{nameof(KenticoHotTipsRepository)}|{nameof(GetHotTipProducts)}|{parentAliasPath}", new[] { CacheDependencyKeyProvider.GetDependencyCacheKeyForObjectType("cms.adhocrelationship"), CacheDependencyKeyProvider.GetDependencyCacheKeyForObjectType("ecommerce.sku"), $"node|{SiteContext.CurrentSiteName}|{parentAliasPath}" })); }
/// <summary> /// Returns a payment method with the specified identifier. /// </summary> /// <param name="paymentMethodId">Payment method's identifier.</param> /// <returns><see cref="PaymentOptionInfo"/> object representing a payment method with the specified identifier. Returns <c>null</c> if not found.</returns> public PaymentOptionInfo GetById(int paymentMethodId) { return(RepositoryCacheHelper.CacheObject(() => { var paymentInfo = paymentOptionInfoProvider.Get(paymentMethodId); if (paymentInfo?.PaymentOptionSiteID == SiteContext.CurrentSiteID) { return paymentInfo; } if (paymentInfo?.PaymentOptionSiteID == 0 && ECommerceSettings.AllowGlobalPaymentMethods(SiteContext.CurrentSiteID)) { return paymentInfo; } return null; }, $"{nameof(KenticoPaymentMethodRepository)}|{nameof(GetById)}|{paymentMethodId}")); }
/// <summary> /// Returns the product with the specified identifier. /// </summary> /// <param name="nodeGUID">The product node identifier.</param> /// <returns>The product with the specified node identifier, if found; otherwise, null.</returns> public SKUTreeNode GetProduct(Guid nodeGUID) { return(RepositoryCacheHelper.CachePage(() => { var page = pageRetriever.Retrieve <TreeNode>( query => query .WhereEquals("NodeGUID", nodeGUID)) .FirstOrDefault(); if ((page == null) || !page.IsProduct()) { return null; } // Load product type specific fields from the database page.MakeComplete(true); return page as SKUTreeNode; }, $"{nameof(KenticoProductRepository)}|{nameof(GetProduct)}|{nodeGUID}", new[] { CacheDependencyKeyProvider.GetDependencyCacheKeyForObjectType("ecommerce.sku"), $"nodeguid|{SiteContext.CurrentSiteName}|{nodeGUID}" })); }
/// <summary> /// Initializes a new instance of the <see cref="PaymentMethodRepository"/> class using the payment option provider given. /// </summary> /// <param name="paymentOptionInfoProvider">Provider for <see cref="PaymentOptionInfo"/> management.</param> public PaymentMethodRepository(IPaymentOptionInfoProvider paymentOptionInfoProvider, RepositoryCacheHelper repositoryCacheHelper) { this.paymentOptionInfoProvider = paymentOptionInfoProvider; this.repositoryCacheHelper = repositoryCacheHelper; }
/// <summary> /// Initializes a new instance of the <see cref="PublicStatusRepository"/> class using the public status provider given. /// </summary> /// <param name="publicStatusInfoProvider">Provider for <see cref="PublicStatusInfo"/> management.</param> /// <param name="repositoryCacheHelper">Handles caching of retrieved objects.</param> public PublicStatusRepository(IPublicStatusInfoProvider publicStatusInfoProvider, RepositoryCacheHelper repositoryCacheHelper) { this.publicStatusInfoProvider = publicStatusInfoProvider; this.repositoryCacheHelper = repositoryCacheHelper; }
/// <summary> /// Initializes a new instance of the <see cref="VariantRepository"/> class. /// </summary> /// <param name="skuInfoProvider">Provider for <see cref="SKUInfo"/> management.</param> /// <param name="repositoryCacheHelper">Handles caching of retrieved objects.</param> public VariantRepository(ISKUInfoProvider skuInfoProvider, RepositoryCacheHelper repositoryCacheHelper) { this.skuInfoProvider = skuInfoProvider; this.repositoryCacheHelper = repositoryCacheHelper; }
/// <summary> /// Initializes a new instance of the <see cref="ShippingOptionRepository"/> class using the shipping option provider given. /// </summary> /// <param name="shippingOptionInfoProvider">Provider for <see cref="ShippingOptionInfo"/> management.</param> /// <param name="repositoryCacheHelper">Handles caching of retrieved objects.</param> public ShippingOptionRepository(IShippingOptionInfoProvider shippingOptionInfoProvider, RepositoryCacheHelper repositoryCacheHelper) { this.shippingOptionInfoProvider = shippingOptionInfoProvider; this.repositoryCacheHelper = repositoryCacheHelper; }
/// <summary> /// Initializes a new instance of the <see cref="CountryRepository"/> class. /// </summary> /// <param name="countryInfoProvider">Provider for <see cref="CountryInfo"/> management.</param> /// <param name="stateInfoProvider">Provider for <see cref="StateInfo"/> management.</param> public CountryRepository(ICountryInfoProvider countryInfoProvider, IStateInfoProvider stateInfoProvider, RepositoryCacheHelper repositoryCacheHelper) { this.countryInfoProvider = countryInfoProvider; this.stateInfoProvider = stateInfoProvider; this.repositoryCacheHelper = repositoryCacheHelper; }
/// <summary> /// Initializes a new instance of the <see cref="NavigationRepository"/> class. /// </summary> /// <param name="pageRetriever">The page retriever.</param> /// <param name="repositoryCacheHelper">Handles caching of retrieved objects.</param> public NavigationRepository(IPageRetriever pageRetriever, RepositoryCacheHelper repositoryCacheHelper) { this.pageRetriever = pageRetriever; this.repositoryCacheHelper = repositoryCacheHelper; }
/// <summary> /// Initializes a new instance of the <see cref="CustomerAddressRepository"/> class using the address provider given. /// </summary> /// <param name="addressInfoProvider">Provider for <see cref="AddressInfo"/> management.</param> /// <param name="repositoryCacheHelper">Handles caching of retrieved objects.</param> public CustomerAddressRepository(IAddressInfoProvider addressInfoProvider, RepositoryCacheHelper repositoryCacheHelper) { this.addressInfoProvider = addressInfoProvider; this.repositoryCacheHelper = repositoryCacheHelper; }
/// <summary> /// Initializes a new instance of the <see cref="OrderRepository"/> class. /// </summary> /// <param name="orderInfoProvider">Provider for <see cref="OrderInfo"/> management.</param> /// <param name="repositoryCacheHelper">Handles caching of retrieved objects.</param> public OrderRepository(IOrderInfoProvider orderInfoProvider, RepositoryCacheHelper repositoryCacheHelper) { this.orderInfoProvider = orderInfoProvider; this.repositoryCacheHelper = repositoryCacheHelper; }