Search in sources :

Example 1 with OnSiteTicket

use of com.eventyay.organizer.data.ticket.OnSiteTicket in project open-event-orga-app by fossasia.

the class CreateOrderViewModel method createOnSiteOrder.

public void createOnSiteOrder(long eventId) {
    Order order = new Order();
    Event event = new Event();
    event.setId(eventId);
    order.setEvent(event);
    order.setAmount(orderAmount.getValue());
    for (Long ticketId : onSiteTicketsMap.keySet()) {
        OnSiteTicket onSiteTicket = new OnSiteTicket();
        onSiteTicket.setId(ticketId);
        onSiteTicket.setQuantity(onSiteTicketsMap.get(ticketId).get());
        onSiteTicketsList.add(onSiteTicket);
    }
    order.setOnSiteTickets(onSiteTicketsList);
    compositeDisposable.add(orderRepository.createOrder(order).compose(dispose(compositeDisposable)).doOnSubscribe(disposable -> progress.setValue(true)).doFinally(() -> {
        clearSelectedTickets();
        progress.setValue(false);
    }).subscribe(createdOrder -> success.setValue("Order created successfully"), throwable -> error.setValue(ErrorUtils.getMessage(throwable).toString())));
}
Also used : Order(com.eventyay.organizer.data.order.Order) MutableLiveData(androidx.lifecycle.MutableLiveData) LiveData(androidx.lifecycle.LiveData) SingleEventLiveData(com.eventyay.organizer.common.livedata.SingleEventLiveData) Event(com.eventyay.organizer.data.event.Event) ViewTransformers.dispose(com.eventyay.organizer.common.rx.ViewTransformers.dispose) ViewModel(androidx.lifecycle.ViewModel) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) TicketRepository(com.eventyay.organizer.data.ticket.TicketRepository) OrderRepository(com.eventyay.organizer.data.order.OrderRepository) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Order(com.eventyay.organizer.data.order.Order) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Map(java.util.Map) OnSiteTicket(com.eventyay.organizer.data.ticket.OnSiteTicket) ErrorUtils(com.eventyay.organizer.utils.ErrorUtils) Ticket(com.eventyay.organizer.data.ticket.Ticket) ObservableLong(androidx.databinding.ObservableLong) OnSiteTicket(com.eventyay.organizer.data.ticket.OnSiteTicket) ObservableLong(androidx.databinding.ObservableLong) Event(com.eventyay.organizer.data.event.Event)

Aggregations

ObservableLong (androidx.databinding.ObservableLong)1 LiveData (androidx.lifecycle.LiveData)1 MutableLiveData (androidx.lifecycle.MutableLiveData)1 ViewModel (androidx.lifecycle.ViewModel)1 SingleEventLiveData (com.eventyay.organizer.common.livedata.SingleEventLiveData)1 ViewTransformers.dispose (com.eventyay.organizer.common.rx.ViewTransformers.dispose)1 Event (com.eventyay.organizer.data.event.Event)1 Order (com.eventyay.organizer.data.order.Order)1 OrderRepository (com.eventyay.organizer.data.order.OrderRepository)1 OnSiteTicket (com.eventyay.organizer.data.ticket.OnSiteTicket)1 Ticket (com.eventyay.organizer.data.ticket.Ticket)1 TicketRepository (com.eventyay.organizer.data.ticket.TicketRepository)1 ErrorUtils (com.eventyay.organizer.utils.ErrorUtils)1 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Inject (javax.inject.Inject)1