Esempio n. 1
0
        public static SalesOrderViewModel CreateSalesOrderViewModelFromSalesOrder(SalesOrder salesOrder)
        {
            SalesOrderViewModel salesOrderViewModel = new SalesOrderViewModel()
                                                          {
                                                              CustomerName = salesOrder.CustomerName,
                                                              PoNumber = salesOrder.PoNumber,
                                                              SalesOrderId = salesOrder.SalesOrderId,
                                                              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 = salesOrderItem.SalesOrderId;

                salesOrderViewModel.SalesOrderItems.Add(salesOrderItemViewModel);
            }

            return salesOrderViewModel;
        }
Esempio n. 2
0
        public static SalesOrderViewModel CreateSalesOrderViewModelFromSalesOrder(SalesOrder salesOrder)
        {
            SalesOrderViewModel salesOrderViewModel = new SalesOrderViewModel()
            {
                CustomerName = salesOrder.CustomerName,
                PoNumber     = salesOrder.PoNumber,
                SalesOrderId = salesOrder.SalesOrderId,
                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     = salesOrderItem.SalesOrderId;

                salesOrderViewModel.SalesOrderItems.Add(salesOrderItemViewModel);
            }


            return(salesOrderViewModel);
        }
Esempio n. 3
0
        public static SalesOrderViewModel CreateSalesOrderViewModelFromSalesOrder(SalesOrder salesOrder)
        {
            var salesOrderViewModel = new SalesOrderViewModel();

            salesOrderViewModel.Id           = salesOrder.Id;
            salesOrderViewModel.CustomerName = salesOrder.CustomerName;
            salesOrderViewModel.PONumber     = salesOrder.PONumber;
            salesOrderViewModel.ObjectState  = ObjectState.Unchanged;
            salesOrderViewModel.RowVersion   = salesOrder.RowVersion;

            foreach (var item in salesOrder.Items)
            {
                var itemViewModel = new SalesOrderItemViewModel();
                itemViewModel.Id           = item.Id;
                itemViewModel.ProductCode  = item.ProductCode;
                itemViewModel.Quantity     = item.Quantity;
                itemViewModel.UnitPrice    = item.UnitPrice;
                itemViewModel.ObjectState  = ObjectState.Unchanged;
                itemViewModel.SalesOrderId = item.SalesOrderId;
                itemViewModel.RowVersion   = item.RowVersion;
                salesOrderViewModel.Items.Add(itemViewModel);
            }
            return(salesOrderViewModel);
        }