Search in sources :

Example 21 with Event

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

the class UpdateTrackViewModel method updateTrack.

public void updateTrack() {
    nullifyEmptyFields(track);
    long eventId = ContextManager.getSelectedEvent().getId();
    Event event = new Event();
    event.setId(eventId);
    track.setEvent(event);
    compositeDisposable.add(trackRepository.updateTrack(track).doOnSubscribe(disposable -> progress.setValue(true)).doFinally(() -> progress.setValue(false)).subscribe(updatedTrack -> {
        success.setValue("Track Updated");
        dismiss.call();
    }, throwable -> error.setValue(ErrorUtils.getMessage(throwable).toString())));
}
Also used : Color(android.graphics.Color) Inject(javax.inject.Inject) LiveData(androidx.lifecycle.LiveData) SingleEventLiveData(com.eventyay.organizer.common.livedata.SingleEventLiveData) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Event(com.eventyay.organizer.data.event.Event) ViewModel(androidx.lifecycle.ViewModel) ContextManager(com.eventyay.organizer.common.ContextManager) TrackRepository(com.eventyay.organizer.data.tracks.TrackRepository) ErrorUtils(com.eventyay.organizer.utils.ErrorUtils) StringUtils(com.eventyay.organizer.utils.StringUtils) Track(com.eventyay.organizer.data.tracks.Track) Event(com.eventyay.organizer.data.event.Event)

Example 22 with Event

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

the class CreateSessionViewModel method updateSession.

// Method called for updating an session
public void updateSession(long trackId, long eventId) {
    Track track = new Track();
    Event event = new Event();
    track.setId(trackId);
    event.setId(eventId);
    session.setTrack(track);
    session.setEvent(event);
    nullifyEmptyFields(session);
    compositeDisposable.add(sessionRepository.updateSession(session).doOnSubscribe(disposable -> progress.setValue(true)).doFinally(() -> progress.setValue(false)).subscribe(updatedSession -> {
        success.setValue("Session Updated Successfully");
        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) ZonedDateTime(org.threeten.bp.ZonedDateTime) Inject(javax.inject.Inject) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) SessionRepository(com.eventyay.organizer.data.session.SessionRepository) LocalDateTime(org.threeten.bp.LocalDateTime) ErrorUtils(com.eventyay.organizer.utils.ErrorUtils) StringUtils(com.eventyay.organizer.utils.StringUtils) Track(com.eventyay.organizer.data.tracks.Track) Session(com.eventyay.organizer.data.session.Session) DateTimeParseException(org.threeten.bp.format.DateTimeParseException) Event(com.eventyay.organizer.data.event.Event) Track(com.eventyay.organizer.data.tracks.Track)

Example 23 with Event

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

the class CreateSessionViewModel method createSession.

public void createSession(long trackId, long eventId) {
    if (!verify())
        return;
    Track track = new Track();
    Event event = new Event();
    track.setId(trackId);
    event.setId(eventId);
    session.setTrack(track);
    session.setEvent(event);
    nullifyEmptyFields(session);
    compositeDisposable.add(sessionRepository.createSession(session).doOnSubscribe(disposable -> progress.setValue(true)).doFinally(() -> progress.setValue(false)).subscribe(createdSession -> {
        success.setValue("Session 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) ZonedDateTime(org.threeten.bp.ZonedDateTime) Inject(javax.inject.Inject) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) SessionRepository(com.eventyay.organizer.data.session.SessionRepository) LocalDateTime(org.threeten.bp.LocalDateTime) ErrorUtils(com.eventyay.organizer.utils.ErrorUtils) StringUtils(com.eventyay.organizer.utils.StringUtils) Track(com.eventyay.organizer.data.tracks.Track) Session(com.eventyay.organizer.data.session.Session) DateTimeParseException(org.threeten.bp.format.DateTimeParseException) Event(com.eventyay.organizer.data.event.Event) Track(com.eventyay.organizer.data.tracks.Track)

Example 24 with Event

use of com.eventyay.organizer.data.event.Event 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)

Example 25 with Event

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

the class RoleInviteViewModel method createRoleInvite.

public void createRoleInvite(long roleId) {
    long eventId = ContextManager.getSelectedEvent().getId();
    Event event = new Event();
    event.setId(eventId);
    roleInvite.setEvent(event);
    role.setId(roleId);
    roleInvite.setRole(role);
    compositeDisposable.add(roleRepository.sendRoleInvite(roleInvite).doOnSubscribe(disposable -> progress.setValue(true)).doFinally(() -> progress.setValue(false)).subscribe(sentRoleInvite -> {
        success.setValue("Role Invite Sent");
        dismiss.call();
    }, throwable -> error.setValue(ErrorUtils.getMessage(throwable).toString())));
}
Also used : Inject(javax.inject.Inject) LiveData(androidx.lifecycle.LiveData) SingleEventLiveData(com.eventyay.organizer.common.livedata.SingleEventLiveData) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Event(com.eventyay.organizer.data.event.Event) RoleInvite(com.eventyay.organizer.data.role.RoleInvite) Role(com.eventyay.organizer.data.role.Role) ViewModel(androidx.lifecycle.ViewModel) ContextManager(com.eventyay.organizer.common.ContextManager) ErrorUtils(com.eventyay.organizer.utils.ErrorUtils) RoleRepository(com.eventyay.organizer.data.role.RoleRepository) Event(com.eventyay.organizer.data.event.Event)

Aggregations

Event (com.eventyay.organizer.data.event.Event)36 LiveData (androidx.lifecycle.LiveData)15 ViewModel (androidx.lifecycle.ViewModel)15 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)15 Inject (javax.inject.Inject)15 ErrorUtils (com.eventyay.organizer.utils.ErrorUtils)14 Test (org.junit.Test)14 SingleEventLiveData (com.eventyay.organizer.common.livedata.SingleEventLiveData)13 ContextManager (com.eventyay.organizer.common.ContextManager)10 StringUtils (com.eventyay.organizer.utils.StringUtils)8 DateUtils (com.eventyay.organizer.utils.DateUtils)5 LocalDateTime (org.threeten.bp.LocalDateTime)5 ZonedDateTime (org.threeten.bp.ZonedDateTime)5 DateTimeParseException (org.threeten.bp.format.DateTimeParseException)5 VisibleForTesting (androidx.annotation.VisibleForTesting)4 MutableLiveData (androidx.lifecycle.MutableLiveData)4 Track (com.eventyay.organizer.data.tracks.Track)4 InOrder (org.mockito.InOrder)4 Logger (com.eventyay.organizer.common.rx.Logger)3 Ticket (com.eventyay.organizer.data.ticket.Ticket)3