Example #1
0
        public static SalesOrderViewModel CreateSalesOrderViewModelFromSalesOrder(SalesOrder salesOrder)
        {
            SalesOrderViewModel salesOrderViewModel = new SalesOrderViewModel
            {
                SalesOrderId = salesOrder.SalesOrderId,
                CustomerName = salesOrder.CustomerName,
                PONumber     = salesOrder.PONumber,
                ObjectState  = ObjectState.Unchanged
            };

            foreach (SalesOrderItem salesOrderItem in salesOrder.SalesOrderItems)
            {
                SalesOrderItemViewModel salesOrderItemViewModel = new SalesOrderItemViewModel
                {
                    SalesOrderItemId = salesOrderItem.SalesOrderItemId,
                    ProductCode      = salesOrderItem.ProductCode,
                    Quantity         = salesOrderItem.Quantity,
                    UnitPrice        = salesOrderItem.UnitPrice,
                    ObjectState      = salesOrderItem.ObjectState,
                    SalesOrderId     = salesOrderItem.SalesOrderId
                };

                salesOrderViewModel.SalesOrderItems.Add(salesOrderItemViewModel);
            }

            return(salesOrderViewModel);
        }
Example #2
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;
        }
        public static SalesOrderViewModel CreateSalesOrderViewModelFromSalesOrder(SalesOrder salesOrder)
        {
            SalesOrderViewModel salesOrderViewModel = new SalesOrderViewModel();

            salesOrderViewModel.SalesOrderId = salesOrder.SalesOrderId;
            salesOrderViewModel.CustomerName = salesOrder.CustomerName;
            salesOrderViewModel.PONumber     = salesOrder.PONumber;
            salesOrderViewModel.ObjectState  = ObjectState.Unchanged;

            foreach (SalesOrderItem salesOrderItem in salesOrder.SalesOrderItems)
            {
                SalesOrderItemViewModel salesOrderItemViewModel = new SalesOrderItemViewModel();
                salesOrderItemViewModel.SalesOrderItemId = salesOrderItem.SalesOrderItemId;
                salesOrderItemViewModel.ProductCode      = salesOrderItem.ProductCode;
                salesOrderItemViewModel.Quantity         = salesOrderItem.Quantity;
                salesOrderItemViewModel.UnitPrice        = salesOrderItem.UnitPrice;

                salesOrderItemViewModel.ObjectState = ObjectState.Unchanged;

                salesOrderItemViewModel.SalesOrderId = salesOrder.SalesOrderId;

                salesOrderViewModel.SalesOrderItems.Add(salesOrderItemViewModel);
            }

            return(salesOrderViewModel);
        }