package org.academiadecodigo.enuminatti.helloworld;

import org.academiadecodigo.enuminatti.helloworld.models.Bootcamp;
import org.academiadecodigo.enuminatti.helloworld.models.User;
import org.academiadecodigo.enuminatti.helloworld.services.BootcampService;
import org.academiadecodigo.enuminatti.helloworld.services.UserService;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * MIT License
 * (c) 2017 Ricardo Constantino
 */

public class Main implements ServletContextListener {
    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        UserService userService = new UserService();
        userService.addUser(new User("Ricardo", "c@d", "a"));
        userService.addUser(new User("JP", "c@d", "a"));
        servletContextEvent.getServletContext().setAttribute("userService", userService);

        BootcampService bootcampService = new BootcampService();
        bootcampService.addBootcamp(new Bootcamp(1, "Lisboa", "2017/09/04", "2017/12/07"));
        bootcampService.addBootcamp(new Bootcamp(2, "Fundão", "2017/09/04", "2017/12/07"));
        servletContextEvent.getServletContext().setAttribute("bootcampService", bootcampService);
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {

    }
}
