/// <summary> /// Builds an instance of CustomizedProduct based on the given Product with the data in the given instance of AddCustomizedProductModelView. /// </summary> /// <param name="addCustomizedProductModelView">AddCustomizedProductModelView containing the CustomizedProduct's information.</param> /// <param name="product">Instance of Product.</param> /// <param name="parentCustomizedProduct">Parent CustomizedProduct.</param> /// <param name="insertedInSlot">Slot in which the CustomizedProduct will be inserted.</param> /// <exception cref="System.ArgumentException"> /// Thrown when the Material referenced by the CustomizedMaterial is not found or when no CustomizedDimensions are provided. /// </exception> /// <returns>A new instance of CustomizedProduct.</returns> private static CustomizedProduct buildSubCustomizedProduct(AddCustomizedProductModelView addCustomizedProductModelView, Product product, CustomizedProduct parentCustomizedProduct, Slot insertedInSlot) { CustomizedProductBuilder customizedProductBuilder = null; if (addCustomizedProductModelView.customizedDimensions == null) { throw new ArgumentException(ERROR_NO_CUSTOMIZED_DIMENSIONS); } CustomizedDimensions customizedProductDimensions = CustomizedDimensionsModelViewService.fromModelView(addCustomizedProductModelView.customizedDimensions); if (addCustomizedProductModelView.userAuthToken == null) { customizedProductBuilder = CustomizedProductBuilder.createCustomizedProduct(product, customizedProductDimensions, parentCustomizedProduct, insertedInSlot); } else { customizedProductBuilder = CustomizedProductBuilder .createCustomizedProduct(addCustomizedProductModelView.userAuthToken, product, customizedProductDimensions, parentCustomizedProduct, insertedInSlot); } if (addCustomizedProductModelView.customizedMaterial != null) { CustomizedMaterial customizedMaterial = CreateCustomizedMaterialService.create(addCustomizedProductModelView.customizedMaterial); customizedProductBuilder.withMaterial(customizedMaterial); } //ignore designation since only the base customized products can set the designation return(customizedProductBuilder.build()); }
/// <summary> /// Builds an instance of CustomizedProduct based on the given Product with the data in the given instance of AddCustomizedProductModelView. /// </summary> /// <param name="addCustomizedProductModelView">AddCustomizedProductModelView containing the CustomizedProduct's information.</param> /// <param name="product">Instance of Product.</param> /// <returns>Built instance of CustomizedProduct.</returns> /// <exception cref="System.ArgumentException"> /// Thrown when the Material referenced by the CustomizedMaterial is not found or when no CustomizedDimensions are provided. /// </exception> /// <returns>A new instance of CustomizedProduct.</returns> private static CustomizedProduct buildCustomizedProduct(AddCustomizedProductModelView addCustomizedProductModelView, Product product) { CustomizedProductBuilder customizedProductBuilder = null; if (addCustomizedProductModelView.customizedDimensions == null) { throw new ArgumentException(ERROR_NO_CUSTOMIZED_DIMENSIONS); } CustomizedDimensions customizedProductDimensions = CustomizedDimensionsModelViewService.fromModelView(addCustomizedProductModelView.customizedDimensions); if (addCustomizedProductModelView.userAuthToken == null) { customizedProductBuilder = CustomizedProductBuilder.createCustomizedProduct(addCustomizedProductModelView.reference, product, customizedProductDimensions); } else { customizedProductBuilder = CustomizedProductBuilder .createCustomizedProduct(addCustomizedProductModelView.userAuthToken, addCustomizedProductModelView.reference, product, customizedProductDimensions); } //build customized product with optional properties if they're defined if (addCustomizedProductModelView.customizedMaterial != null) { CustomizedMaterial customizedMaterial = CreateCustomizedMaterialService.create(addCustomizedProductModelView.customizedMaterial); customizedProductBuilder.withMaterial(customizedMaterial); } if (addCustomizedProductModelView.designation != null) { customizedProductBuilder.withDesignation(addCustomizedProductModelView.designation); } return(customizedProductBuilder.build()); }