Refactoring: moving
the Catalog manager and model into the Yavsc.Model.FrontOffice namespace * Web.config: * Catalog.xml: * MyClass.cs: * Note.cs: * Euro.cs: * Unit.cs: * Text.cs: * Link.cs: * Price.cs: * Label.cs: * Brand.cs: * Scalar.cs: * Option.cs: * Period.cs: * YavscModel.csproj: * Catalog.cs: * Service.cs: * Product.cs: * YavscClient.csproj: * CatalogManager.cs: * Currency.cs: * CheckBox.cs: * SaleForm.cs: * FormInput.cs: * CatalogProvider.cs: * TextInput.cs: * SelectItem.cs: * SalesCatalog.csproj: * FilesInput.cs: * FormElement.cs: * SelectInput.cs: * IValueProvider.cs: * StockStatus.cs: * RadioButton.cs: * Commande.cs: * ProductImage.cs: * WebCatalogExtensions.cs: * TemplateException.cs: * ProductCategory.cs: * PhysicalProduct.cs: * Note.cs: * Link.cs: * Text.cs: * Euro.cs: * Unit.cs: * WorkFlowManager.cs: * Brand.cs: * Label.cs: * Price.cs: * Scalar.cs: * FrontOfficeController.cs: * Period.cs: * Option.cs: * Product.cs: * Service.cs: * Catalog.cs: * SaleForm.cs: * Currency.cs: * CheckBox.cs: * TextInput.cs: * FrontOfficeApiController.cs: * FormInput.cs: * SelectItem.cs: * FilesInput.cs: * XmlCatalog.cs: * FormElement.cs: * SelectInput.cs: * RadioButton.cs: * StockStatus.cs: * ProductImage.cs: * CatalogHelper.cs: * CatalogManager.cs: * CatalogProvider.cs: * ProductCategory.cs: * PhysicalProduct.cs: * XmlCatalogProvider.cs: * CatalogProviderConfigurationElement.cs: * CatalogProvidersConfigurationSection.cs: * CatalogProvidersConfigurationCollection.cs: * CatalogProviderConfigurationElement.cs: * CatalogProvidersConfigurationSection.cs: * CatalogProvidersConfigurationCollection.cs: * CatalogHelper.cs:
This commit is contained in:
@ -1,64 +0,0 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Reflection;
|
||||
using System.Collections.Specialized;
|
||||
using SalesCatalog.Configuration;
|
||||
|
||||
namespace SalesCatalog
|
||||
{
|
||||
/// <summary>
|
||||
/// Catalog helper.
|
||||
/// Used by the catalog manager to get the catalog provider from the configuration.
|
||||
/// </summary>
|
||||
public static class CatalogHelper
|
||||
{
|
||||
|
||||
public static CatalogProvidersConfigurationSection Config {get; set; }
|
||||
|
||||
public static void LoadConfig () {
|
||||
Config = ConfigurationManager.GetSection ("system.web/catalog") as CatalogProvidersConfigurationSection;
|
||||
if (Config == null)
|
||||
throw new ConfigurationErrorsException("The configuration bloc for the catalog provider was not found");
|
||||
/* foreach (CatalogProviderConfigurationElement e in Config.Providers) {
|
||||
Providers.Add(CreateProvider (e));
|
||||
} */
|
||||
}
|
||||
private static CatalogProvider CreateProvider(CatalogProviderConfigurationElement celt) {
|
||||
if (celt == null)
|
||||
throw new ConfigurationErrorsException("The default catalog provider was not found");
|
||||
Type catprtype = Type.GetType (celt.Type);
|
||||
if (catprtype == null)
|
||||
throw new Exception (
|
||||
string.Format("The catalog provider type ({0}) could not be found",celt.Type));
|
||||
ConstructorInfo ci = catprtype.GetConstructor (Type.EmptyTypes);
|
||||
if (ci==null)
|
||||
throw new Exception (
|
||||
string.Format("The catalog provider type ({0}) doesn't contain public constructor with empty parameter list",celt.Type));
|
||||
|
||||
CatalogProvider cp = ci.Invoke (Type.EmptyTypes) as CatalogProvider;
|
||||
NameValueCollection c = new NameValueCollection ();
|
||||
c.Add ("name", celt.Name);
|
||||
c.Add ("type", celt.Type);
|
||||
c.Add ("connection", celt.Connection);
|
||||
c.Add ("description", celt.Description);
|
||||
c.Add ("applicationName", celt.ApplicationName);
|
||||
cp.Initialize (celt.Name, c);
|
||||
return cp;
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the default provider.
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns>The default provider.</returns>
|
||||
public static CatalogProvider GetDefaultProvider ()
|
||||
{
|
||||
if (Config == null)
|
||||
throw new Exception ("Configuration wanted, use a call to \"Load\".");
|
||||
CatalogProviderConfigurationElement celt =
|
||||
Config.Providers.GetElement (Config.DefaultProvider);
|
||||
|
||||
return CreateProvider (celt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,39 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Configuration.Provider;
|
||||
using SalesCatalog.Model;
|
||||
|
||||
namespace SalesCatalog
|
||||
{
|
||||
/// <summary>
|
||||
/// Catalog provider.<br/>
|
||||
/// Abstract class, inherited to implement a catalog provider.
|
||||
/// </summary>
|
||||
public abstract class CatalogProvider: ProviderBase
|
||||
{
|
||||
public abstract Catalog GetCatalog ();
|
||||
}
|
||||
}
|
||||
|
@ -1,39 +0,0 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
|
||||
namespace SalesCatalog.Configuration
|
||||
{
|
||||
|
||||
public class CatalogProviderConfigurationElement : ConfigurationElement
|
||||
{
|
||||
[ConfigurationProperty("name", IsRequired = true, IsKey=true)]
|
||||
public string Name {
|
||||
get { return (string)this ["name"]; }
|
||||
set { this ["name"] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty("type", IsRequired = true)]
|
||||
public string Type {
|
||||
get { return (string)this ["type"]; }
|
||||
set { this ["type"] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty("connection")]
|
||||
public string Connection {
|
||||
get { return (string)this ["connection"]; }
|
||||
set { this ["connection"] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty("description")]
|
||||
public string Description {
|
||||
get { return (string)this ["description"]; }
|
||||
set { this ["description"] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty("applicationName")]
|
||||
public string ApplicationName {
|
||||
get { return (string)this ["applicationName"]; }
|
||||
set { this ["applicationName"] = value; }
|
||||
}
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace SalesCatalog.Configuration
|
||||
{
|
||||
public class CatalogProvidersConfigurationCollection : ConfigurationElementCollection
|
||||
{
|
||||
protected override ConfigurationElement CreateNewElement ()
|
||||
{
|
||||
return new CatalogProviderConfigurationElement();
|
||||
}
|
||||
|
||||
protected override object GetElementKey (ConfigurationElement element)
|
||||
{
|
||||
return ((CatalogProviderConfigurationElement) element).Name;
|
||||
}
|
||||
|
||||
public CatalogProviderConfigurationElement GetElement (string name)
|
||||
{
|
||||
return this.BaseGet(name) as CatalogProviderConfigurationElement;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,26 +0,0 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace SalesCatalog.Configuration
|
||||
{
|
||||
public class CatalogProvidersConfigurationSection : ConfigurationSection
|
||||
{
|
||||
[ConfigurationProperty("defaultProvider")]
|
||||
public string DefaultProvider {
|
||||
get { return (string)base ["defaultProvider"]; }
|
||||
set { base ["defaultProvider"] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty("providers")]
|
||||
[ConfigurationCollection(typeof(CatalogProvidersConfigurationCollection),
|
||||
AddItemName = "add",
|
||||
ClearItemsName = "clear",
|
||||
RemoveItemName = "remove")]
|
||||
public CatalogProvidersConfigurationCollection Providers{
|
||||
get { return (CatalogProvidersConfigurationCollection) base ["providers"]; }
|
||||
set { base ["providers"] = value; }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
using System;
|
||||
using System.Xml.Serialization;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class Brand
|
||||
{
|
||||
public Brand ()
|
||||
{
|
||||
}
|
||||
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Slogan { get; set; }
|
||||
|
||||
public ProductImage Logo { get; set; }
|
||||
|
||||
public ProductCategory[] Categories { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the default form.
|
||||
/// </summary>
|
||||
/// <value>The default form.</value>
|
||||
public SaleForm DefaultForm { get; set; }
|
||||
|
||||
public ProductCategory GetProductCategory(string reference)
|
||||
{
|
||||
return Array.Find<ProductCategory>(Categories, c => c.Reference == reference);
|
||||
}
|
||||
public ProductCategory GetProductCategoryByName(string catName)
|
||||
{
|
||||
return Array.Find<ProductCategory>(Categories, c => c.Name == catName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,69 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// Catalog.
|
||||
/// </summary>
|
||||
public class Catalog {
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the catalog unique identifier in the system.
|
||||
/// </summary>
|
||||
/// <value>The unique identifier.</value>
|
||||
string UID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the brands.
|
||||
/// </summary>
|
||||
/// <value>The brands.</value>
|
||||
public Brand[] Brands { get; set; }
|
||||
|
||||
public Brand GetBrand(string brandName)
|
||||
{
|
||||
return Array.Find<Brand>(Brands, b => b.Name == brandName);
|
||||
}
|
||||
|
||||
public Brand AddBrand(string brandName,string slogan=null, ProductImage logo=null)
|
||||
{
|
||||
Brand[] oldbrs = (Brand[]) Brands.Clone ();
|
||||
int oldl = Brands.Length;
|
||||
Array.Resize<Brand>(ref oldbrs,oldl+1);
|
||||
Brand b = new Brand ();
|
||||
b.Name=brandName;
|
||||
b.Slogan = slogan;
|
||||
b.Logo = logo;
|
||||
oldbrs [oldl] = b;
|
||||
Brands=oldbrs;
|
||||
return b;
|
||||
}
|
||||
|
||||
public bool RemoveBrand(string brandName)
|
||||
{
|
||||
Brand b = this.GetBrand (brandName);
|
||||
if (b == null)
|
||||
return false;
|
||||
//ASSERT Brands.Length>0;
|
||||
List<Brand> nb = new List<Brand> (Brands);
|
||||
nb.Remove (b);
|
||||
Brands = nb.ToArray ();
|
||||
return true;
|
||||
}
|
||||
|
||||
public DateTime StartDate { get; set; }
|
||||
|
||||
public DateTime EndDate { get; set; }
|
||||
|
||||
public Product FindProduct (string reference)
|
||||
{
|
||||
Product p = null;
|
||||
foreach (Brand b in Brands)
|
||||
foreach (ProductCategory c in b.Categories)
|
||||
if ((p = c.GetProduct(reference))!=null)
|
||||
return p;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class CheckBox : FormInput
|
||||
{
|
||||
public CheckBox ()
|
||||
{
|
||||
}
|
||||
|
||||
#region implemented abstract members of FormInput
|
||||
|
||||
|
||||
public override string Type {
|
||||
get {
|
||||
return "checkbox";
|
||||
}
|
||||
}
|
||||
|
||||
public bool Value { get; set; }
|
||||
|
||||
public override string ToHtml ()
|
||||
{
|
||||
return string.Format ("<input type=\"checkbox\" id=\"{0}\" name=\"{1}\" {2}/>", Id,Name,Value?"checked":"");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public abstract class Currency: Unit
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -1,34 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class Euro : Currency
|
||||
{
|
||||
public Euro ()
|
||||
{
|
||||
}
|
||||
|
||||
public override string Name {
|
||||
get {
|
||||
return "Euro";
|
||||
}
|
||||
}
|
||||
|
||||
public override string Description {
|
||||
get {
|
||||
return "European currency";
|
||||
}
|
||||
}
|
||||
|
||||
public override bool MayConvertTo (Unit other)
|
||||
{
|
||||
return other.GetType().IsSubclassOf(typeof (Currency));
|
||||
}
|
||||
|
||||
public override object ConvertTo (Unit dest, object value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,25 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class FilesInput : FormInput
|
||||
{
|
||||
#region implemented abstract members of FormInput
|
||||
public override string Type {
|
||||
get {
|
||||
return "file";
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public FilesInput ()
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToHtml ()
|
||||
{
|
||||
return string.Format ("<input type=\"file\" id=\"{0}\" name=\"{0}\"/>", Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public abstract class FormElement
|
||||
{
|
||||
public abstract string ToHtml ();
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public abstract class FormInput: FormElement
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the identifier, unique in its Form.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The identifier.
|
||||
/// </value>
|
||||
[Required]
|
||||
[StringLength(256)]
|
||||
public string Id { get; set; }
|
||||
|
||||
public abstract string Type { get; }
|
||||
|
||||
private string name=null;
|
||||
|
||||
[StringLength(256)]
|
||||
public string Name { get { return name == null ? Id : name; } set { name = value; } }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class Label:FormElement
|
||||
{
|
||||
public Label ()
|
||||
{
|
||||
}
|
||||
string Text { get; set; }
|
||||
string For { get; set ; }
|
||||
public override string ToHtml ()
|
||||
{
|
||||
return string.Format ("<label for=\"{0}\">{1}</label>", For, Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class Link:Label
|
||||
{
|
||||
public Link ()
|
||||
{
|
||||
}
|
||||
[Required]
|
||||
public string Ref { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class Note:Text
|
||||
{
|
||||
public override string ToHtml ()
|
||||
{
|
||||
return string.Format("<quote>{0}</quote>",Val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class Option : FormElement
|
||||
{
|
||||
public Option ()
|
||||
{
|
||||
}
|
||||
public string Value { get; set; }
|
||||
public string Text { get; set; }
|
||||
|
||||
public override string ToHtml ()
|
||||
{
|
||||
return string.Format ("<option value=\"{0}\">{1}</option>\n",Value,Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class Period
|
||||
{
|
||||
public Period ()
|
||||
{
|
||||
}
|
||||
public DateTime StartDate { get; set; }
|
||||
public DateTime EndDate { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class PhysicalProduct : Product
|
||||
{
|
||||
public PhysicalProduct ()
|
||||
{
|
||||
}
|
||||
public Price UnitaryPrice { get; set; }
|
||||
#region implemented abstract members of SalesCatalog.Model.Product
|
||||
public override string[] GetSalesConditions ()
|
||||
{
|
||||
return new string [] { string.Format(
|
||||
"Prix unitaire : {0} {1}",
|
||||
UnitaryPrice.Quantity.ToString(),
|
||||
UnitaryPrice.Unit.Name) };
|
||||
}
|
||||
#endregion
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return string.Format ("[PhysicalProduct: Reference:{0} UnitaryPrice={1}]", Reference, UnitaryPrice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,36 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class Price: Scalar
|
||||
{
|
||||
public Price ()
|
||||
{
|
||||
}
|
||||
|
||||
decimal quantity;
|
||||
|
||||
#region implemented abstract members of SalesCatalog.Value
|
||||
public override object Quantity {
|
||||
get {
|
||||
return quantity;
|
||||
}
|
||||
set {
|
||||
quantity = (decimal) value;
|
||||
}
|
||||
}
|
||||
|
||||
Currency curr;
|
||||
public override SalesCatalog.Model.Unit Unit {
|
||||
get {
|
||||
return curr;
|
||||
}
|
||||
set {
|
||||
curr = (Currency)value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,39 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// Product.
|
||||
/// Crucial object in the catalog,
|
||||
/// being at each origin of form display
|
||||
/// its properties may be used to fill some form input values or other form element.
|
||||
/// <c>in text values, within {} ex: {Name} : {Price} ({stockStatus}) ($description) </c>.
|
||||
/// </summary>
|
||||
public abstract class Product
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the product name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
[Required]
|
||||
[StringLength(1024)]
|
||||
public string Name { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the product description.
|
||||
/// </summary>
|
||||
/// <value>The description.</value>
|
||||
public string Description { get; set; }
|
||||
public ProductImage[] Images { get; set; }
|
||||
public SaleForm CommandForm { get; set; }
|
||||
[Required]
|
||||
[StringLength(255)]
|
||||
public string Reference { get; set; }
|
||||
public Period CommandValidityDates { get; set; }
|
||||
public abstract string[] GetSalesConditions();
|
||||
|
||||
public virtual string Type { get { return GetType().Name; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class ProductCategory
|
||||
{
|
||||
public ProductCategory ()
|
||||
{
|
||||
}
|
||||
public string Name { get; set; }
|
||||
public string Reference { get; set; }
|
||||
public Product[] Products { get; set; }
|
||||
public Product GetProductByName (string productName)
|
||||
{
|
||||
return Array.Find<Product> (Products, p => p.Name == productName);
|
||||
}
|
||||
public Product GetProduct (string reference)
|
||||
{
|
||||
return Array.Find<Product> (Products, p => p.Reference == reference);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class ProductImage: FormElement
|
||||
{
|
||||
#region implemented abstract members of FormElement
|
||||
|
||||
public override string ToHtml ()
|
||||
{
|
||||
return string.Format ("<img src=\"\" alt=\"\"/>", Src, Alt);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public ProductImage ()
|
||||
{
|
||||
}
|
||||
public string Src { get; set; }
|
||||
public string Alt { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class RadioButton:FormInput
|
||||
{
|
||||
#region implemented abstract members of FormInput
|
||||
|
||||
public override string Type {
|
||||
get {
|
||||
return "radio";
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public RadioButton ()
|
||||
{
|
||||
}
|
||||
public string Choice { get; set; }
|
||||
public override string ToHtml ()
|
||||
{
|
||||
return string.Format ("<input type=\"radio\" id=\"{0}\" name=\"{1}\" value=\"{2}\"/><label for=\"{0}\">{2}</label>", Id,Name,Choice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,40 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class SaleForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the catalog reference.
|
||||
/// It must be non null,
|
||||
/// it is an Uri, returning the Xml
|
||||
/// Catalog at Http GET request
|
||||
/// </summary>
|
||||
/// <value>The catalog reference.</value>
|
||||
public string CatalogReference { get; set; }
|
||||
|
||||
public SaleForm ()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the action, that is,
|
||||
/// the Method of the FrontOffice controller
|
||||
/// called to post this Command form.
|
||||
/// It defaults to "Command"
|
||||
/// </summary>
|
||||
/// <value>The action.</value>
|
||||
public string Action {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the input values of this command form.
|
||||
/// </summary>
|
||||
/// <value>The items.</value>
|
||||
public FormElement[] Items { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public abstract class Scalar
|
||||
{
|
||||
public Scalar ()
|
||||
{
|
||||
}
|
||||
public abstract object Quantity { get; set; }
|
||||
public abstract Unit Unit{ get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,30 +0,0 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class SelectInput: FormInput
|
||||
{
|
||||
#region implemented abstract members of FormInput
|
||||
|
||||
public override string Type {
|
||||
get {
|
||||
return "select";
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public Option[] Items;
|
||||
public int SelectedIndex;
|
||||
public override string ToHtml ()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder ();
|
||||
foreach (Option opt in Items)
|
||||
sb.Append (opt.ToHtml());
|
||||
return string.Format ("<select id=\"{0}\" name=\"{1}\">{2}</select>\n", Id,Name,sb.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class SelectItem
|
||||
{
|
||||
public SelectItem(string t)
|
||||
{
|
||||
Value = t;
|
||||
}
|
||||
public string Value { get; set; }
|
||||
public static implicit operator string(SelectItem t)
|
||||
{
|
||||
return t.Value;
|
||||
}
|
||||
public static implicit operator SelectItem(string t)
|
||||
{
|
||||
return new SelectItem(t);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,28 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class Service : Product
|
||||
{
|
||||
public Service ()
|
||||
{
|
||||
}
|
||||
|
||||
public Price HourPrice { get; set; }
|
||||
|
||||
#region implemented abstract members of SalesCatalog.Model.Product
|
||||
public override string [] GetSalesConditions ()
|
||||
{
|
||||
return new string [] { string.Format(
|
||||
"Prix horaire de la prestation : {0} {1}",
|
||||
HourPrice.Quantity.ToString(),
|
||||
HourPrice.Unit.Name) } ;
|
||||
}
|
||||
#endregion
|
||||
public override string ToString ()
|
||||
{
|
||||
return string.Format ("[Service: HourPrice={0}]", HourPrice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public enum StockStatus
|
||||
{
|
||||
NoStock,
|
||||
InStock
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class Text: FormElement
|
||||
{
|
||||
public string Val {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public override string ToHtml ()
|
||||
{
|
||||
return Val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,68 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class TextInput:FormInput
|
||||
{
|
||||
|
||||
#region implemented abstract members of FormInput
|
||||
private string tpe = null;
|
||||
public override string Type {
|
||||
get {
|
||||
return tpe;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public TextInput ()
|
||||
{
|
||||
tpe = "text";
|
||||
}
|
||||
|
||||
public TextInput (string txt)
|
||||
{
|
||||
tpe = "text";
|
||||
text = txt;
|
||||
}
|
||||
|
||||
public TextInput (string type, string txt)
|
||||
{
|
||||
tpe = type;
|
||||
text = txt;
|
||||
}
|
||||
|
||||
string text = null;
|
||||
|
||||
|
||||
public static implicit operator string(TextInput t)
|
||||
{
|
||||
return t.text;
|
||||
}
|
||||
|
||||
public static implicit operator TextInput(string t)
|
||||
{
|
||||
return new TextInput(t);
|
||||
}
|
||||
|
||||
public string DefaultValue {
|
||||
get {
|
||||
return text;
|
||||
}
|
||||
set {
|
||||
text = (string) value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool multiline = false;
|
||||
public bool MultiLine { get { return multiline; } set { multiline = value; } }
|
||||
|
||||
public override string ToHtml ()
|
||||
{
|
||||
|
||||
return MultiLine?
|
||||
string.Format ("<textarea id=\"{0}\" name=\"{1}\">{2}</textarea>", Id,Name,DefaultValue)
|
||||
: string.Format ("<input type=\"text\" id=\"{0}\" name=\"{1}\" value=\"{2}\"/>", Id,Name,DefaultValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public abstract class Unit
|
||||
{
|
||||
public abstract string Name { get; }
|
||||
public abstract string Description { get; }
|
||||
public abstract object ConvertTo (Unit dest, object value);
|
||||
public abstract bool MayConvertTo (Unit other);
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>SalesCatalog</RootNamespace>
|
||||
<AssemblyName>SalesCatalog</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@ -38,44 +39,10 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblyInfo.cs" />
|
||||
<Compile Include="Configuration\CatalogProviderConfigurationElement.cs" />
|
||||
<Compile Include="Configuration\CatalogProvidersConfigurationSection.cs" />
|
||||
<Compile Include="Configuration\CatalogProvidersConfigurationCollection.cs" />
|
||||
<Compile Include="CatalogManager.cs" />
|
||||
<Compile Include="Model\CheckBox.cs" />
|
||||
<Compile Include="Model\Currency.cs" />
|
||||
<Compile Include="Model\Euro.cs" />
|
||||
<Compile Include="Model\FilesInput.cs" />
|
||||
<Compile Include="Model\FormElement.cs" />
|
||||
<Compile Include="Model\FormInput.cs" />
|
||||
<Compile Include="Model\Label.cs" />
|
||||
<Compile Include="Model\Link.cs" />
|
||||
<Compile Include="Model\Price.cs" />
|
||||
<Compile Include="Model\ProductCategory.cs" />
|
||||
<Compile Include="Model\RadioButton.cs" />
|
||||
<Compile Include="Model\SelectInput.cs" />
|
||||
<Compile Include="Model\TextInput.cs" />
|
||||
<Compile Include="Model\Unit.cs" />
|
||||
<Compile Include="Model\Brand.cs" />
|
||||
<Compile Include="CatalogProvider.cs" />
|
||||
<Compile Include="XmlImplementation\XmlCatalog.cs" />
|
||||
<Compile Include="CatalogHelper.cs" />
|
||||
<Compile Include="Tests\TestCatalogInit.cs" />
|
||||
<Compile Include="Model\Product.cs" />
|
||||
<Compile Include="Model\Period.cs" />
|
||||
<Compile Include="Model\Service.cs" />
|
||||
<Compile Include="Model\PhysicalProduct.cs" />
|
||||
<Compile Include="Model\Catalog.cs" />
|
||||
<Compile Include="XmlImplementation\XmlCatalogProvider.cs" />
|
||||
<Compile Include="Model\Text.cs" />
|
||||
<Compile Include="Model\SelectItem.cs" />
|
||||
<Compile Include="Model\StockStatus.cs" />
|
||||
<Compile Include="Model\Scalar.cs" />
|
||||
<Compile Include="Tests\TestBrands.cs" />
|
||||
<Compile Include="Model\SaleForm.cs" />
|
||||
<Compile Include="Model\ProductImage.cs" />
|
||||
<Compile Include="Model\Option.cs" />
|
||||
<Compile Include="Model\Note.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ProjectExtensions>
|
||||
@ -95,4 +62,10 @@
|
||||
<Folder Include="XmlImplementation\" />
|
||||
<Folder Include="Tests\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\yavscModel\YavscModel.csproj">
|
||||
<Project>{68F5B80A-616E-4C3C-91A0-828AA40000BD}</Project>
|
||||
<Name>YavscModel</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using SalesCatalog.Model;
|
||||
using System.Xml.Serialization;
|
||||
using Yavsc.Model.FrontOffice;
|
||||
|
||||
namespace SalesCatalog.XmlImplementation
|
||||
{
|
||||
|
@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using System.Xml.Serialization;
|
||||
using SalesCatalog.Model;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using Yavsc.Model.FrontOffice;
|
||||
|
||||
namespace SalesCatalog.XmlImplementation
|
||||
{
|
||||
|
Reference in New Issue
Block a user