yavsc/SalesCatalog/CatalogManager.cs
Paul Schneider b835053e5f * Makefile:
* CatalogManager.cs: Let the catalog manager ensure all command form
  are instancied

* PhysicalProduct.cs: A better ToString method

* SaleForm.cs: doc

* NpgsqlContentProvider.cs: registers a command

* FrontOfficeApiController.cs: Set the catalog referer uri in each
  command form found in the catalog

* FrontOfficeController.cs: creates the catalog with referer uri

* instdbws.sql: the command has got a client, as registered user

* Commande.cs: The command has an id and a product reference

* IContentProvider.cs: new RegisterCommand method

* WorkFlowManager.cs: yavscModel/WorkFlow/IContentProvider.cs
2015-01-26 16:44:41 +01:00

39 lines
972 B
C#

using System;
using SalesCatalog.Model;
namespace SalesCatalog
{
/// <summary>
/// Catalog manager.
/// Use this class to retreive the catalog or its elements
/// </summary>
public static class CatalogManager
{
private static CatalogProvider defaultProvider = null;
public static Catalog GetCatalog (string catalogUri)
{
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;
}
}
}