Пример #1
0
        public object Get()
        {
            string docUuid = Context.Request.Query[Defines.IDENTIFIER];

            if (string.IsNullOrEmpty(docUuid))
            {
                return(new StatusCodeResult((int)HttpStatusCode.NotFound));
            }

            DefaultDocumentId docId = new DefaultDocumentId(docUuid);

            // Get site and application file is for if applicable
            Site site = docId.SiteId == null ? null : SiteHelper.GetSite(docId.SiteId.Value);

            List <File> files = FilesHelper.GetFiles(site, docId.Path);

            return(new {
                files = files.Select(f => FilesHelper.ToJsonModelRef(f, site, docId.Path))
            });
        }
Пример #2
0
        public void Delete(string id)
        {
            var fileId = new FileId(id);

            Site site = fileId.SiteId == null ? null : SiteHelper.GetSite(fileId.SiteId.Value);

            if (fileId.SiteId != null && site == null)
            {
                Context.Response.StatusCode = (int)HttpStatusCode.NoContent;
                return;
            }

            File file = FilesHelper.GetFiles(site, fileId.Path).Where(f => f.Name.Equals(fileId.Name)).FirstOrDefault();

            if (file != null)
            {
                var section = DefaultDocumentHelper.GetDefaultDocumentSection(site, fileId.Path, ManagementUnit.ResolveConfigScope());

                FilesHelper.DeleteFile(file, section);
                ManagementUnit.Current.Commit();
            }

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