public async Task <IActionResult> Index(string cadenaBuscar = "", bool mostrarTodos = false) { if (cadenaBuscar == null) { cadenaBuscar = ""; } IEnumerable <TipoEntradaDto> dtos; if (User.IsInRole("Empresa")) { var empresa = await _helperEmpresa.ObtenerEmpresaActual(User.Identity.Name); ViewBag.EmpresaId = empresa.Id; dtos = (IEnumerable <TipoEntradaDto>) await _tipoEntradaServicio.ObtenerPorEmpresa(empresa.Id, cadenaBuscar, mostrarTodos); } else { ViewBag.EmpresaId = null; dtos = (IEnumerable <TipoEntradaDto>) await _tipoEntradaServicio.Obtener(cadenaBuscar, mostrarTodos); } var models = dtos.Select(b => new TipoEntradaViewModel() { Id = b.Id, EstaEliminado = b.EliminadoStr, Nombre = b.Nombre, EmpresaId = b.EmpresaId, BeneficioEntradaId = b.BeneficioEntradaId }).ToList(); foreach (var model in models) { model.BeneficioEntradaNombre = await _helperBeneficioEntrada.ObtenerNombreBeneficioEntrada(model.BeneficioEntradaId); } ViewBag.MostrarTodos = mostrarTodos; ViewBag.CadenaBuscar = cadenaBuscar; return(View(models)); }
public async Task <TipoEntradaViewModel> Obtener(long tipoEntradaId) { var tipoEntrada = (TipoEntradaDto)await _tipoEntradaServicio.Obtener(tipoEntradaId); var model = new TipoEntradaViewModel() { Id = tipoEntrada.Id, BeneficioEntradaId = tipoEntrada.BeneficioEntradaId, BeneficioEntradaNombre = await _helperBeneficioEntrada.ObtenerNombreBeneficioEntrada(tipoEntrada.BeneficioEntradaId), Nombre = tipoEntrada.Nombre, EstaEliminado = tipoEntrada.EliminadoStr }; return(model); }