Exemplo n.º 1
0
        public OrderModel(int id)
        {
            if (id == 0)
            {
                return;
            }

            Order order = Database.GetOrder(id, true);

            this.id           = id;
            this.name         = order.Name;
            this.customerType = order.CustomerType;
            this.date         = order.Date;
            this.orderNumber  = order.OrderNumber;

            foreach (OrderItem item in order.OrderItems)
            {
                OrderItemModel newItemModel = new OrderItemModel(item.Id, id, item.VariationId, item.InOutStatus, item.DiscountId, item.State);
                items.Add(newItemModel);

                foreach (OrderItemComponent component in item.Components)
                {
                    OrderItemComponentModel componentModel = new OrderItemComponentModel(component);
                    newItemModel.AddComponentModel(componentModel);

                    foreach (OrderItemComponentComponent subComponent in component.Components)
                    {
                        componentModel.AddComponent(new OrderItemComponentComponentModel(subComponent));
                    }
                }
            }
        }
        public OrderItemComponentModel Clone()
        {
            OrderItemComponentModel model = new OrderItemComponentModel(this.id, this.orderItemId, this.componentId, this.name, this.displayName, this.cost, this.price, this.portions, this.position);

            foreach (OrderItemComponentComponentModel component in components)
            {
                model.AddComponent(component);
            }

            return(model);
        }