예제 #1
0
 /// <summary>
 /// maps a collection of SalesOrderItems (data) to SalesOrderItemModels (view models)
 /// </summary>
 /// <param name="orderItems"></param>
 /// <returns></returns>
 private static List <SalesOrderItemModel> SerializeSalesOrderItems(IEnumerable <SalesOrderItem> orderItems)
 {
     return(orderItems.Select(item => new SalesOrderItemModel
     {
         Id = item.Id,
         Quantity = item.Quantity,
         Product = ProductMapper.SerializeProductModel(item.Product)
     }).ToList());
 }
예제 #2
0
        /// <summary>
        /// Maps an InvoiceModel view model to a SalesOrder data model
        /// </summary>
        /// <param name="invoice"></param>
        /// <returns></returns>
        public static SalesOrder SerializeInvoiceToOrder(InvoiceModel invoice)
        {
            var salesOrderItems = invoice.LineItems
                                  .Select(item => new SalesOrderItem
            {
                Id       = item.Id,
                Quantity = item.Quantity,
                Product  = ProductMapper.SerializeProductModel(item.Product)
            }).ToList();

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