/// <summary> /// Map OrderModel to Order /// </summary> /// <param name="orderModel"></param> /// <returns></returns> public static Order MapToOrder(OrderModel orderModel) { TypeAdapterConfig <OrderModel, Order> .NewConfig() .Ignore(dst => dst.AdditionalInfo) .Ignore(dst => dst.Customer) .Ignore(dst => dst.LineItems); return(orderModel.Adapt <Order>()); }
public int Add(OrderModel model) { var newOrder = model.Adapt <OrderEntity>(); newOrder.Date = DateTime.Now; newOrder.Status = OrderStatus.Successful; if (model.Items.Count <= 0) { throw new ValidatorException("Can not create order without items"); } CreateOrderItem(newOrder, model); orderValidator.Validate(newOrder); orderRepository.Add(newOrder); return(newOrder.OrderId); }