public object Patch(string id, [FromBody] dynamic model) { // Set settings Site site = SiteHelper.UpdateSite(new SiteId(id).Id, model, _fileProvider); if (site == null) { return(NotFound()); } // Start/Stop if (model.status != null) { Status status = DynamicHelper.To <Status>(model.status); try { switch (status) { case Status.Stopped: site.Stop(); break; case Status.Started: site.Start(); break; } } catch (COMException e) { // If site is fresh and status is still unknown then COMException will be thrown when manipulating status throw new ApiException("Error setting site status", e); } catch (ServerManagerException e) { throw new ApiException(e.Message, e); } } // Update changes ManagementUnit.Current.Commit(); // Refresh data site = ManagementUnit.ServerManager.Sites[site.Name]; // // Create response dynamic sModel = SiteHelper.ToJsonModel(site, Context.Request.GetFields()); // The Id could change by changing the sites key if (sModel.id != id) { return(LocationChanged(SiteHelper.GetLocation(sModel.id), sModel)); } return(sModel); }