Пример #1
0
        public async Task <IActionResult> Details(long id)
        {
            try
            {
                ViewBag.EmpresaId = null;

                var disertante = (DisertanteDto)await _disertanteServicio.Obtener(id);

                var empresa = await _helperEmpresa.ObtenerEmpresa(disertante.EmpresaId);

                if (User.IsInRole("Admin"))
                {
                    ViewBag.EmpresaId = disertante.EmpresaId;
                }

                var model = new DisertanteViewModel()
                {
                    Id            = disertante.Id,
                    Apellido      = disertante.Apellido,
                    Nombre        = disertante.Nombre,
                    Dni           = disertante.Dni,
                    Empresa       = empresa,
                    EmpresaId     = disertante.EmpresaId,
                    EstaEliminado = disertante.EliminadoStr
                };

                return(View(model));
            }
            catch (Exception)
            {
                return(RedirectToAction(nameof(Index)));
            }
        }
Пример #2
0
        public async Task <IActionResult> Edit(DisertanteViewModel vm)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    throw new Exception("Error de validacion no controlado.");
                }

                var dto = new DisertanteDto()
                {
                    Id        = vm.Id,
                    Apellido  = vm.Apellido,
                    Dni       = vm.Dni,
                    EmpresaId = vm.EmpresaId,
                    Nombre    = vm.Nombre,
                };

                await _disertanteServicio.Modificar(dto);

                if (User.IsInRole("Admin"))
                {
                    return(RedirectToAction(nameof(Index), new { empresaId = vm.EmpresaId }));
                }
                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception)
            {
                return(View(vm));
            }
        }
Пример #3
0
        public async Task <IActionResult> Create(long?empresaId = null)
        {
            EmpresaViewModel empresa = null;

            ViewBag.EmpresaId = null;

            if (empresaId.HasValue) // si tiene empresaId es que estoy entrando como administrador
            {
                empresa = await _helperEmpresa.ObtenerEmpresa(empresaId.Value);

                ViewBag.EmpresaId = empresaId.Value;
                if (empresa == null)
                {
                    return(RedirectToAction("Index", "Empresa"));
                }
            }
            else // sino la empresaId la extrae desde el usuario logueado
            {
                empresa = await _helperEmpresa.ObtenerEmpresaActual(User.Identity.Name);
            }

            var model = new DisertanteViewModel()
            {
                EmpresaId = empresa.Id
            };

            return(View(model));
        }
        public async Task <DisertanteViewModel> ObtenerDisertante(long id)
        {
            var dto = (DisertanteDto)await _disertanteServicio.Obtener(id);

            var model = new DisertanteViewModel()
            {
                Id            = dto.Id,
                EstaEliminado = dto.EliminadoStr,
                Nombre        = dto.Nombre,
                Apellido      = dto.Apellido,
                Dni           = dto.Dni,
                EmpresaId     = dto.EmpresaId
            };

            return(model);
        }
Пример #5
0
        public async Task <IActionResult> Edit(long id)
        {
            var dto = (DisertanteDto)await _disertanteServicio.Obtener(id);

            var model = new DisertanteViewModel()
            {
                Id        = dto.Id,
                Apellido  = dto.Apellido,
                Nombre    = dto.Nombre,
                Dni       = dto.Dni,
                EmpresaId = dto.EmpresaId
            };

            ViewBag.EmpresaId = null;
            if (User.IsInRole("Admin"))
            {
                ViewBag.EmpresaId = dto.EmpresaId;
            }

            return(View(model));
        }