public void Delete(int id) { ACLRole resource = _context.ACLRoles.Single(m => m.ID == id); _context.ACLRoles.Remove(resource); _context.SaveChanges(); }
public void UpdateACL(List <ACLUpdateRecord> model) { _session.Transact(session => { foreach (var aclUpdateRecord in model) { var role = _roleService.GetRoleByName(aclUpdateRecord.Role); var aclRole = role.ACLRoles.FirstOrDefault(ar => ar.Name == aclUpdateRecord.Key); if ((aclRole != null && aclUpdateRecord.Allowed) || (aclRole == null && !aclUpdateRecord.Allowed)) { continue; } if (aclRole != null && !aclUpdateRecord.Allowed) { role.ACLRoles.Remove(aclRole); session.Delete(aclRole); } else if (aclRole == null && aclUpdateRecord.Allowed) { var newRole = new ACLRole { UserRole = role, Name = aclUpdateRecord.Key }; role.ACLRoles.Add(newRole); session.Save(newRole); } } }); }
public IActionResult Post([FromBody] ACLRole value) { if (value == null) { return(BadRequest()); } _context.ACLRoles.Add(value); return(CreatedAtRoute("Get", new { controller = "ACLRoles", id = value.ID }, value)); }