Search in sources :

Example 6 with Ticket

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

the class CreateTicketViewModel method createTicket.

public void createTicket() {
    if (!verify())
        return;
    long eventId = ContextManager.getSelectedEvent().getId();
    Event event = new Event();
    event.setId(eventId);
    ticket.setEvent(event);
    compositeDisposable.add(ticketRepository.createTicket(ticket).doOnSubscribe(disposable -> progress.setValue(true)).doFinally(() -> progress.setValue(false)).subscribe(createdTicket -> {
        success.setValue("Ticket Created");
        dismiss.call();
    }, throwable -> error.setValue(ErrorUtils.getMessage(throwable).toString())));
}
Also used : DateUtils(com.eventyay.organizer.utils.DateUtils) LiveData(androidx.lifecycle.LiveData) SingleEventLiveData(com.eventyay.organizer.common.livedata.SingleEventLiveData) Event(com.eventyay.organizer.data.event.Event) ViewModel(androidx.lifecycle.ViewModel) ContextManager(com.eventyay.organizer.common.ContextManager) TicketRepository(com.eventyay.organizer.data.ticket.TicketRepository) ZonedDateTime(org.threeten.bp.ZonedDateTime) Inject(javax.inject.Inject) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) LocalDateTime(org.threeten.bp.LocalDateTime) ErrorUtils(com.eventyay.organizer.utils.ErrorUtils) Ticket(com.eventyay.organizer.data.ticket.Ticket) DateTimeParseException(org.threeten.bp.format.DateTimeParseException) Event(com.eventyay.organizer.data.event.Event)

Example 7 with Ticket

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

the class AutoCheckInFragment method autoCheckInAll.

// Inevitable DD anomaly
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
private void autoCheckInAll() {
    if (autoCheckInViewModel.getTickets() == null) {
        return;
    }
    boolean autoCheckInAll = true;
    for (Ticket ticket : autoCheckInViewModel.getTickets().getValue()) {
        if (!ticket.autoCheckinEnabled) {
            autoCheckInAll = false;
            break;
        }
    }
    binding.autoCheckInAllCheckbox.setChecked(autoCheckInAll);
}
Also used : Ticket(com.eventyay.organizer.data.ticket.Ticket)

Example 8 with Ticket

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

the class TicketRepositoryTest method shouldSaveCreatedTicket.

@Test
public void shouldSaveCreatedTicket() {
    Ticket created = mock(Ticket.class);
    when(repository.isConnected()).thenReturn(true);
    when(ticketApi.postTicket(TICKET)).thenReturn(Observable.just(created));
    when(repository.save(eq(Ticket.class), eq(created))).thenReturn(Completable.complete());
    ticketRepository.createTicket(TICKET).subscribe();
    verify(repository).save(Ticket.class, created);
}
Also used : Ticket(com.eventyay.organizer.data.ticket.Ticket) Test(org.junit.Test)

Example 9 with Ticket

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

the class CheckInRestrictions method checkRestrictAll.

// Inevitable DD anomaly
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
private void checkRestrictAll() {
    if (ticketSettingsViewModel.getTickets() == null) {
        return;
    }
    boolean restrictAll = true;
    for (Ticket ticket : ticketSettingsViewModel.getTickets().getValue()) {
        if (!ticket.isCheckinRestricted) {
            restrictAll = false;
            break;
        }
    }
    binding.restrictAllCheckbox.setChecked(restrictAll);
}
Also used : Ticket(com.eventyay.organizer.data.ticket.Ticket)

Example 10 with Ticket

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

the class EventRepositoryImpl method saveEvent.

private void saveEvent(Event event) {
    event.setComplete(true);
    repository.save(Event.class, event).subscribe();
    List<Ticket> tickets = event.getTickets();
    if (tickets != null) {
        for (Ticket ticket : tickets) ticket.setEvent(event);
        repository.saveList(Ticket.class, tickets).subscribe();
    }
}
Also used : Ticket(com.eventyay.organizer.data.ticket.Ticket)

Aggregations

Ticket (com.eventyay.organizer.data.ticket.Ticket)14 Test (org.junit.Test)8 InOrder (org.mockito.InOrder)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 Event (com.eventyay.organizer.data.event.Event)2 PrintManager (android.print.PrintManager)1 LiveData (androidx.lifecycle.LiveData)1 ViewModel (androidx.lifecycle.ViewModel)1 ContextManager (com.eventyay.organizer.common.ContextManager)1 SingleEventLiveData (com.eventyay.organizer.common.livedata.SingleEventLiveData)1 Repository (com.eventyay.organizer.data.Repository)1 Attendee (com.eventyay.organizer.data.attendee.Attendee)1 DbFlowDatabaseRepository (com.eventyay.organizer.data.db.DbFlowDatabaseRepository)1 TicketRepository (com.eventyay.organizer.data.ticket.TicketRepository)1 TicketRepositoryImpl (com.eventyay.organizer.data.ticket.TicketRepositoryImpl)1 DateUtils (com.eventyay.organizer.utils.DateUtils)1 ErrorUtils (com.eventyay.organizer.utils.ErrorUtils)1 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)1 ArrayList (java.util.ArrayList)1 Inject (javax.inject.Inject)1