Search in sources :

Example 1 with OrderInfo

use of io.github.zutherb.appstash.shop.service.order.model.OrderInfo in project the-app by devops-dojo.

the class CheckoutPage method submitOrderLink.

private Component submitOrderLink() {
    return new SubmitLink("submitOrder") {

        private static final long serialVersionUID = 5203227218130238529L;

        @Override
        protected void onBeforeRender() {
            setVisible(!isReadOnly() && getAuthenticationService().isAuthorized());
            super.onBeforeRender();
        }

        @Override
        public void onSubmit() {
            OrderInfo submittedOrder = orderService.submitOrder(orderInfoModel.getObject(), getSession().getId());
            trackingService.trackPurchase(submittedOrder);
            getSession().info(CheckoutPage.this.getString("order.submitted"));
            setResponsePage(new OrderConfirmationPage(Model.of(submittedOrder)));
        }
    };
}
Also used : SubmitLink(org.apache.wicket.markup.html.form.SubmitLink) OrderInfo(io.github.zutherb.appstash.shop.service.order.model.OrderInfo)

Example 2 with OrderInfo

use of io.github.zutherb.appstash.shop.service.order.model.OrderInfo in project the-app by devops-dojo.

the class OrderServiceImpl method submitOrder.

@Override
public OrderInfo submitOrder(OrderInfo orderInfo, String sessionId) {
    Long orderId = orderIdProvider.nextVal();
    OrderInfo orderInfoToSave = new OrderInfo(orderId, sessionId, orderInfo);
    save(orderInfoToSave);
    logger.info(String.format("Order %d was submited", orderInfoToSave.getOrderId()));
    cart.clear();
    return orderInfoToSave;
}
Also used : OrderInfo(io.github.zutherb.appstash.shop.service.order.model.OrderInfo)

Example 3 with OrderInfo

use of io.github.zutherb.appstash.shop.service.order.model.OrderInfo in project the-app by devops-dojo.

the class DeliveryAdressEditPanel method deliveryAdressEditForm.

private Component deliveryAdressEditForm() {
    Form<OrderInfo> deliveryAdressEditForm = new Form<>("deliveryAdressEditForm");
    deliveryAdressEditForm.add(new TextField<>("firstname", new PropertyModel<>(orderModel, "deliveryAddress.firstname")).setRequired(true));
    deliveryAdressEditForm.add(new TextField<>("lastname", new PropertyModel<>(orderModel, "deliveryAddress.lastname")).setRequired(true));
    deliveryAdressEditForm.add(new TextField<>("street", new PropertyModel<>(orderModel, "deliveryAddress.street")).setRequired(true));
    deliveryAdressEditForm.add(new TextField<>("zip", new PropertyModel<>(orderModel, "deliveryAddress.zip")).setRequired(true));
    deliveryAdressEditForm.add(new TextField<>("city", new PropertyModel<>(orderModel, "deliveryAddress.city")).setRequired(true));
    deliveryAdressEditForm.add(new SubmitLink("deliveryAdressEditFormSubmit") {

        private static final long serialVersionUID = 8821619700889289116L;

        @Override
        public void onSubmit() {
            deliveryAdressEditFormSubmit();
        }
    });
    return deliveryAdressEditForm;
}
Also used : Form(org.apache.wicket.markup.html.form.Form) SubmitLink(org.apache.wicket.markup.html.form.SubmitLink) TextField(org.apache.wicket.markup.html.form.TextField) OrderInfo(io.github.zutherb.appstash.shop.service.order.model.OrderInfo)

Example 4 with OrderInfo

use of io.github.zutherb.appstash.shop.service.order.model.OrderInfo in project the-app by devops-dojo.

the class OrderServiceImpl method mapSourceEntityToDestinationEntity.

@Override
protected OrderInfo mapSourceEntityToDestinationEntity(Order sourceEntity) {
    OrderInfo orderInfo = super.mapSourceEntityToDestinationEntity(sourceEntity);
    orderInfo.setUser(userService.findById(sourceEntity.getUserId()));
    return orderInfo;
}
Also used : OrderInfo(io.github.zutherb.appstash.shop.service.order.model.OrderInfo)

Aggregations

OrderInfo (io.github.zutherb.appstash.shop.service.order.model.OrderInfo)4 SubmitLink (org.apache.wicket.markup.html.form.SubmitLink)2 Form (org.apache.wicket.markup.html.form.Form)1 TextField (org.apache.wicket.markup.html.form.TextField)1