Beispiel #1
0
        public async Task <IActionResult> Create(DisertanteViewModel vm)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    throw new Exception("Error de validacion no controlado.");
                }

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

                await _disertanteServicio.Insertar(dto);

                if (User.IsInRole("Admin"))
                {
                    return(RedirectToAction(nameof(Index), new { empresaId = vm.EmpresaId }));
                }
                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception)
            {
                return(View(vm));
            }
        }