public async Task <object> Patch(string id, [FromBody] dynamic model)
        {
            // Cut off the notion of uuid from beginning of request
            string name = AppPoolId.CreateFromUuid(id).Name;

            // Set settings
            ApplicationPool appPool = AppPoolHelper.UpdateAppPool(name, model);

            if (appPool == null)
            {
                return(NotFound());
            }

            if (model.identity != null && !await IsAppPoolIdentityAllowed(appPool))
            {
                return(new ForbidResult());
            }

            // Start/Stop
            if (model.status != null)
            {
                Status status = DynamicHelper.To <Status>(model.status);
                try {
                    switch (status)
                    {
                    case Status.Stopped:
                        appPool.Stop();
                        break;

                    case Status.Started:
                        appPool.Start();
                        break;
                    }
                }
                catch (COMException e) {
                    // If pool is fresh and status is still unknown then COMException will be thrown when manipulating status
                    throw new ApiException("Error setting application pool status", e);
                }
            }

            // Update changes
            ManagementUnit.Current.Commit();

            // Refresh data
            appPool = ManagementUnit.ServerManager.ApplicationPools[appPool.Name];

            //
            // Create response
            dynamic pool = AppPoolHelper.ToJsonModel(appPool, Context.Request.GetFields());

            // The Id could change by changing apppool name
            if (pool.id != id)
            {
                return(LocationChanged(AppPoolHelper.GetLocation(pool.id), pool));
            }

            return(pool);
        }
        public object Get(string id)
        {
            // Extract the name of the target app pool from the uuid specified in the request
            string name = AppPoolId.CreateFromUuid(id).Name;

            ApplicationPool pool = AppPoolHelper.GetAppPool(name);

            if (pool == null)
            {
                return(NotFound());
            }

            return(AppPoolHelper.ToJsonModel(pool, Context.Request.GetFields()));
        }
        public void Delete(string id)
        {
            string name = AppPoolId.CreateFromUuid(id).Name;

            ApplicationPool pool = AppPoolHelper.GetAppPool(name);

            if (pool != null)
            {
                AppPoolHelper.DeleteAppPool(pool);
                ManagementUnit.Current.Commit();
            }

            // Sucess
            Context.Response.StatusCode = (int)HttpStatusCode.NoContent;
        }