public ActionResult Editar_Rol(AddRolesViewModel model)
        {
            ViewData["Nombre"]   = AccesoController.nombre;
            ViewData["Apellido"] = AccesoController.apellido;
            try
            {
                if (ModelState.IsValid)
                {
                    using (SII_Entities db = new SII_Entities())
                    {
                        var obj_Rol = db.Tbl_Rol.Find(model.id_R);
                        obj_Rol.tipo_Rol        = model.rol;
                        db.Entry(obj_Rol).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();

                        TempData["msg"] = "Modificado";
                        ViewBag.Msg     = TempData["msg"];
                    }
                    return(Redirect("/Rol/Mant_Rol"));
                }
                return(View(model));
            }
            catch (Exception)
            {
                return(Redirect("/Error/InaccessiblePage"));
            }
        }
        public ActionResult Nuevo_Rol(AddRolesViewModel model)
        {
            ViewData["Nombre"]   = AccesoController.nombre;
            ViewData["Apellido"] = AccesoController.apellido;
            try
            {
                if (ModelState.IsValid)
                {
                    using (SII_Entities db = new SII_Entities())
                    {
                        var obj_Rol = new Tbl_Rol();
                        obj_Rol.tipo_Rol = model.rol;
                        obj_Rol.estado   = 1;
                        db.Tbl_Rol.Add(obj_Rol);
                        db.SaveChanges();

                        TempData["msg"] = "Agregado";
                        ViewBag.Msg     = TempData["msg"];
                    }
                    return(Redirect("/Rol/Mant_Rol"));
                }
                return(View(model));
            }
            catch (Exception)
            {
                return(Redirect("/Error/InaccessiblePage"));
            }
        }
Exemple #3
0
        public async Task <ActionResult> Add(AddRolesViewModel roles)
        {
            if (ModelState.IsValid)
            {
                // 验证合法,
                int rs = await _rolesBll.AddRolesAsync(roles.Title);

                if (rs > 0)
                {
                    Response.Write("<script>alert('新增成功');location.href='../../Manager/RolesManager/List'</script>");
                }
            }
            return(View(roles));
        }
Exemple #4
0
        public async Task <ActionResult> AddRoles(AddRolesViewModel addRolesViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.Values.SelectMany(e => e.Errors)));
            }

            var result = await _mediator.Send(AddRolesCommand.Create(addRolesViewModel.Cpf, addRolesViewModel.Roles));

            if (result.Succeeded)
            {
                return(Ok(result));
            }

            return(BadRequest(result));
        }
        public ActionResult Editar_Rol(int?ID)
        {
            try
            {
                ViewData["Nombre"]   = AccesoController.nombre;
                ViewData["Apellido"] = AccesoController.apellido;

                AddRolesViewModel model = new AddRolesViewModel();
                using (SII_Entities db = new SII_Entities())
                {
                    var obj_Rol = db.Tbl_Rol.Find(ID);
                    model.rol  = obj_Rol.tipo_Rol;
                    model.id_R = obj_Rol.id_Rol;
                }
                return(View(model));
            }
            catch (Exception)
            {
                return(Redirect("/Error/InaccessiblePage"));
            }
        }