예제 #1
0
        public static SalesOrderViewModel createFromSalesOrder(SalesOrder _salesOrder)
        {
            SalesOrderViewModel salesOrderViewModel = new SalesOrderViewModel();
            salesOrderViewModel.SalesOrderId        = _salesOrder.SalesOrderId;
            salesOrderViewModel.CustomerName        = _salesOrder.CustomerName;
            salesOrderViewModel.PONumber            = _salesOrder.PONumber;
            salesOrderViewModel.ObjectState         = ObjectState.Unchanged;
            salesOrderViewModel.RowVersion          = _salesOrder.RowVersion;

            foreach (SalesOrderItem salesOrderItem in _salesOrder.SalesOrderItems)
            {
                SalesOrderItemViewModel salesOrderItemViewModel = new SalesOrderItemViewModel();
                salesOrderItemViewModel.SalesOrderItemId        = salesOrderItem.SalesOrderItemId;
                salesOrderItemViewModel.ProductId               = salesOrderItem.ProductId;
                salesOrderItemViewModel.Quantity                = salesOrderItem.Quantity;
                salesOrderItemViewModel.UnitPrice               = salesOrderItem.UnitPrice;
                salesOrderItemViewModel.ObjectState             = ObjectState.Unchanged;
                salesOrderItemViewModel.SalesOrderId            = salesOrderItem.SalesOrderId;
                salesOrderItemViewModel.RowVersion              = salesOrderItem.RowVersion;

                salesOrderViewModel.SalesOrderItems.Add(salesOrderItemViewModel);
            }

            return salesOrderViewModel;
        }
예제 #2
0
        public static SalesOrder createFromSalesOrderModelView(SalesOrderViewModel _salesOrderModelView)
        {
            SalesOrder salesOrder   = new SalesOrder();
            salesOrder.SalesOrderId = _salesOrderModelView.SalesOrderId;
            salesOrder.CustomerName = _salesOrderModelView.CustomerName;
            salesOrder.PONumber     = _salesOrderModelView.PONumber;
            salesOrder.ObjectState  = _salesOrderModelView.ObjectState;
            salesOrder.RowVersion   = _salesOrderModelView.RowVersion;
            int temporarySalesOrderItemId = -1;

            foreach (SalesOrderItemViewModel salesOrderItemViewModel in _salesOrderModelView.SalesOrderItems)
            {
                SalesOrderItem salesOrderItem   = new SalesOrderItem();
                salesOrderItem.SalesOrderItemId = salesOrderItemViewModel.SalesOrderItemId;
                salesOrderItem.ProductId        = salesOrderItemViewModel.ProductId;
                salesOrderItem.Quantity         = salesOrderItemViewModel.Quantity;
                salesOrderItem.UnitPrice        = salesOrderItemViewModel.UnitPrice;
                salesOrderItem.ObjectState      = salesOrderItemViewModel.ObjectState;
                salesOrderItem.SalesOrderId     = _salesOrderModelView.SalesOrderId;
                salesOrderItem.RowVersion       = salesOrderItemViewModel.RowVersion;

                if (salesOrderItem.ObjectState == ObjectState.Added)
                {
                    salesOrderItem.SalesOrderItemId = temporarySalesOrderItemId;
                    temporarySalesOrderItemId--;
                }

                salesOrder.SalesOrderItems.Add(salesOrderItem);
            }

            return salesOrder;
        }
 public static SalesOrder CreateSalesOrderFromSalesOrderViewModel(SalesOrderViewModel saleOrderViewModel)
 {
     SalesOrder salesOrder = new SalesOrder();
        salesOrder.Id = saleOrderViewModel.SalesOrderId;
        salesOrder.CustomerName = saleOrderViewModel.CustomerName;
        salesOrder.PONumber = saleOrderViewModel.PONumber;
        return salesOrder;
 }