Exemplo n.º 1
0
        public async Task <IActionResult> Patch(string id, [FromBody] RequestDocument <WidgetResource> request)
        {
            try
            {
                var resource = request.Data;
                if (string.IsNullOrWhiteSpace(resource?.Id))
                {
                    return(BadRequest());
                }

                var widget = await _widgetRepository.Get(resource.Id);

                WidgetMap.ApplyUpdates(widget, resource);
                await _widgetRepository.Update(widget);

                var updatedResource = WidgetMap.ToResource(widget);
                await _bus.Publish(new WidgetEvent("WidgetUpdated", updatedResource, GetRequestor()), "WidgetEvents");

                return(Ok(updatedResource));
            }
            catch (WidgetNotFoundException)
            {
                return(NotFound());
            }
        }
Exemplo n.º 2
0
 public IHttpActionResult Get()
 {
     return(Ok(WidgetRepo.Get(User.IsInRole("iVision"), User.IsInRole("Microsoft")).ToList()));
 }
Exemplo n.º 3
0
 public IHttpActionResult Get()
 {
     return(Ok(widgetRepo.Get(User.IsInRole("Praemium"), User.IsInRole("Microsoft"))));
 }