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()); }
///<summary> /// Maps an InvoiceModel (view model) to a SalesOrder (data) model ///</summary> ///<param name="invoice"></param> ///<returns></returns> public static SalesOrder SerializeInvoiceOrder(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, UpdatedOn = DateTime.UtcNow, CreatedOn = DateTime.UtcNow }); }