示例#1
0
 public DeletePackageViewModel Setup(
     DeletePackageViewModel viewModel,
     Package package,
     User currentUser,
     IReadOnlyList <ReportPackageReason> reasons)
 {
     _displayPackageViewModelFactory.Setup(viewModel, package, currentUser, deprecation: null, readMeHtml: null);
     return(SetupInternal(viewModel, package, reasons));
 }
示例#2
0
        public DeletePackageViewModel Create(
            Package package,
            User currentUser,
            IReadOnlyList <ReportPackageReason> reasons)
        {
            var viewModel = new DeletePackageViewModel();

            return(Setup(viewModel, package, currentUser, reasons));
        }
示例#3
0
        public DeletePackageViewModel Create(
            Package package,
            IReadOnlyCollection <Package> allVersions,
            User currentUser,
            IReadOnlyList <ReportPackageReason> reasons)
        {
            var viewModel = new DeletePackageViewModel();

            return(Setup(viewModel, package, allVersions, currentUser, reasons));
        }
示例#4
0
        public virtual ActionResult Delete(string id, string version)
        {
            var package = _packageService.FindPackageByIdAndVersion(id, version);

            if (package == null)
            {
                return(HttpNotFound());
            }
            if (!package.IsOwner(User))
            {
                return(new HttpStatusCodeResult(401, "Unauthorized"));
            }

            var model = new DeletePackageViewModel(package, ReportMyPackageReasons);

            return(View(model));
        }
        public DeletePackageViewModel Setup(
            DeletePackageViewModel viewModel,
            Package package,
            IReadOnlyCollection <Package> allVersions,
            User currentUser,
            IReadOnlyList <ReportPackageReason> reasons)
        {
            _displayPackageViewModelFactory.Setup(
                viewModel,
                package,
                allVersions,
                currentUser,
                packageKeyToDeprecation: null,
                readmeResult: null);

            return(SetupInternal(viewModel, package, reasons));
        }
示例#6
0
        private DeletePackageViewModel SetupInternal(
            DeletePackageViewModel viewModel,
            Package package,
            IReadOnlyList <ReportPackageReason> reasons)
        {
            viewModel.DeletePackagesRequest = new DeletePackagesRequest
            {
                Packages = new List <string>
                {
                    string.Format(
                        CultureInfo.InvariantCulture,
                        "{0}|{1}",
                        package.PackageRegistration.Id,
                        package.Version)
                },
                ReasonChoices = reasons
            };

            viewModel.IsLocked = package.PackageRegistration.IsLocked;

            return(viewModel);
        }
        public virtual ActionResult Delete(string id, string version)
        {
            var package = _packageService.FindPackageByIdAndVersion(id, version);
            if (package == null)
            {
                return HttpNotFound();
            }
            if (!package.IsOwner(User))
            {
                return new HttpStatusCodeResult(401, "Unauthorized");
            }

            var model = new DeletePackageViewModel(package, ReportMyPackageReasons);
            return View(model);
        }
示例#8
0
        public virtual ActionResult DeletePackage(string id, string version)
        {
            var package = packageSvc.FindPackageByIdAndVersion(id, version);
            if (package == null)
            {
                return PackageNotFound(id, version);
            }
            if (!package.IsOwner(HttpContext.User))
            {
                return new HttpStatusCodeResult(401, "Unauthorized");
            }

            var dependents = packageSvc.FindDependentPackages(package);
            var model = new DeletePackageViewModel(package, dependents);

            if (!model.MayDelete)
            {
                return new HttpStatusCodeResult(401, "Unauthorized");
            }

            packageSvc.DeletePackage(id, version);

            TempData["Message"] = "The package was deleted";

            return Redirect(Url.PackageList());
        }
示例#9
0
        public virtual ActionResult Delete(string id, string version)
        {
            var package = packageSvc.FindPackageByIdAndVersion(id, version);
            if (package == null)
            {
                return PackageNotFound(id, version);
            }
            if (!package.IsOwner(HttpContext.User))
            {
                return new HttpStatusCodeResult(401, "Unauthorized");
            }

            var dependents = packageSvc.FindDependentPackages(package);
            var model = new DeletePackageViewModel(package, dependents);

            return View(model);
        }