Beispiel #1
0
 // Maps a collection of SalesOrderItems data model to SalesOrderItemsVM
 private static List <SalesOrderItemViewModel> SerializeSalesOrderItems(IEnumerable <SalesOrderItem> orderItems)
 {
     return(orderItems.Select(item => new SalesOrderItemViewModel
     {
         Id = item.Id,
         Quantity = item.Quantity,
         InventoryProduct = ProductMapper.SerializeProductViewModel(item.InventoryProduct)
     }).ToList());
 }
Beispiel #2
0
 //Serializes an inventoryVM to an inventory data model
 public static ProductInventory SerializeInventory(InventoryViewModel inventory)
 {
     return(new ProductInventory
     {
         Id = inventory.Id,
         CreatedOn = inventory.CreatedOn,
         UpdatedOn = inventory.UpdatedOn,
         QuantityOnHand = inventory.QuantityOnHand,
         IdealQuantity = inventory.IdealQuantity,
         InventoryProduct = ProductMapper.SerializeProductViewModel(inventory.InventoryProduct)
     });
 }
Beispiel #3
0
        // Maps an InvoiceVM to a SalesOrder data model
        public static SalesOrder SerializeInvoiceToOrder(InvoiceViewModel order)
        {
            var salesOrderItems = order.LineItems
                                  .Select(item => new SalesOrderItem
            {
                Id               = item.Id,
                Quantity         = item.Quantity,
                InventoryProduct = ProductMapper.SerializeProductViewModel(item.InventoryProduct)
            }).ToList();

            return(new SalesOrder
            {
                SalesOrderItems = salesOrderItems,
                CreatedOn = order.CreatedOn,
                UpdatedOn = order.UpdatedOn
            });
        }