Package com.impromptu.events.infrastructure

Source Code of com.impromptu.events.infrastructure.DefaultEventMessageService

package com.impromptu.events.infrastructure;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.impromptu.events.Event;
import com.impromptu.events.EventMessageService;
import com.impromptu.events.repository.EventRepository;

@Service
public class DefaultEventMessageService implements EventMessageService {

private final EventRepository eventRepository;
 
  @Autowired
  public DefaultEventMessageService(EventRepository eventRepository) {
    this.eventRepository = eventRepository;
  }
 
    @Override
    public Event addMessage(String eventId, String message) {
        Event event = eventRepository.findOne(eventId);
        List<String> messages = event.getMessages();
        messages.add(message);
        event.setMessages(messages);
        return eventRepository.save(event);
    }

}
TOP

Related Classes of com.impromptu.events.infrastructure.DefaultEventMessageService

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.