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

            SendBroadcast(result, "updated");
            return(Ok());
        }
예제 #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));
        }
예제 #3
0
        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;
        }
예제 #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()));
        }
예제 #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());
        }