public void addCartexDesign() { CartexDesign cartexDesign = CartexDesignService.getCartexDesignByUserId(user.getId()); if (cartexDesign != null) { cartexDesign.setInformation(getInformation()); cartexDesign.setFileNumber(getFileNumber()); cartexDesign.setEconomicCode(getEconomicCode()); cartexDesign.setCity(getCity()); cartexDesign.setName1(getName1()); cartexDesign.setTitle1(getTitle1()); cartexDesign.setName2(getName2()); cartexDesign.setTitle2(getTitle2()); CartexDesignService.editCartexDesign(cartexDesign); } else { CartexDesignService.addCartexDesign( user.getId(), getInformation(), getFileNumber(), getEconomicCode(), getCity(), getName1(), getTitle1(), getName2(), getTitle2(), null); } addMessage(FacesMessage.SEVERITY_INFO, LanguageUtil.get("cartex_design_added_successfully")); }
public void uploadFile(FileUploadEvent event) throws IOException { CartexDesign cartexDesign = CartexDesignService.getCartexDesignByUserId(user.getId()); if (cartexDesign != null) { cartexDesign.setImage(IOUtils.toByteArray(event.getFile().getInputstream())); CartexDesignService.editCartexDesign(cartexDesign); } else { CartexDesignService.addCartexDesign( user.getId(), "", "", "", "", "", "", "", "", IOUtils.toByteArray(event.getFile().getInputstream())); } init(); }