public async Task <ActionResult> Update([FromBody] ChangedTemplate template) { var result = await _templateService.Update(template); SendBroadcast(result, "updated"); return(Ok()); }
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; }
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())); }
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()); }