package net.sevecek.zakladniwebapp;

import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.*;

@Controller
public class HlavniController {

    @RequestMapping(value = "/ukazka.html", method = RequestMethod.GET)
    public ModelAndView zobrazUkazku() {
        ModelAndView modelAndView = new ModelAndView(
                "/WEB-INF/view/ukazka.jsp");
        return modelAndView;
    }

    @RequestMapping(value = "/ukazka.html", method = RequestMethod.POST)
    public ModelAndView ukazVysledek(VypoctyProFarmare info) {
        ModelAndView modelAndView = new ModelAndView(
                "/WEB-INF/view/vysledek.jsp");
        
        modelAndView.addObject("pocetHus", info.getPocetHus());
        modelAndView.addObject("pocetHouseru", info.getPocetHouseru());
        modelAndView.addObject("pocetKraliku", info.getPocetKraliku());
        modelAndView.addObject("pocetKralic", info.getPocetKralic());
        modelAndView.addObject("mnozstviPsenice", info.zjistitMnozstviPsenice());
        modelAndView.addObject("mnozstviMrkve", info.zjistitMnozstviMrkve());
        modelAndView.addObject("pocetRadkuPsenice", info.zjistitMnozstviPsenice() / 2);
        modelAndView.addObject("pocetRadkuMrkve", info.zjistitMnozstviMrkve() / 5);

        return modelAndView;
    }

}
