public Order Map(OrderVM orderVM) { var order = new Order { UserId = orderVM.UserId, }; //potentially that will be entered already if (orderVM.Id != null) { order.Id = (int)orderVM.Id; } //potentially entered already if (orderVM.OrderDate != null) { order.OrderDate = (DateTime)orderVM.OrderDate; } foreach (var od in orderVM.OrderDetails) { order.OrderDetails.Add(Map(od)); } order.Ini(this); return(order); }
public OrderVM Map(Order order) { var orderVM = new OrderVM { Id = order.Id, UserId = order.UserId, OrderDate = order.OrderDate, }; //Convert the orderdetail items to be orderdetailvms foreach (var x in order.OrderDetails) { orderVM.OrderDetails.Add(Map(x)); } return(orderVM); }