package com.pollistics.services;

import java.util.List;

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

import com.pollistics.models.Poll;
import com.pollistics.repositories.PollRepository;

@Service
public class PollService {
	@Autowired
	private PollRepository pollRepo;
	
	public Poll getPoll(String id) {
		return pollRepo.findOne(id);
	}
	
	public List<Poll> getAllPolls() {
		return pollRepo.findAll();
	}
}

@@ -27,16 +27,42 @@
 vices;%0A%0A
+import java.util.HashMap;%0A
 import j
@@ -76,16 +76,16 @@
 l.List;%0A
-
 %0Aimport 
@@ -357,18 +357,17 @@
 llRepo;%0A
-%09
 %0A
+
 %09public 
@@ -430,10 +430,9 @@
 %0A%09%7D%0A
-%09
 %0A
+
 %09pub
@@ -458,24 +458,24 @@
 llPolls() %7B%0A
-
 %09%09return pol
@@ -493,11 +493,180 @@
 ll();%0A%09%7D
+%0A%0A%09public String createPoll(String name, HashMap%3CString, Integer%3E options) %7B%0A%09%09Poll poll = pollRepo.insert(new Poll(name, options));%0A%09%09return poll.getId().toString();%0A%09%7D
 %0A%7D%0A

Write polls to database