Пример #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);
  }
Пример #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);
  }
Пример #3
0
 public List<UserPaymentUI> findByUser(String userName) {
   Customer customer = new Customer();
   customer.setUsername(userName);
   return mapper.toUIBean(repository.findByCustomer(customer));
 }
Пример #4
0
  public Page<UserPaymentUI> findAll(Pageable pageable, List<FilterRequest> filters) {

    Predicate predicate = toPredicate(filters);
    return mapper.toUIBean(repository.findAll(predicate, pageable), pageable);
  }
Пример #5
0
 public UserPaymentUI find(long paymentId) {
   return mapper.toUIBean(repository.findById(paymentId));
 }