@Override public SupplierDTO getSupplier(int id) { Supplier supplier = supplierDAO.findById(id); SupplierDTO supplierDTO = new SupplierDTO(); BeanUtils.copyProperties(supplier, supplierDTO); return supplierDTO; }
@Override public List<SupplierDTO> getAllSuppliers() { List<SupplierDTO> supplierDtos = new ArrayList<SupplierDTO>(); List<Supplier> suppliers = supplierDAO.findAll(); if (suppliers != null && !suppliers.isEmpty()) { for (Supplier supplier : suppliers) { SupplierDTO supplierDTO = new SupplierDTO(); BeanUtils.copyProperties(supplier, supplierDTO); supplierDtos.add(supplierDTO); } } return supplierDtos; }
@Override public void deleteSupplier(int id) { supplierDAO.deleteById(id); }
@Override public void update(SupplierDTO supplierDTO) { Supplier supplier = new Supplier(); BeanUtils.copyProperties(supplierDTO, supplier); supplierDAO.update(supplier); }