public void RemovePermissionFromRole(Guid roleID, Guid permissionID)
        {
            var role = FindById(roleID, false, true);
            var id   = role.RolePermissions.FirstOrDefault(p => p.PermissionID == permissionID).RolePermissionID;

            _rolePermissionService.Delete(id);
        }
Beispiel #2
0
        public IHttpActionResult DeleteEntity(int id)
        {
            var rolePermission = _rolePermissionService.GetById(id);

            if (null == rolePermission)
            {
                return(NotFound());
            }
            rolePermission = _rolePermissionService.Delete(id);
            return(Ok(rolePermission));
        }
Beispiel #3
0
        public CommonApiResponse <string> Delete(Guid rolePermissionId)
        {
            jwt = ViewBag.Jwt;
            bool result = _rolePermissionService.Delete(jwt.UserId, rolePermissionId);

            if (result)
            {
                return(CommonApiResponse <string> .Create(Response, System.Net.HttpStatusCode.OK, true, "İşlem başarılı", null));
            }

            return(CommonApiResponse <string> .Create(Response, System.Net.HttpStatusCode.OK, false, null, FluentValidationHelper.GenerateErrorList("An error occurred.")));
        }
Beispiel #4
0
        public ActionResult Edit(RoleEditViewModel model)
        {
            try
            {
                Role role = _roleService.FindBy(x => x.Id == model.Id).First();
                //role.Name = model.Name;
                //role.Code = model.Code;
                //_roleService.Update(role);

                IList <Permission>          permissions    = role.Permissions;
                IList <PermissionViewModel> permisosNuevos = model.Permissions.Where(x => x.Assigned == true).ToList();
                var query  = permisosNuevos.Where(p => !permissions.Any(l => p.Id == l.Id)); //permisosNuevos.Where(x => permissions.Contains(x.Id));
                var query2 = permissions.Where(p => !permisosNuevos.Any(l => p.Id == l.Id));
                foreach (PermissionViewModel permisoNuevo in query)
                {
                    RolePermission rolePermission = new RolePermission();
                    rolePermission.Role = new Role {
                        Id = role.Id
                    };
                    rolePermission.Permission = new Permission {
                        Id = permisoNuevo.Id
                    };
                    _rolePermissionService.Create(rolePermission);
                }
                foreach (Permission permisoQuitado in query2)
                {
                    RolePermission rolePermission = _rolePermissionService.FindBy(x => x.Role.Id == role.Id && x.Permission.Id == permisoQuitado.Id).FirstOrDefault();
                    _rolePermissionService.Delete(rolePermission.Id);
                }
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
 public Task <IResultModel> Delete([BindRequired] string id)
 {
     return(_service.Delete(id));
 }