81 lines
No EOL
2.8 KiB
C#
81 lines
No EOL
2.8 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using PruebaAzureAD.Models;
|
|
using PruebaAzureAD.Servicios;
|
|
using System.Diagnostics;
|
|
|
|
namespace PruebaAzureAD.Controllers
|
|
{
|
|
[Authorize]
|
|
public class HomeController : Controller
|
|
{
|
|
private readonly ILogger<HomeController> _logger;
|
|
|
|
readonly Persona persona = new Persona();
|
|
readonly Estado estado = new Estado();
|
|
readonly TipoIdentificacion tipoIdentificacion = new TipoIdentificacion();
|
|
readonly Pais pais = new Pais();
|
|
readonly EstadoCivil estadoCivil = new EstadoCivil();
|
|
readonly Universidad universidad = new Universidad();
|
|
readonly GradoAcademico gradoAcademico = new GradoAcademico();
|
|
readonly Empresa empresa = new Empresa();
|
|
readonly Puesto puesto = new Puesto();
|
|
readonly TipoNombramiento tipoNombramiento = new TipoNombramiento();
|
|
|
|
public HomeController(ILogger<HomeController> logger)
|
|
{
|
|
_logger = logger;
|
|
}
|
|
|
|
public async Task<IActionResult> Index()
|
|
{
|
|
var data = await persona.ObtenerPersonas();
|
|
return View(data);
|
|
}
|
|
|
|
public async Task<IActionResult> Agregar()
|
|
{
|
|
ViewBag.Estados = await estado.ObtenerEstados();
|
|
ViewBag.Tipos = await tipoIdentificacion.ObtenerTipoIdentificaciones();
|
|
ViewBag.Paises = await pais.ObtenerPaises();
|
|
ViewBag.EstadosCiviles = await estadoCivil.ObtenerEstadosCiviles();
|
|
//ViewBag.Provincias = await persona.ObtenerProvincias();
|
|
//ViewBag.Cantones = await persona.ObtenerCantones();
|
|
//ViewBag.Distritos = await persona.ObtenerDistritos();
|
|
ViewBag.Universidades = await universidad.ObtenerUniversidades();
|
|
ViewBag.GradosAcademicos = await gradoAcademico.ObtenerGradosAcademicos();
|
|
ViewBag.Empresas = await empresa.ObtenerEmpresas();
|
|
ViewBag.Puestos = await puesto.ObtenerPuestos();
|
|
ViewBag.TipoNombramiento = await tipoNombramiento.ObtenerNombramientos();
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<IActionResult> Agregar(PersonaViewModel funcionario)
|
|
{
|
|
try
|
|
{
|
|
await persona.AgregarPersona(funcionario);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
throw;
|
|
}
|
|
|
|
return RedirectToAction(nameof(Index));
|
|
}
|
|
|
|
public IActionResult Privacy()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[AllowAnonymous]
|
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
|
public IActionResult Error()
|
|
{
|
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
|
}
|
|
}
|
|
} |