public ActionResult Get(string path) { if (string.IsNullOrWhiteSpace(path) || path == "/") { throw new Exception("A document path must be provided to retrieve documents."); } var document = documents.GetByPath(path); return(Json(new { data = new { id = document.ID, name = document.Name, active = document.Active, path = document.Path, tags = document.Tags, hasFile = document.HasFile }, tags = document.Tags.Select(a => new { name = a, links = new { self = PathToController("tags", a) } }), activeWorkflows = document.ActiveWorkflows.OrderBy(a => a.Order).Select(a => new { name = a.WorkflowName, status = a.Status, order = a.Order, instanceId = a.InstanceId, bookmark = a.Bookmark, settings = a.Settings.Select(b => new { key = b.Key, value = b.Value }), links = a.Status == "InProgress" ? new Dictionary <string, object> { // Only show these items when the status indicates it is expecting a response { "respondApprove", PathToController("workflowreply", a.InstanceId, a.Bookmark, "true") }, { "respondReject", PathToController("workflowreply", a.InstanceId, a.Bookmark, "false") } } : new Dictionary <string, object>() }), links = new { self = PathTo(document.Path), fileDownload = document.HasFile ? PathToController("documentfiles", document.Path) : (string)null } })); }
public ActionResult Get(string path) { if (string.IsNullOrWhiteSpace(path) || path == "/") throw new Exception("A document path must be provided to retrieve a file."); var file = documentFiles.Get(path); if (file == null) throw new Exception("File not found: " + path); var document = documents.GetByPath(path); if (document == null) throw new Exception("Document not found." + path); return File(file.Data, file.MimeType, document.Name); }