Files
yavsc/SalesCatalog/Model/Catalog.cs
Paul Schneider f157c6edb9 * Web.csproj:
* jquery-latest.js:
* IITContent.cs:
* ITContent.csproj:
* YavscModel.csproj:
* Write.aspx:
* jquery.tablesorter.min.js:
* AssemblyInfo.cs:
* NewEstimateEvenArgs.cs: 

* jquery.metadata.js: ajax call Write

* jquery.tablesorter.js: Estimate table sorting

* Catalog.cs: Find a product by reference

* NpgsqlContentProvider.cs: Npgsql provider could not get the
  Postgresql data type "money"

* Yavsc.sln: Removing an empty project

* MyClass.cs: implements IModule

* fortune.csproj: uses Configuration

* FrontOfficeApiController.cs: Url: GetEstimate/5

* WorkFlowController.cs: debugging ajax call

* RemoveUserQuery.aspx: no more "head" place holder


* Estimate.aspx: Ajax call to add a line to estimates

* Web.config: using the "Deploy" target

* IModule.cs: Install & uninstall using a System.Data.IDbConnection

* IContentProvider.cs: refactoring

* WorkFlowManager.cs: an event at creating an estimate (NewOrder)

* Writting.cs: ProductReference is a string
2014-10-17 02:10:00 +02:00

70 lines
1.5 KiB
C#

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;
}
}
}