Initial import
This commit is contained in:
parent
0c865416ca
commit
04804b89a9
279 changed files with 12945 additions and 0 deletions
37
SalesCatalog/Model/Brand.cs
Normal file
37
SalesCatalog/Model/Brand.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
53
SalesCatalog/Model/Catalog.cs
Normal file
53
SalesCatalog/Model/Catalog.cs
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// Catalog.
|
||||
/// </summary>
|
||||
public class Catalog {
|
||||
/// <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; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
18
SalesCatalog/Model/CheckBox.cs
Normal file
18
SalesCatalog/Model/CheckBox.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class CheckBox : FormInput
|
||||
{
|
||||
public 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":"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
9
SalesCatalog/Model/Currency.cs
Normal file
9
SalesCatalog/Model/Currency.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public abstract class Currency: Unit
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
34
SalesCatalog/Model/Euro.cs
Normal file
34
SalesCatalog/Model/Euro.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
18
SalesCatalog/Model/FilesInput.cs
Normal file
18
SalesCatalog/Model/FilesInput.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class FilesInput : FormInput
|
||||
{
|
||||
|
||||
public FilesInput ()
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToHtml ()
|
||||
{
|
||||
return string.Format ("<input type=\"file\" id=\"{0}\" name=\"{0}\"/>", Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
10
SalesCatalog/Model/FormElement.cs
Normal file
10
SalesCatalog/Model/FormElement.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public abstract class FormElement
|
||||
{
|
||||
public abstract string ToHtml ();
|
||||
}
|
||||
}
|
||||
|
||||
19
SalesCatalog/Model/FormInput.cs
Normal file
19
SalesCatalog/Model/FormInput.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public abstract class FormInput: FormElement
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the identifier, unique in its Form.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The identifier.
|
||||
/// </value>
|
||||
|
||||
public string Id { get; set; }
|
||||
private string name=null;
|
||||
public string Name { get { return name == null ? Id : name; } set { name = value; } }
|
||||
}
|
||||
}
|
||||
|
||||
18
SalesCatalog/Model/Label.cs
Normal file
18
SalesCatalog/Model/Label.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
15
SalesCatalog/Model/Link.cs
Normal file
15
SalesCatalog/Model/Link.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class Link:Label
|
||||
{
|
||||
public Link ()
|
||||
{
|
||||
}
|
||||
[Required]
|
||||
public string Ref { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
13
SalesCatalog/Model/Note.cs
Normal file
13
SalesCatalog/Model/Note.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class Note:Text
|
||||
{
|
||||
public override string ToHtml ()
|
||||
{
|
||||
return string.Format("<quote>{0}</quote>",Val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
19
SalesCatalog/Model/Option.cs
Normal file
19
SalesCatalog/Model/Option.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
15
SalesCatalog/Model/Period.cs
Normal file
15
SalesCatalog/Model/Period.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class Period
|
||||
{
|
||||
public Period ()
|
||||
{
|
||||
}
|
||||
public DateTime StartDate { get; set; }
|
||||
public DateTime EndDate { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
27
SalesCatalog/Model/PhysicalProduct.cs
Normal file
27
SalesCatalog/Model/PhysicalProduct.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
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: UnitaryPrice={0}]", UnitaryPrice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
36
SalesCatalog/Model/Price.cs
Normal file
36
SalesCatalog/Model/Price.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
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
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
37
SalesCatalog/Model/Product.cs
Normal file
37
SalesCatalog/Model/Product.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
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();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
23
SalesCatalog/Model/ProductCategory.cs
Normal file
23
SalesCatalog/Model/ProductCategory.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
23
SalesCatalog/Model/ProductImage.cs
Normal file
23
SalesCatalog/Model/ProductImage.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
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; }
|
||||
}
|
||||
}
|
||||
|
||||
17
SalesCatalog/Model/RadioButton.cs
Normal file
17
SalesCatalog/Model/RadioButton.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class RadioButton:FormInput
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
20
SalesCatalog/Model/SaleForm.cs
Normal file
20
SalesCatalog/Model/SaleForm.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class SaleForm
|
||||
{
|
||||
public SaleForm ()
|
||||
{
|
||||
}
|
||||
|
||||
public string Action {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public FormElement[] Items { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
14
SalesCatalog/Model/Scalar.cs
Normal file
14
SalesCatalog/Model/Scalar.cs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public abstract class Scalar
|
||||
{
|
||||
public Scalar ()
|
||||
{
|
||||
}
|
||||
public abstract object Quantity { get; set; }
|
||||
public abstract Unit Unit{ get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
20
SalesCatalog/Model/SelectInput.cs
Normal file
20
SalesCatalog/Model/SelectInput.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using System.Text;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class SelectInput: FormInput
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
23
SalesCatalog/Model/SelectItem.cs
Normal file
23
SalesCatalog/Model/SelectItem.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
28
SalesCatalog/Model/Service.cs
Normal file
28
SalesCatalog/Model/Service.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
11
SalesCatalog/Model/StockStatus.cs
Normal file
11
SalesCatalog/Model/StockStatus.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public enum StockStatus
|
||||
{
|
||||
NoStock,
|
||||
InStock
|
||||
}
|
||||
}
|
||||
|
||||
18
SalesCatalog/Model/Text.cs
Normal file
18
SalesCatalog/Model/Text.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class Text: FormElement
|
||||
{
|
||||
public string Val {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public override string ToHtml ()
|
||||
{
|
||||
return Val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
46
SalesCatalog/Model/TextInput.cs
Normal file
46
SalesCatalog/Model/TextInput.cs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
using System;
|
||||
|
||||
namespace SalesCatalog.Model
|
||||
{
|
||||
public class TextInput:FormInput
|
||||
{
|
||||
public TextInput ()
|
||||
{
|
||||
}
|
||||
public TextInput (string txt)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
13
SalesCatalog/Model/Unit.cs
Normal file
13
SalesCatalog/Model/Unit.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue