Example #1
0
        public async Task <ActionResult> Update([FromBody] ChangedTemplate template)
        {
            var result = await _templateService.Update(template);

            SendBroadcast(result, "updated");
            return(Ok());
        }
Example #2
0
        public async Task <Template> Update(ChangedTemplate template)
        {
            var entity = await _store.Retrieve(template.Id);

            Mapper.Map <ChangedTemplate, Data.Template>(template, entity);

            await _store.Update(entity);

            return(Mapper.Map <Template>(entity));
        }
        private async Task _validate(ChangedTemplate model)
        {
            if (model.Name.IsEmpty())
            {
                throw new ArgumentException("ChangedTemplate.Name");
            }

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

            await Task.CompletedTask;
        }
Example #4
0
        public async Task <Template> Update(ChangedTemplate template)
        {
            var entity = await _templateStore.Load(template.Id);

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

            Mapper.Map <ChangedTemplate, Data.Template>(template, entity);

            await _templateStore.Update(entity);

            return(Mapper.Map <Template>(entity, WithActor()));
        }
Example #5
0
        public async Task <ActionResult> UpdateTemplate([FromBody] ChangedTemplate model)
        {
            await Validate(model);

            AuthorizeAny(
                () => Actor.IsAdmin,
                () => _svc.CanEdit(model.Id, Actor.Id).Result
                );

            var result = await _svc.Update(model);

            SendBroadcast(result, "updated");

            return(Ok());
        }