/*
 * WordGridController.java
 *
 * Copyright (C) 2017 [ A Legge Up ]
 *
 * This software may be modified and distributed under the terms
 * of the MIT license.  See the LICENSE file for details.
 */

package com.aleggeup.confagrid.controller;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.aleggeup.confagrid.data.WordGridRepository;
import com.aleggeup.confagrid.model.WordGrid;

@Controller
@RequestMapping("/api/v1")
public class WordGridController {

    private final WordGridRepository wordGridRepository;

    @Autowired
    public WordGridController(final WordGridRepository wordGridRepository) {
        this.wordGridRepository = wordGridRepository;
    }

    @RequestMapping("word-grids")
    @ResponseBody
    public List<WordGrid> allWordGrids() {
        final List<WordGrid> wordGrids = new ArrayList<>();

        for (final Iterator<WordGrid> iterator = this.wordGridRepository.findAll().iterator(); iterator.hasNext();) {
            wordGrids.add(iterator.next());
        }

        return wordGrids;
    }
}

@@ -484,23 +484,145 @@
 .Request
-Mapping
+Body;%0Aimport org.springframework.web.bind.annotation.RequestMapping;%0Aimport org.springframework.web.bind.annotation.RequestMethod
 ;%0Aimport
@@ -1389,24 +1389,390 @@
 %0A        %7D%0A%0A
+        return wordGrids;%0A    %7D%0A%0A    @RequestMapping(method = RequestMethod.POST, value=%22/word-grids%22)%0A    @ResponseBody%0A    public List%3CWordGrid%3E create(@RequestBody WordGrid wordGrid) %7B%0A        final List%3CWordGrid%3E wordGrids = new ArrayList%3C%3E();%0A        final WordGrid savedWordGrid = this.wordGridRepository.save(wordGrid);%0A        wordGrids.add(savedWordGrid);%0A%0A
         retu

Add a 'create' to save to database