コード例 #1
0
        public virtual async Task <ActionResult> EliminarRolView(string idRol, long idView)
        {
            if (this.DataService == null)
            {
                this.DataService = new CuentaDataService(this.GetIdentityUser(this.User.Identity.Name).Result, this.UserManager, this.RoleManager);
            }

            try
            {
                await this.DataService.EliminarRolView(idRol, idView, this.HttpContext);

                FaAuthorizeAttribute.RolActualizado(idRol);
                return(RedirectToAction(nameof(VerRol), new { id = idRol }));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
        public virtual async Task <ActionResult> EliminarRol(string borrarRolId)
        {
            if (this.DataService == null)
            {
                this.DataService = new CuentaDataService(this.GetIdentityUser(this.User.Identity.Name).Result, this.UserManager, this.RoleManager);
            }

            try
            {
                await this.DataService.Eliminar(borrarRolId);

                FaAuthorizeAttribute.RolActualizado(borrarRolId);
                return(RedirectToAction(nameof(ListaRoles)));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        public async Task <ActionResult> RegistrarRol(IdentityRole model)
        {
            if (ModelState.IsValid)
            {
                var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(this.DbContext));

                var result = await roleManager.CreateAsync(model);

                if (result.Succeeded)
                {
                    FaAuthorizeAttribute.RolActualizado(model.Id);
                    return(RedirectToAction(nameof(ListaRoles)));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
コード例 #4
0
        public async Task <ActionResult> RegistrarRolViewPermit(string idRol, string viewName, byte?todas)
        {
            if (this.DataService == null)
            {
                this.DataService = new CuentaDataService(this.GetIdentityUser(this.User.Identity.Name).Result, this.UserManager, this.RoleManager);
            }
            if (ModelState.IsValid)
            {
                try
                {
                    await this.DataService.CrearRolViewPermit(idRol, ViewUtil.ObtenerDireccionDeView(viewName), todas.GetValueOrDefault(0), this.HttpContext);

                    FaAuthorizeAttribute.RolActualizado(idRol);
                    return(RedirectToAction(nameof(VerRol), new { id = idRol }));
                }
                catch (Exception ex)
                {
                    this.ModelState.AddModelError("", ex);
                    return(RedirectToAction(nameof(ListaRoles)));
                }
            }
            // If we got this far, something failed, redisplay form
            return(RedirectToAction(nameof(RegistrarRolViewPermit)));
        }