public IActionResult Add() { var viewModel = new AddActaEUViewModel(); var categorias = _categorias.GetAllWithSubCategorias(); viewModel.CarrerasExistentes = _carreras.GetAll().Select(x => new DropDownViewModel <int>() { Text = $"{x.Abreviatura} - {x.Nombre}", Value = x.Id }).ToList(); foreach (var categoria in categorias) { var categoriaTemp = AutoMapper.Mapper.Map <AddActaEUCategoriaViewModel>(categoria); foreach (var subCategoria in categoria.SubCategorias.Where(x => x.Active)) { var detalle = AutoMapper.Mapper.Map <AddActaEUDetalleViewModel>(subCategoria); categoriaTemp.Detalle.Add(detalle); } //si la categoria no tiene subcategorias se le agrega esa categoria como subcategoria para mostrar en la vista if (categoria.SubCategorias.Count == 0) { var subCat = new AddActaEUDetalleViewModel() { Nombre = categoria.Nombre, Caracter = categoria.Caracter, }; categoriaTemp.Detalle.Add(subCat); } viewModel.Categorias.Add(categoriaTemp); } return(View(viewModel)); }
public IActionResult Mensual() { var viewModel = new ReporteIndexViewModel(); //viewModel = _reportes.GetReporteMensual(12, 2018, 1); viewModel.CarrerasExistentes = _carreras.GetAll().Select(x => new DropDownViewModel <int>() { Text = $"{x.Abreviatura} - {x.Nombre}", Value = x.Id }).ToList(); for (var i = 1; i <= 12; i++) { viewModel.MesesExistentes.Add(new DropDownViewModel <int>() { Text = CultureInfo.CreateSpecificCulture("es").DateTimeFormat.GetMonthName(i), Value = i }); } for (var i = DateTime.Now.AddYears(-10).Year; i <= DateTime.Now.Year; i++) { viewModel.AnhosExistentes.Add(new DropDownViewModel <int>() { Text = i.ToString(), Value = i }); } return(View(viewModel)); }
public IActionResult Index() { var viewModel = new IndexCarrerasViewModel() { Carreras = Mapper.Map <List <CarreraViewModel> >(_carreras.GetAll()) }; return(View(viewModel)); }
public IActionResult Upsert(int?id) { var viewModel = new UpsertEstudianteViewModel(); if (id != null) { viewModel = Mapper.Map <UpsertEstudianteViewModel>(_estudiantes.GetById(id.Value)); } viewModel.CarrerasExistentes = _carreras.GetAll().Select(x => new DropDownViewModel <int>() { Text = $"{x.Abreviatura} - {x.Nombre}", Value = x.Id }).ToList(); viewModel.SexoExistentes = Enum.GetValues(typeof(Sexo)).Cast <Sexo>().Select(x => new DropDownViewModel <int> { Text = x.ToString(), Value = (int)x }).ToList(); return(View(viewModel)); }