PostulanteController.java 1.2 KB
Newer Older
1 2 3 4 5 6 7
package com.roshka.controller;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;

8
import com.roshka.modelo.Experiencia;
9 10 11 12 13 14
import com.roshka.modelo.Postulante;
import com.roshka.repositorio.PostulanteRepository;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
15
import org.springframework.web.bind.annotation.RequestBody;
16 17 18 19 20 21 22
import org.springframework.web.bind.annotation.RequestMapping;

@Controller

public class PostulanteController {
    @Autowired
    PostulanteRepository post;  
23

24
    @RequestMapping("/")
25 26
    public String index() {
        return "index";
27 28
    }

29 30
    @RequestMapping("/postulante")
    public String getFormPostulante(){
31
        
32 33
        return "postulante-form";
    }
34

35 36
    @PostMapping(value = "/postulante",consumes = "application/json")
    public String guardarPostulante(@RequestBody Postulante postulante){
37 38 39 40 41
        post.save(postulante);
        for(Experiencia exp: postulante.getExperiencias()){
            exp.setPostulante(postulante);
        }
        post.save(postulante);
42
        return "redirect:/";
43 44 45
    }

}