Ejemplo n.º 1
0
        public IActionResult AgregarArticulo(Articulo articulo, bool permanecerView)
        {
            if (!ModelState.IsValid)
            {
                TempData["toastr_error"] = "No ha ingresado correctamente la información del nuevo artículo !";
                return(View());
            }

            try
            {
                _articulosService.Insertar(articulo);
                TempData["toastr_success"] = $"Se ha creado exitosamente el artículo {articulo.Descripcion} ({articulo.Codigo})";

                return((permanecerView) ? RedirectToAction("AgregarArticulo") : RedirectToAction("AdministrarArticulos"));
            }
            catch (ArticuloException e)
            {
                TempData["toastr_error"] = e.Message;
                return(View());
            }
        }