public async Task <ActionResult> Update([FromBody] ChangedWorkspace model)
        {
            Workspace workspace = await _workspaceService.Update(model);

            // Broadcast(topo.GlobalId, new BroadcastEvent<Topology>(User, "TOPO.UPDATED", topo));
            await _hub.Clients.Group(workspace.GlobalId).TopoEvent(new BroadcastEvent <Workspace>(User, "TOPO.UPDATED", workspace));

            return(Ok());
        }
Beispiel #2
0
        /// <summary>
        /// Update an existing workspace (privileged).
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <Workspace> Update(ChangedWorkspace model)
        {
            var entity = await _store.Retrieve(model.Id);

            Mapper.Map <ChangedWorkspace, Data.Workspace>(
                model,
                entity
                );

            await _store.Update(entity);

            return(Mapper.Map <Workspace>(entity));
        }
Beispiel #3
0
        private async Task _validate(ChangedWorkspace model)
        {
            if (model.Name.IsEmpty())
            {
                throw new ArgumentException("ChangedWorkspace.Name");
            }

            if ((await Exists(model.Id)).Equals(false))
            {
                throw new ResourceNotFound();
            }

            await Task.CompletedTask;
        }
Beispiel #4
0
        public async Task <ActionResult> PrivilegedUpdateWorkspace([FromBody] ChangedWorkspace model)
        {
            await Validate(model);

            AuthorizeAny(
                () => Actor.IsAdmin
                );

            Workspace workspace = await _svc.Update(model);

            await Hub.Clients
            .Group(workspace.Id)
            .TopoEvent(new BroadcastEvent <Workspace>(User, "TOPO.UPDATED", workspace))
            ;

            return(Ok());
        }
Beispiel #5
0
        /// <summary>
        /// Update an existing workspace.
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <Workspace> Update(ChangedWorkspace model)
        {
            var entity = await _workspaceStore.Load(model.Id);

            if (entity == null || !entity.CanEdit(User))
            {
                throw new InvalidOperationException();
            }

            if (model.TemplateLimit == 0 || !User.IsAdmin)
            {
                model.TemplateLimit = entity.TemplateLimit;
            }

            Mapper.Map <ChangedWorkspace, Data.Workspace>(model, entity, WithActor());

            await _workspaceStore.Update(entity);

            return(Mapper.Map <Workspace>(entity, WithActor()));
        }