com.soltec.mmc.controllers.MiCuentaController.java Source code

Java tutorial

Introduction

Here is the source code for com.soltec.mmc.controllers.MiCuentaController.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.soltec.mmc.controllers;

import com.soltec.mmc.dao.AdministradorDAO;
import com.soltec.mmc.dao.AdministradorImplementation;
import com.soltec.mmc.dao.ArtistaDAO;
import com.soltec.mmc.dao.ArtistaImplementation;
import com.soltec.mmc.dao.CuentaUsuarioDAO;
import com.soltec.mmc.dao.CuentaUsuarioImplementation;
import com.soltec.mmc.modelos.Administrador;
import com.soltec.mmc.modelos.Artista;
import com.soltec.mmc.modelos.Usuario;
import javax.servlet.http.HttpServletRequest;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

/**
 *
 * @author danielvasquez
 */
@Controller
@Scope("session")
@SessionAttributes(value = "usuarioActual")
public class MiCuentaController {

    private ArtistaDAO artistaService = new ArtistaImplementation();
    private AdministradorDAO administradorService = new AdministradorImplementation();

    @RequestMapping(value = "mi_cuenta", method = RequestMethod.GET)
    public String showView(ModelMap model, HttpServletRequest request) {
        Usuario usr = (Usuario) request.getSession().getAttribute("usuarioActual");
        if (usr.getTipoCuenta().compareTo("Administrador") == 0) {
            Administrador admin = (Administrador) administradorService
                    .obtenerAdministradorPorIdCuenta(usr.getIdCuenta());
            request.getSession().setAttribute("cuentaInfo", admin);
        } else {
            Artista artista = (Artista) artistaService.obtenerArtistaPorIdCuenta(usr.getIdCuenta());
            request.getSession().setAttribute("cuentaInfo", artista);
        }
        return "mi_cuenta";
    }

}