public ActionResult Edit(HiveId?id) { if (id.IsNullValueOrEmpty()) { return(HttpNotFound()); } using (var uow = _hive.Create()) { var def = PackageBuilderHelper.GetPackageDefinitionById(uow, id.Value); if (def == null) { return(HttpNotFound()); } var pkg = PackageBuilderHelper.GetPackageFileById(uow, id.Value); var model = BackOfficeRequestContext.Application.FrameworkContext.TypeMappers .Map <PackageDefinition, PackageDefinitionEditorModel>(def); model.Id = id.Value; model.IsPublished = pkg != null; PopulateCollections(model); return(View(model)); } }
public ActionResult Download(HiveId?id) { if (id.IsNullValueOrEmpty()) { return(HttpNotFound()); } using (var uow = _hive.Create()) { var def = PackageBuilderHelper.GetPackageDefinitionById(uow, id.Value); if (def == null) { return(HttpNotFound()); } var pkg = PackageBuilderHelper.GetPackageFileById(uow, id.Value); if (pkg == null) { return(HttpNotFound()); } return(File(pkg.ContentBytes, "application/zip", def.Alias + "." + def.Version + ".nupkg")); } }
protected override RebelTreeResult GetTreeData(HiveId parentId, FormCollection queryStrings) { if (parentId == RootNodeId) { foreach (var node in PackageTreeNodes .Select(x => CreateTreeNode( x.Item1, queryStrings, x.Item2, !string.IsNullOrWhiteSpace(x.Item3) ? Url.GetEditorUrl(x.Item3, null, EditorControllerId, BackOfficeRequestContext.RegisteredComponents, BackOfficeRequestContext.Application.Settings) : Url.GetCurrentDashboardUrl(), x.Item3, false, "tree-repository"))) { if ((int)node.HiveId.Value.Value == 3) { node.AddEditorMenuItem <CreateItem>(this, "createUrl", "Create"); node.AddMenuItem <Reload>(); node.HasChildren = true; } NodeCollection.Add(node); } } else { if ((int)parentId.Value.Value == 3) { using (var uow = BackOfficeRequestContext.Application.Hive.OpenReader <IFileStore>(new Uri("storage://created-packages"))) { var root = uow.Repositories.Get <File>(new HiveId("/")); var defs = uow.Repositories.GetChildRelations(root, FixedRelationTypes.DefaultRelationType) .Select(x => PackageBuilderHelper.GetPackageDefinitionById(uow, x.DestinationId)) .Where(x => x != null) .ToList(); foreach (var def in defs) { var n = CreateTreeNode( def.Id, queryStrings, def.Name, Url.GetEditorUrl("Edit", def.Id, EditorControllerId, BackOfficeRequestContext.RegisteredComponents, BackOfficeRequestContext.Application.Settings), "Edit", false, "tree-package"); n.AddEditorMenuItem <Delete>(this, "deleteUrl", "Delete"); NodeCollection.Add(n); } } } else { throw new NotImplementedException("The Packaging tree does not support more than 1 level"); } } return(RebelTree()); }