Exemplo n.º 1
0
  @Transactional
  public UserPaymentUI create(UserPaymentUI uiBean) {

    UserPayment newUserPayment = mapper.toPersistenceBean(uiBean);

    if (uiBean.getUserName() == null) {
      return null;
    }

    Customer customer = userRepository.findByUsername(uiBean.getUserName());
    newUserPayment.setCustomer(customer);

    UserPayment saved = repository.save(newUserPayment);
    logger.debug("Added Payment : " + saved);

    return mapper.toUIBean(saved);
  }
Exemplo n.º 2
0
  public UserPaymentUI update(UserPaymentUI uiBean) {
    UserPayment existing = repository.findById(uiBean.getId());

    if (existing == null) {
      return null;
    }

    existing.setAmount(uiBean.getAmount());
    existing.setNotes(uiBean.getNotes());

    UserPayment saved = null;

    try {
      saved = repository.save(existing);
    } catch (Exception e) {
      logger.error(e);
    }

    return mapper.toUIBean(saved);
  }
Exemplo n.º 3
0
 public List<UserPaymentUI> findByUser(String userName) {
   Customer customer = new Customer();
   customer.setUsername(userName);
   return mapper.toUIBean(repository.findByCustomer(customer));
 }
Exemplo n.º 4
0
  public Page<UserPaymentUI> findAll(Pageable pageable, List<FilterRequest> filters) {

    Predicate predicate = toPredicate(filters);
    return mapper.toUIBean(repository.findAll(predicate, pageable), pageable);
  }
Exemplo n.º 5
0
 public UserPaymentUI find(long paymentId) {
   return mapper.toUIBean(repository.findById(paymentId));
 }