refactiring, docpage * Yavsc.sln: * Web.csproj: * YavscModel.csproj: * OtherWebException.cs: * ProjectInfo.cs: * IValueProvider.cs: * CalendarApi.cs: * HomeController.cs: * TemplateException.cs: * WorkFlowController.cs: * NpgsqlWorkflow.csproj: * GoogleErrorMessage.cs: * ITCPNpgsqlProvider.cs: * NpgsqlContentProvider.cs: * ITContentProvider.csproj: * FrontOfficeApiController.cs: * NpgsqlContentProvider.csproj: refactoring * App.master: * WebApiConfig.cs: New Web api configuration architecture * SalesCatalog.csproj: * XmlCatalogProvider.cs: using MVC to get the catalog xml filename * WorkFlowManager.cs: * FrontOfficeController.cs: * CatalogManager.cs: No more extra argument to get the catalog * DateQuery.aspx: * AskForADate.cs: * GoogleController.cs: Google Date new query model * style.css: * BBCodeHelper.cs: Doc page responsive design * Service.cs: * SetPrice.cs: xml doc * WebApiConfig.cs: refactioring
46 lines
1.1 KiB
C#
46 lines
1.1 KiB
C#
using System;
|
|
using System.Web;
|
|
|
|
|
|
namespace Yavsc.Model.FrontOffice
|
|
{
|
|
/// <summary>
|
|
/// Catalog manager.
|
|
/// Use this class to retreive the catalog or its elements
|
|
/// </summary>
|
|
public static class CatalogManager
|
|
{
|
|
private static CatalogProvider defaultProvider = null;
|
|
|
|
/// <summary>
|
|
/// Gets the catalog.
|
|
/// </summary>
|
|
/// <returns>The catalog.</returns>
|
|
/// <param name="catalogUri">Catalog URI.</param>
|
|
public static Catalog GetCatalog ()
|
|
{
|
|
string catalogUri = HttpContext.Current.Request.Url.AbsolutePath;
|
|
if (defaultProvider == null) {
|
|
if (CatalogHelper.Config == null)
|
|
CatalogHelper.LoadConfig ();
|
|
defaultProvider = CatalogHelper.GetDefaultProvider ();
|
|
}
|
|
Catalog res = defaultProvider.GetCatalog ();
|
|
|
|
// Assert res.Brands.All( x => x.DefaultForm != null );
|
|
// Sanity fixes
|
|
foreach (Brand b in res.Brands) {
|
|
if (b.DefaultForm.CatalogReference==null)
|
|
b.DefaultForm.CatalogReference = catalogUri;
|
|
foreach (ProductCategory pc in b.Categories) {
|
|
foreach (Product p in pc.Products) {
|
|
if (p.CommandForm == null)
|
|
p.CommandForm = b.DefaultForm;
|
|
}
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
}
|
|
}
|
|
|