using System; using System.Collections.Generic; namespace Yavsc.Model.FrontOffice.Catalog { /// /// Catalog. /// public class Catalog { /// /// Gets or sets the catalog unique identifier in the system. /// /// The unique identifier. string UID { get; set; } /// /// Gets or sets the brands. /// /// The brands. public Brand[] Brands { get; set; } /// /// Gets the brand. /// /// The brand. /// Brand name. public Brand GetBrand(string brandName) { return Array.Find(Brands, b => b.Name == brandName); } /// /// Adds the brand. /// /// The brand. /// Brand name. /// Slogan. /// Logo. public Brand AddBrand(string brandName,string slogan=null, ProductImage logo=null) { Brand[] oldbrs = (Brand[]) Brands.Clone (); int oldl = Brands.Length; Array.Resize(ref oldbrs,oldl+1); Brand b = new Brand (); b.Name=brandName; b.Slogan = slogan; b.Logo = logo; oldbrs [oldl] = b; Brands=oldbrs; return b; } /// /// Removes the brand. /// /// true, if brand was removed, false otherwise. /// Brand name. public bool RemoveBrand(string brandName) { Brand b = this.GetBrand (brandName); if (b == null) return false; //ASSERT Brands.Length>0; List nb = new List (Brands); nb.Remove (b); Brands = nb.ToArray (); return true; } /// /// Gets or sets the start date. /// /// The start date. public DateTime StartDate { get; set; } /// /// Gets or sets the end date. /// /// The end date. public DateTime EndDate { get; set; } /// /// Finds the product. /// /// The product. /// Reference. 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; } } }