/// <summary> /// Gets the plan for a catalog item /// </summary> /// <param name="catalogName">Name of Azure catalog</param> /// <param name="catalogSectionName">Section of the catalog (this is the <see cref="CatalogGroupEntry.GroupId"/> property value)</param> /// <param name="offerId">Id of the item. You can provide any of the Id values (Id, SkuId, PlanId or LegacyPlanId)</param> /// <param name="planId">Id of the plan</param> /// <param name="language">Language for the data. Default is "en" for English.</param> /// <param name="locale">Locale for the data. Default is "en-us" for US English.</param> /// <returns>The GroupItem if found, else NULL</returns> public static SkuPlan GetCatalogItemPlan(string catalogName, string catalogSectionName, string offerId, string planId, string language = "en", string locale = "en-us") { IEnumerable <CatalogGroupEntry> catalogDetail = GetCatalogDetail(catalogName, language, locale); if (catalogDetail.Count() > 0) { CatalogGroupEntry section = catalogDetail.FirstOrDefault(d => d.GroupId.Equals(catalogSectionName)); if (section != default) { foreach (GroupItem item in section.Items) { if (item.Id.Equals(offerId, StringComparison.InvariantCultureIgnoreCase) || item.OfferId.Equals(offerId, StringComparison.InvariantCultureIgnoreCase) || item.LegacyOfferId.Equals(offerId, StringComparison.InvariantCultureIgnoreCase) || item.BigId.Equals(offerId, StringComparison.InvariantCultureIgnoreCase)) { foreach (SkuPlan plan in item.Plans) { if (plan.Id.Equals(planId, StringComparison.InvariantCultureIgnoreCase) || plan.SkuId.Equals(planId, StringComparison.InvariantCultureIgnoreCase) || plan.PlanId.Equals(planId, StringComparison.InvariantCultureIgnoreCase) || plan.LegacyPlanId.Equals(planId, StringComparison.InvariantCultureIgnoreCase)) { return(plan); } } break; } } } } return(null); }
/// <summary> /// Gets the items within a particular section of a catalog. If the section name is known, this method can be used instead of /// <seealso cref="GetCatalogDetail(string, string, string)"/>. /// </summary> /// <param name="catalogName">Name of Azure catalog</param> /// <param name="catalogSectionName">Section of the catalog (this is the <see cref="CatalogGroupEntry.GroupId"/> property value)</param> /// <param name="language">Language for the data. Default is "en" for English.</param> /// <param name="locale">Locale for the data. Default is "en-us" for US English.</param> /// <returns>IEnumerable of <see cref="GroupItem"/></returns> public static IEnumerable <GroupItem> GetCatalogItems(string catalogName, string catalogSectionName, string language = "en", string locale = "en-us") { IEnumerable <CatalogGroupEntry> catalogDetail = GetCatalogDetail(catalogName, language, locale); if (catalogDetail.Count() > 0) { CatalogGroupEntry section = catalogDetail.FirstOrDefault(d => d.GroupId.Equals(catalogSectionName)); if (section != default) { return(section.Items); } } return(new List <GroupItem>()); }