public VariationModel(Variation variation, bool deep, bool reallyDeep)
        {
            this.id          = variation.Id;
            this.parentId    = variation.ParentId;
            this.name        = variation.Name;
            this.displayName = variation.DisplayName;
            //this.cost = variation.Cost;
            this.price      = variation.Price;
            this.points     = variation.Points;
            this.pointPrice = variation.PointPrice;
            this.showIcon   = variation.Removed;
            this.position   = variation.Position;
            this.vatStatus  = variation.VATStatus;

            children = new List <ItemModelBase>();

            if (deep)
            {
                if (variation.HasChildren() && variation.Children[0] is Variation)
                {
                    foreach (Variation subVariation in variation.Children)
                    {
                        if (!reallyDeep)
                        {
                            children.Add(new VariationModel(subVariation, false, false));
                        }
                        else
                        {
                            children.Add(new VariationModel(subVariation.Id, true));
                        }
                    }
                    SortByPosition();
                }
                else if (variation.HasChildren() && variation.Children[0] is Component)
                {
                    ComponentsModel model = new ComponentsModel(variation);
                    children = model.Children;
                }
            }
        }
Ejemplo n.º 2
0
        public ComponentsModel(Variation variation)
        {
            this.id          = variation.Id;
            this.parentId    = variation.ParentId;
            this.name        = variation.Name;
            this.displayName = variation.DisplayName;
            //this.cost = variation.Cost;
            this.price = variation.Price;

            children = new List <ItemModelBase>();

            if (variation.HasChildren() && variation.Children[0] is Component)
            {
                foreach (Component component in variation.Children)
                {
                    children.Add(new ComponentModel(parentId, component));
                }
            }

            SortByName();
        }