예제 #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> ListaRoles()
        {
            var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(this.DbContext));

            bool cuentasAuth = FaAuthorizeAttribute.IsAuthorized(this.User, nameof(CuentaController), nameof(ListaRoles), this.HttpContext);

            if (!cuentasAuth && FaAuthorizeAttribute.IsAuthorized(this.User, nameof(CuentaController), nameof(ListaCuentas), this.HttpContext))
            {
                return(RedirectToAction(nameof(ListaCuentas)));
            }

            if (cuentasAuth)
            {
                return(this.View(roleManager.Roles.ToList()));
            }
            else
            {
                return(new HttpStatusCodeResult(401));
            }
        }
예제 #5
0
        public async Task <ActionResult> ListaCuentas()
        {
            if (this.DataService == null)
            {
                this.DataService = new CuentaDataService(this.GetIdentityUser(this.User.Identity.Name).Result, this.UserManager, this.RoleManager);
            }
            bool cuentasAuth = FaAuthorizeAttribute.IsAuthorized(this.User, nameof(CuentaController), nameof(ListaCuentas), this.HttpContext);

            if (!cuentasAuth && FaAuthorizeAttribute.IsAuthorized(this.User, nameof(CuentaController), nameof(ListaRoles), this.HttpContext))
            {
                return(RedirectToAction(nameof(ListaRoles)));
            }

            if (cuentasAuth)
            {
                return(this.View(await this.DataService.GetCuentas()));
            }
            else
            {
                return(new HttpStatusCodeResult(401));
            }
        }
예제 #6
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)));
        }