public Relationshipuserpermission AddRelationshipuserpermission(Relationshipuserpermission relationshipuserpermission)
        {
            if (relationshipuserpermission.UserId == null)
            {
                throw new Exception("User ID la bat buoc");
            }
            if (relationshipuserpermission.PermissionId == null)
            {
                throw new Exception("Permission ID la bat buoc");
            }

            _context.Relationshipuserpermissions.Add(relationshipuserpermission);
            _context.SaveChanges();
            return(relationshipuserpermission);
        }
        public Relationshipuserpermission UpdateRelationshipuserpermission(Relationshipuserpermission relationshipuserpermissionToUpdate)
        {
            var relationshipuserpermission = _context.Relationshipuserpermissions.FirstOrDefault(x => x.Id == relationshipuserpermissionToUpdate.Id);

            if (relationshipuserpermission == null)
            {
                throw new Exception("Khong ton tai");
            }
            if (_context.Relationshipuserpermissions.Any(x => x.PermissionId == relationshipuserpermissionToUpdate.Id))
            {
                throw new Exception("Permission da co san!");
            }
            relationshipuserpermission.UserId       = relationshipuserpermissionToUpdate.UserId;
            relationshipuserpermission.PermissionId = relationshipuserpermissionToUpdate.PermissionId;
            relationshipuserpermission.Suspended    = relationshipuserpermissionToUpdate.Suspended;
            _context.Update(relationshipuserpermission);
            _context.SaveChanges();
            return(relationshipuserpermission);
        }