Ejemplo n.º 1
0
        public async Task <ActionResult <Vm> > ChangeVm([FromBody] VmOperation op)
        {
            await Validate(op);

            AuthorizeAny(
                () => Actor.IsAdmin,
                () => CanManageVm(op.Id, Actor.Id).Result
                );

            Vm vm = await _pod.ChangeState(op);

            SendBroadcast(vm, op.Type.ToString().ToLower());

            return(Ok(vm));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <Vm> > ChangeVm([FromBody] VmOperation op)
        {
            string opType = op.Type.ToString().ToLower();

            await AuthorizeAction(op.Id, opType);

            if (
                op.Type == VmOperationType.Save &&
                op.WorkspaceId > 0 &&
                await _workspaceService.HasGames(op.WorkspaceId)
                )
            {
                throw new WorkspaceNotIsolatedException();
            }

            Vm vm = await _pod.ChangeState(op);

            SendBroadcast(vm, opType);

            return(Ok(vm));
        }