public void Delete(string id) { // Cut off the notion of uuid from beginning of request VDirId vdirId = new VDirId(id); Site site = SiteHelper.GetSite(vdirId.SiteId); // Get the parent application using data encoded in uuid Application app = ApplicationHelper.GetApplication(vdirId.AppPath, site); // Get the target vdir from the id data VirtualDirectory vdir = VDirHelper.GetVDir(vdirId.Path, app); if (vdir != null) { // Delete VDirHelper.DeleteVirtualDirectory(vdir, app); // Save ManagementUnit.Current.Commit(); } // Success Context.Response.StatusCode = (int)HttpStatusCode.NoContent; }
public object Get(string id) { // Cut off the notion of uuid from beginning of request VDirId vdirId = new VDirId(id); Site site = SiteHelper.GetSite(vdirId.SiteId); // Get the parent application using data encoded in uuid Application app = ApplicationHelper.GetApplication(vdirId.AppPath, site); // Get the target vdir from the id data VirtualDirectory vdir = VDirHelper.GetVDir(vdirId.Path, app); if (vdir == null) { return(NotFound()); } return(VDirHelper.ToJsonModel(vdir, app, site, Context.Request.GetFields())); }
public object Patch(string id, [FromBody] dynamic model) { // Cut off the notion of uuid from beginning of request VDirId vdirId = new VDirId(id); Site site = SiteHelper.GetSite(vdirId.SiteId); // Get the parent application using data encoded in uuid Application app = ApplicationHelper.GetApplication(vdirId.AppPath, site); // Get the target vdir from the id data VirtualDirectory vdir = VDirHelper.GetVDir(vdirId.Path, app); if (vdir == null) { return(NotFound()); } // Make changes VDirHelper.UpdateVirtualDirectory(vdir, model, _fileProvider); // Save ManagementUnit.Current.Commit(); // // Create response dynamic virtualDir = VDirHelper.ToJsonModel(vdir, app, site, Context.Request.GetFields()); // Id can change if path is different if (virtualDir.id != id) { return(LocationChanged(VDirHelper.GetLocation(virtualDir.id), virtualDir)); } return(virtualDir); }