protected override DriverResult Editor(PackageVersionPart part, IUpdateModel updater, dynamic shapeHelper) { var model = new EditPackageVersionViewModel { }; updater.TryUpdateModel(model, Prefix, new string[] { "PackageId" }, null); // Ensure the use owns the package for this package version var packagesForUser = GetPackagePartsForUser(); if (!packagesForUser.Any(x => x.Id == model.PackageId)) { updater.AddModelError("", T("You are not allowed to add a version to this package.")); } model.PackageVersionPart = part; model.PackageVersionPart.CommonPart.Container = _orchardServices.ContentManager.Get(model.PackageId); var exclude = _orchardServices.Authorizer.Authorize(Permissions.ManageGallery) ? null : new string[] { "PackageVersionPart.DownloadCount" } ; updater.TryUpdateModel(model, Prefix, null, exclude); Version version; if (!Version.TryParse(model.PackageVersionPart.Version, out version)) { updater.AddModelError("PackageVersionPart.Version", T("Invalid version.")); } return(Editor(part, shapeHelper)); }
protected override DriverResult Editor(PackageVersionPart part, dynamic shapeHelper) { return(ContentShape("Parts_PackageVersion_Fields_Edit", () => { var model = new EditPackageVersionViewModel { PackageParts = GetPackagePartsForUser(), PackageVersionPart = part, PackageId = part.CommonPart.Container != null ? part.CommonPart.Container.Id : -1 }; if (!model.PackageParts.Any()) { _orchardServices.Notifier.Error(T("You need to create a Package first.")); } return shapeHelper.EditorTemplate(TemplateName: "Parts/PackageVersion.Fields", Model: model, Prefix: Prefix); })); }