1@* Generator: WebPage *@
2
3@using System.Globalization;
4@using System.Text.RegularExpressions;
5@using NuGet;
6
7@section PackageHead {
8    <script type="text/javascript" src="@Href("scripts/PackageAction.js")"></script>
9    <noscript>@PackageManagerResources.JavascriptRequired</noscript>
10}
11
12@{
13    // Read from request
14    var packageId = Request["package"];
15    var version = Request["version"];
16
17    WebProjectManager projectManager;
18    try {
19        projectManager = new WebProjectManager(PackageManagerModule.ActiveSource.Source, PackageManagerModule.SiteRoot);
20    } catch (Exception exception) {
21        <div class="error message">@exception.Message</div>
22        return;
23    }
24
25    IPackage package = projectManager.LocalRepository.FindPackage(packageId, version != null ? SemanticVersion.Parse(version) : null);
26
27    if (package == null) {
28        ModelState.AddFormError(PackageManagerResources.BadRequest);
29        @Html.ValidationSummary()
30        return;
31    }
32
33    // Set up layout values
34    var packagesHomeUrl = Href(PageUtils.GetPackagesHome(), Request.Url.Query);
35    Page.SectionTitle = String.Format(CultureInfo.CurrentCulture, PackageManagerResources.UninstallPackageDesc, package.GetDisplayName());
36
37    if (IsPost) {
38        AntiForgery.Validate();
39        bool removeDependencies = Request.Form["removeDependencies"].AsBool(false);
40        try {
41            projectManager.UninstallPackage(package, removeDependencies: removeDependencies);
42        } catch (Exception exception) {
43            ModelState.AddFormError(exception.Message);
44        }
45
46        if (ModelState.IsValid) {
47            Response.Redirect(packagesHomeUrl + "&action-completed=Uninstall");
48        }
49        else {
50            @Html.ValidationSummary(String.Format(CultureInfo.CurrentCulture, PackageManagerResources.PackageUninstallationError, package.GetDisplayName()))
51        }
52        return;
53    }
54}
55@{
56    var encodedPackageName = Html.Encode(package.GetDisplayName());
57    <h4>@Html.Raw(String.Format(CultureInfo.CurrentCulture, PackageManagerResources.AreYouSureUninstall, encodedPackageName))</h4>
58}
59<form method="post" action="" id="submitForm">
60<fieldset class="no-border">
61    @AntiForgery.GetHtml()
62    <input type="hidden" name="package" value="@packageId" />
63    <input type="hidden" name="version" value="@version" />
64    @if (package.Dependencies.Any()) {
65        <div>
66            <label><input type="checkbox" name="removeDependencies" value="true" checked="checked"/>@PackageManagerResources.RemoveDependencies</label>
67        </div>
68        <br />
69    }
70    <input type="submit" value="@PackageManagerResources.UninstallPackage" />
71    &nbsp;
72    <input type="reset" value="@PackageManagerResources.Cancel" data-returnurl="@packagesHomeUrl" />
73</fieldset>
74</form>